* {
    box-sizing: border-box;
}

:root {
    --primary: #5b6cff;
    --primary-dark: #4353e8;
    --accent: #22c55e;
    --accent-dark: #16a34a;
    --danger: #ef4444;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --border: #e6e9f2;
    --text: #22263a;
    --text-muted: #8a8fa3;
    --radius: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Gowun Dodum', 'Malgun Gothic', sans-serif;
    background: linear-gradient(160deg, #eef1fb 0%, #f7f8fd 100%);
    display: flex;
    justify-content: center;
    padding: 24px 12px;
    color: var(--text);
}

.container {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hidden {
    display: none !important;
}

h1, h2 {
    margin: 0;
    font-family: 'Nunito', 'Gowun Dodum', sans-serif;
}

h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}

h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

/* ===== Brand / Topbar ===== */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 4px;
}

.brand.small {
    justify-content: flex-start;
    margin-bottom: 0;
}

.brand-icon {
    font-size: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.topbar-actions {
    display: flex;
    gap: 6px;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 4px 16px rgba(30, 40, 90, 0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ===== Fields / Inputs ===== */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    font-size: 15px;
    font-family: inherit;
    background: #fbfcfe;
    color: var(--text);
}

input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.12);
}

/* ===== Buttons ===== */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
}

.btn {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.05s ease, opacity 0.15s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-dark);
}

.btn-ghost {
    background: #f0f1f8;
    color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
    background: #e5e7f3;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn-row .btn {
    flex: 1;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #f0f1f8;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: #e5e7f3;
}

.icon-btn.danger:hover {
    background: #fde2e2;
}

/* ===== Lists ===== */
.list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list li {
    padding: 12px 14px;
    background: #f7f8fd;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.empty-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 12px 0;
    margin: 0;
}

/* ===== Chat ===== */
.chat-box {
    height: 130px;
    overflow-y: auto;
    background: #f7f8fd;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-box p {
    margin: 0;
}

.chat-box .me {
    color: var(--primary-dark);
    font-weight: 700;
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input-row input {
    flex: 1;
}

/* ===== Badges ===== */
.badge {
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef0ff;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
}

.badge.pvp {
    background: #fff0e8;
    color: #d9581f;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 40, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal {
    background: white;
    border-radius: var(--radius);
    padding: 22px;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 12px 40px rgba(20, 24, 40, 0.2);
}

.mode-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-option {
    background: #f7f8fd;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.mode-option.selected {
    border-color: var(--primary);
    background: #eef0ff;
}

.mode-emoji {
    font-size: 24px;
}

.mode-title {
    font-weight: 700;
    font-size: 14px;
}

.mode-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Game screen ===== */
.word-card {
    text-align: center;
    background: linear-gradient(135deg, #eef0ff, #f7f2ff);
    border-radius: var(--radius);
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.word-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
}

.word-card h2 {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary-dark);
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row input {
    flex: 1;
}

.stat-row {
    display: flex;
    gap: 10px;
}

.stat {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}

.turn-indicator {
    padding: 6px 12px;
    border-radius: 999px;
    background: #e8fbef;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 700;
}

.used-words {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.used-words span {
    background: #f0f1f8;
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
    width: 100%;
    max-width: 400px;
    padding: 0 12px;
    pointer-events: none;
}

.toast {
    background: #23263a;
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: #16a34a;
}

.toast.error {
    background: #dc2626;
}

.toast.info {
    background: #23263a;
}
