.game-container {
    max-width: 1200px;
}

.game-area {
    background: var(--card-background, #fff);
    padding: 24px;
    border-radius: var(--border-radius, 8px);
    box-shadow: var(--shadow, 0 4px 6px rgba(0,0,0,0.1));
}

.status {
    min-height: 1.6em;
    margin: 12px 0 18px;
    color: var(--secondary-color, #2c3e50);
    font-size: 1.08rem;
    font-weight: 700;
    text-align: center;
}

.online-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.word-spies-layout {
    display: grid;
    grid-template-columns: minmax(260px, 330px) 1fr;
    gap: 22px;
    align-items: start;
}

.control-panel,
.board-panel {
    background: #f8fafc;
    border: 1px solid var(--border-color, #e9ecef);
    border-radius: 14px;
    padding: 18px;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.team-scoreboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.team-card {
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.team-card.active {
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.18);
}

.team-card.red {
    border-color: #e74c3c;
}

.team-card.blue {
    border-color: #2563eb;
}

.team-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
}

.team-card.red .team-name {
    color: #b42318;
}

.team-card.blue .team-name {
    color: #1d4ed8;
}

.team-remaining {
    margin-top: 6px;
    font-size: 0.9rem;
    color: var(--text-muted, #666);
}

.clue-card,
.clue-form,
.role-panel {
    background: #fff;
    border: 1px solid var(--border-color, #e9ecef);
    border-radius: 12px;
    padding: 14px;
}

.clue-card h2,
.clue-form h2,
.role-panel h2 {
    margin: 0 0 10px;
    color: var(--secondary-color, #2c3e50);
    font-size: 1rem;
}

.current-clue {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #eef2ff;
    color: #1e1b4b;
    font-weight: 800;
}

.current-clue.empty {
    justify-content: center;
    background: #f1f5f9;
    color: var(--text-muted, #666);
    font-weight: 600;
}

.current-clue .clue-word {
    font-size: 1.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.current-clue .clue-count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    background: #312e81;
    color: #fff;
    font-size: 1.1rem;
}

.clue-form label {
    display: block;
    margin: 10px 0 5px;
    color: var(--secondary-color, #2c3e50);
    font-weight: 700;
}

.clue-form input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color, #e9ecef);
    border-radius: var(--border-radius, 8px);
    font-size: 1rem;
}

.clue-form input:focus {
    outline: none;
    border-color: var(--primary-color, #2980b9);
}

.clue-form button {
    width: 100%;
    margin-top: 12px;
}

.view-controls {
    display: grid;
    gap: 10px;
}

.view-controls button {
    width: 100%;
}

.role-panel {
    font-size: 0.92rem;
}

.role-note {
    margin-bottom: 10px;
    color: var(--text-muted, #666);
    font-size: 0.85rem;
}

.role-list {
    display: grid;
    gap: 8px;
}

.role-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.role-row strong {
    color: var(--secondary-color, #2c3e50);
    overflow-wrap: anywhere;
}

.role-row.local {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.role-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.role-fields select {
    width: 100%;
    padding: 7px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

.role-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 800;
}

.role-badge.red {
    background: #fee2e2;
    color: #991b1b;
}

.role-badge.blue {
    background: #dbeafe;
    color: #1e3a8a;
}

.board-panel {
    min-width: 0;
}

.view-mode-banner {
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #ecfeff;
    color: #155e75;
    border: 1px solid #a5f3fc;
    font-weight: 700;
    text-align: center;
}

.view-mode-banner.spymaster {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}

.view-mode-banner.game-over {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    gap: 10px;
}

.word-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 86px;
    padding: 10px 8px;
    border: 2px solid #cbd5e1;
    border-radius: 14px;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    color: #172033;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
    font-size: clamp(0.78rem, 1.6vw, 1.02rem);
    font-weight: 800;
    letter-spacing: 0.015em;
    text-transform: uppercase;
    overflow-wrap: anywhere;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.word-tile:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.word-tile:disabled {
    cursor: not-allowed;
    opacity: 0.92;
    transform: none;
}

.word-tile.guessable {
    border-color: var(--primary-color, #2980b9);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.14);
}

.word-tile .tile-role {
    display: none;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.82);
    font-size: 0.68rem;
    letter-spacing: 0.03em;
}

.word-tile.revealed .tile-role,
.word-tile.key-visible .tile-role {
    display: inline-flex;
}

.word-tile.revealed,
.word-tile.key-visible {
    color: #fff;
}

.word-tile.revealed.red,
.word-tile.key-red {
    background: linear-gradient(145deg, #ef4444, #991b1b);
    border-color: #7f1d1d;
}

.word-tile.revealed.blue,
.word-tile.key-blue {
    background: linear-gradient(145deg, #3b82f6, #1e3a8a);
    border-color: #1e3a8a;
}

.word-tile.revealed.neutral,
.word-tile.key-neutral {
    background: linear-gradient(145deg, #a8a29e, #57534e);
    border-color: #44403c;
}

.word-tile.revealed.trap,
.word-tile.key-trap {
    background: linear-gradient(145deg, #111827, #020617);
    border-color: #020617;
}

.word-tile.revealed::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.88);
    color: #111827;
    font-size: 0.78rem;
    line-height: 20px;
}

.message-log {
    margin-top: 14px;
    padding: 12px 14px;
    min-height: 52px;
    border-radius: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #7c2d12;
    font-size: 0.92rem;
}

.message-log ul {
    margin: 0;
    padding-left: 18px;
}

.message-log li + li {
    margin-top: 4px;
}

.empty-board {
    grid-column: 1 / -1;
    padding: 28px;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    color: var(--text-muted, #666);
    text-align: center;
    font-weight: 700;
}

.game-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.spymaster-cover {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.72);
}

.cover-card {
    width: min(440px, 100%);
    padding: 28px;
    border-radius: 18px;
    background: #fff;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}

.cover-card h2 {
    margin-bottom: 10px;
    color: var(--secondary-color, #2c3e50);
}

.cover-card p {
    margin-bottom: 20px;
    color: var(--text-muted, #666);
}

.cover-card button {
    margin: 6px;
}

.interstitial-screen {
    background: var(--card-background, #fff);
    padding: 40px;
    border-radius: var(--border-radius, 8px);
    box-shadow: var(--shadow, 0 4px 6px rgba(0,0,0,0.1));
    max-width: 460px;
    margin: 40px auto;
    text-align: center;
}

.next-player-name {
    margin: 18px 0;
    color: var(--primary-color, #2980b9);
    font-size: 2rem;
    font-weight: 800;
}

@media (max-width: 900px) {
    .word-spies-layout {
        grid-template-columns: 1fr;
    }

    .control-panel {
        order: 2;
    }

    .board-panel {
        order: 1;
    }
}

@media (max-width: 640px) {
    .game-container {
        padding: 12px;
    }

    .game-area {
        padding: 14px;
    }

    .team-scoreboard,
    .role-actions,
    .role-fields {
        grid-template-columns: 1fr;
    }

    .word-grid {
        grid-template-columns: repeat(5, minmax(52px, 1fr));
        gap: 6px;
    }

    .word-tile {
        min-height: 64px;
        padding: 7px 4px;
        border-radius: 10px;
        font-size: 0.66rem;
    }

    .word-tile .tile-role {
        font-size: 0.56rem;
        padding: 1px 5px;
    }

    .control-panel,
    .board-panel {
        padding: 12px;
    }
}
