/* === CSS Reset & Base === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #f5e6cc;
    --text-primary: #000000;
    --text-secondary: #666666;
    --btn-color: #e34b34;
    --btn-hover: #d03e28;
    --input-border: #cccccc;
    --selected-bg: #d4edda;
    --selected-border: #28a745;

    /* Game colors */
    --blue-team: #2e7dd1;
    --blue-team-light: #5a9ee0;
    --red-team: #c9433a;
    --red-team-light: #e06860;
    --neutral-color: #d4b86a;
    --assassin-color: #1a1a1a;
    --card-bg: #f0e8dc;
    --card-border: rgba(0, 0, 0, 0.12);
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Noto Serif', Georgia, serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
}

/* === Screens === */
.screen {
    display: none;
    min-height: 100vh;
    padding: 2rem;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* === Home Screen === */
#home-screen {
    justify-content: flex-start;
    padding-top: 12vh;
    position: relative;
}

.title {
    font-size: clamp(2.75rem, 8vw, 5rem);
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 3.5rem;
    letter-spacing: -0.02em;
}

.button-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 0;
    flex-wrap: wrap;
}

.home-description {
    font-size: 1.15rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 600px;
    margin-top: 3rem;
    line-height: 1.6;
    padding: 0 1rem;
    font-weight: 400;
}

/* === Admin Lock Button === */
.admin-lock-btn {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s ease;
    padding: 0.5rem;
}

.admin-lock-btn:hover {
    opacity: 0.6;
}

.lock-icon {
    width: 24px;
    height: 24px;
}

/* === Buttons === */
.btn {
    font-family: 'Noto Serif', Georgia, serif;
    background-color: var(--btn-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn:hover {
    background-color: var(--btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(227, 75, 52, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn-large {
    font-size: 1.1rem;
    padding: 1rem 2.5rem;
    min-width: 200px;
}

.btn-small {
    font-size: 1.1rem;
    padding: 1rem 2.5rem;
    background-color: white;
    color: var(--text-primary);
    border: 2px solid #e0e0e0;
    min-width: 200px;
}

.btn-small:hover {
    background-color: #fafafa;
    border-color: #d0d0d0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.btn-go {
    font-size: 1.25rem;
    padding: 0.875rem 2.5rem;
    min-width: 100px;
}

/* === Back Button === */
.back-btn {
    position: absolute;
    top: 2rem;
    left: 2rem;
    background: none;
    border: none;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 1.1rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.back-btn:hover {
    color: var(--text-primary);
}

/* === Create Room Screen === */
#create-screen {
    position: relative;
    justify-content: flex-start;
    padding-top: 12vh;
}

.create-container {
    width: 100%;
    max-width: 650px;
}

.input-row {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
}

.url-input {
    flex: 1;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 1.25rem;
    padding: 1rem 1.25rem;
    border: 2px solid var(--input-border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    outline: none;
    transition: border-color 0.2s ease;
}

.url-input:focus {
    border-color: var(--btn-color);
}

.url-input::placeholder {
    color: #999999;
}

.input-row .btn-go {
    border-radius: 0 8px 8px 0;
}

/* === Timer Section === */
.timer-section {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.timer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timer-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.timer-label {
    font-size: 1.1rem;
}

.timer-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* === Toggle Switch === */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle.small {
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle.small .toggle-slider:before {
    height: 16px;
    width: 16px;
}

.toggle input:checked+.toggle-slider {
    background-color: var(--btn-color);
}

.toggle input:checked+.toggle-slider:before {
    transform: translateX(22px);
}

.toggle.small input:checked+.toggle-slider:before {
    transform: translateX(18px);
}

/* === Timer Options === */
.timer-options {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.timer-options.hidden {
    display: none;
}

.timer-duration-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.option-label {
    font-size: 1rem;
    font-weight: 500;
}

.duration-input {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    width: 100px;
    border: 2px solid var(--input-border);
    border-radius: 6px;
    text-align: center;
    outline: none;
}

.duration-input.small {
    width: 80px;
    font-size: 0.9rem;
    padding: 0.4rem 0.5rem;
}

.duration-input:focus {
    border-color: var(--btn-color);
}

.duration-input:disabled {
    background-color: #eee;
    color: #999;
    cursor: not-allowed;
}

.timer-cap-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cap-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.radio-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
    transition: background 0.2s ease;
}

.radio-option:hover {
    background: rgba(255, 255, 255, 0.8);
}

.radio-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--btn-color);
}

.radio-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.radio-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    width: 100%;
    margin-left: 26px;
}

/* === Words Section === */
.words-section {
    margin-top: 1rem;
}

.words-count {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.word-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.word-btn {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background-color: white;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.word-btn:hover {
    border-color: var(--text-secondary);
}

.word-btn.selected {
    background-color: var(--selected-bg);
    border-color: var(--selected-border);
}

/* === Join Room Screen === */
#join-screen {
    position: relative;
    justify-content: flex-start;
    padding-top: 20vh;
}

.join-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.join-container .input-row {
    width: 100%;
    margin-bottom: 1.5rem;
}

.join-container .url-input {
    border-radius: 8px;
    border-right: 2px solid var(--input-border);
    text-align: center;
}

#join-game-btn {
    transition: opacity 0.3s ease, transform 0.15s ease;
}

.hidden {
    display: none !important;
}

/* ============================== */
/* === GAME SCREEN STYLES === */
/* ============================== */

#game-screen {
    padding: 1rem 1.5rem;
    max-width: 100%;
    position: relative;
    overflow: hidden;
}

.game-header {
    text-align: center;
    margin-bottom: 0.75rem;
    width: 100%;
    max-width: 1100px;
}

.game-title {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.game-title.clickable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.game-title.clickable:hover {
    opacity: 0.7;
}

.header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.share-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.share-link a {
    color: var(--text-primary);
    text-decoration: underline;
}

/* === Online Widget === */
.online-widget {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #2d2d2d;
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* === Game Info Bar === */
.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto 0.5rem;
    padding: 0.5rem 0;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    min-width: 140px;
}

.score {
    font-weight: 500;
}

.blue-score {
    color: var(--blue-team);
}

.red-score {
    color: var(--red-team);
}

.score-divider {
    color: var(--text-secondary);
}

.turn-display {
    flex: 1;
    text-align: center;
}

.turn-indicator {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 0.4rem 1.25rem;
    border-radius: 8px;
}

.blue-turn {
    color: var(--blue-team);
}

.red-turn {
    color: var(--red-team);
}

.blue-win {
    color: var(--blue-team);
    font-size: 1.6rem;
}

.red-win {
    color: var(--red-team);
    font-size: 1.6rem;
}

.end-turn-spacer {
    min-width: 140px;
    display: flex;
    justify-content: flex-end;
}

.btn-end-turn {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 6px;
}

.btn-end-turn:hover {
    background: #f5f5f5;
    transform: none;
}

/* === Timer Display === */
.timer-display {
    text-align: center;
    margin-bottom: 0.75rem;
    width: 100%;
    max-width: 1100px;
}

.timer-display span {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    background: white;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    border: 2px solid var(--input-border);
}

.timer-display.warning span {
    color: var(--btn-color);
    border-color: var(--btn-color);
}

/* === Game Board === */
.game-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.card {
    aspect-ratio: 2 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    font-size: clamp(0.9rem, 1.8vw, 1.15rem);
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    padding: 0.75rem 0.5rem;
    text-align: center;
    min-height: 70px;
}

.card:hover:not(.revealed):not(.no-click) {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card.revealed {
    cursor: default;
}

.card.no-click {
    cursor: default;
}

.card.no-click:hover {
    transform: none;
    box-shadow: none;
}

/* Revealed card colors */
.card.revealed.blue {
    background-color: var(--blue-team);
    border-color: #1e5a9e;
    color: white;
}

.card.revealed.red {
    background-color: var(--red-team);
    border-color: #a32e27;
    color: white;
}

.card.revealed.neutral {
    background-color: var(--neutral-color);
    border-color: #b8993d;
    color: white;
}

.card.revealed.assassin {
    background-color: var(--assassin-color);
    border-color: #000;
    color: white;
}

/* === Spymaster View - Colored Words Only === */
.spymaster-view .card.blue-word:not(.revealed) {
    color: var(--blue-team);
}

.spymaster-view .card.red-word:not(.revealed) {
    color: var(--red-team);
}

.spymaster-view .card.neutral-word:not(.revealed) {
    color: #b8943a;
}

.spymaster-view .card.assassin-word:not(.revealed) {
    color: var(--assassin-color);
    border: 3px solid var(--assassin-color);
    background: rgba(26, 26, 26, 0.08);
}

/* Spymaster view - revealed cards show border only, not filled */
.spymaster-view .card.revealed.blue {
    background-color: var(--card-bg);
    border: 3px solid var(--blue-team);
    color: var(--blue-team);
}

.spymaster-view .card.revealed.red {
    background-color: var(--card-bg);
    border: 3px solid var(--red-team);
    color: var(--red-team);
}

.spymaster-view .card.revealed.neutral {
    background-color: var(--card-bg);
    border: 3px solid var(--neutral-color);
    color: #8a7530;
}

.spymaster-view .card.revealed.assassin {
    background-color: rgba(26, 26, 26, 0.15);
    border: 4px solid var(--assassin-color);
    color: var(--assassin-color);
}

/* === Game Controls === */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1100px;
    margin: 1rem auto 0;
}

.view-buttons {
    display: flex;
    gap: 0.5rem;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.view-btn {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background: #f0f0f0;
}

.view-btn.active {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

.btn-next-game {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.settings-btn {
    background: white;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    padding: 0.4rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: #f0f0f0;
}

.settings-icon {
    width: 22px;
    height: 22px;
    stroke: #555;
    stroke-width: 1.5;
}

/* === Settings Panel === */
.settings-panel {
    position: absolute;
    bottom: 80px;
    right: 1.5rem;
    background: white;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 250px;
}

.settings-content h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--input-border);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

/* === Confetti === */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    opacity: 0.9;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.modal-content p {
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-cancel {
    background: #888;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
}

.btn-cancel:hover {
    background: #777;
}

.btn-confirm {
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
}

/* === Responsive === */
@media (max-width: 900px) {
    .game-board {
        gap: 8px;
    }

    .card {
        font-size: 0.85rem;
        min-height: 60px;
    }
}

@media (max-width: 768px) {
    #game-screen {
        padding: 0.75rem;
    }

    .game-header {
        margin-bottom: 0.5rem;
    }

    .game-title {
        font-size: 1.5rem;
        margin-bottom: 0.35rem;
    }

    .header-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .share-link {
        font-size: 0.75rem;
        max-width: 100%;
        word-break: break-all;
        padding: 0 0.5rem;
    }

    .share-link a {
        display: inline-block;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: bottom;
    }

    .online-widget {
        padding: 0.3rem 0.7rem;
        font-size: 0.75rem;
    }

    .game-info-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.4rem 0;
        margin-bottom: 0.4rem;
    }

    .turn-display {
        order: -1;
        width: 100%;
        text-align: center;
    }

    .score-display {
        min-width: auto;
        font-size: 1rem;
        gap: 0.5rem;
    }

    .end-turn-spacer {
        min-width: auto;
    }

    .turn-indicator {
        font-size: 1.1rem;
        padding: 0.3rem 0.75rem;
    }

    /* Game Board - Critical mobile fix */
    .game-board {
        gap: 4px;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin-bottom: 160px;
    }

    .card {
        font-size: clamp(0.55rem, 2.5vw, 0.75rem);
        min-height: 45px;
        padding: 0.4rem 0.25rem;
        border-radius: 4px;
        aspect-ratio: auto;
    }

    /* Timer display mobile */
    .timer-display {
        margin-bottom: 0.5rem;
    }

    .timer-display span {
        font-size: 1.5rem;
        padding: 0.35rem 1rem;
    }

    /* Game controls mobile */
    .game-controls {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 0;
        z-index: 10;
        max-width: calc(100% - 2rem);
    }

    .view-buttons {
        width: 100%;
        justify-content: center;
        order: 2;
    }

    .view-btn {
        flex: 1;
        text-align: center;
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .control-buttons {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
        order: 1;
    }

    .btn-next-game {
        flex: 1;
        text-align: center;
        padding: 0.6rem 0.75rem;
    }

    .settings-btn {
        padding: 0.5rem;
    }

    .settings-panel {
        right: 0.75rem;
        left: 0.75rem;
        bottom: 140px;
        min-width: auto;
    }

    .setting-row {
        font-size: 0.85rem;
    }
}

@media (max-width: 600px) {

    /* Home screen mobile */
    #home-screen {
        padding-top: 8vh;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .title {
        font-size: 2.5rem;
        margin-bottom: 2rem;
    }

    .button-container {
        width: 100%;
        max-width: 350px;
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn-large,
    .btn-small {
        font-size: 1rem;
        padding: 0.9rem 2rem;
        width: 100%;
        min-width: auto;
    }

    .home-description {
        font-size: 1rem;
        margin-top: 2.5rem;
        padding: 0 0.5rem;
    }

    /* Create/Join screens mobile */
    #create-screen,
    #join-screen {
        padding-top: 10vh;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .create-container,
    .join-container {
        padding: 0;
        max-width: 100%;
    }

    .input-row {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .url-input {
        border-radius: 8px;
        border-right: 2px solid var(--input-border);
        font-size: 1rem;
        padding: 0.875rem 1rem;
        text-align: center;
    }

    .input-row .btn-go {
        border-radius: 8px;
        width: 100%;
        padding: 0.875rem;
    }

    .back-btn {
        top: 1rem;
        left: 1rem;
        font-size: 1rem;
    }

    /* Timer section mobile */
    .timer-section {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .timer-row {
        gap: 1rem;
    }

    .timer-label {
        font-size: 1rem;
    }

    .timer-description {
        font-size: 0.8rem;
    }

    .timer-duration-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .duration-input {
        width: 100%;
    }

    .radio-option {
        padding: 0.6rem;
    }

    .radio-description {
        margin-left: 22px;
        font-size: 0.75rem;
    }

    /* Words section mobile */
    .words-section {
        margin-top: 0.5rem;
    }

    .words-count {
        font-size: 0.9rem;
    }

    .word-options {
        flex-direction: column;
    }

    .word-btn {
        width: 100%;
        padding: 0.6rem 1rem;
        text-align: center;
    }

    /* Join container specifics */
    .join-container .input-row {
        margin-bottom: 1rem;
    }

    #join-game-btn {
        width: 100%;
    }

    /* Card further reduction */
    .card {
        font-size: clamp(0.5rem, 2.2vw, 0.65rem);
        min-height: 40px;
        padding: 0.3rem 0.2rem;
    }

    /* Blue/Red win states */
    .blue-win,
    .red-win {
        font-size: 1.2rem;
    }

    /* Modal mobile */
    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
        max-width: calc(100% - 2rem);
    }

    .modal-content p {
        font-size: 0.95rem;
        margin-bottom: 1.25rem;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }

    .btn-cancel,
    .btn-confirm {
        width: 100%;
    }
}

/* Extra small screens (under 400px) */
@media (max-width: 400px) {
    .title {
        font-size: 1.75rem;
    }

    .game-title {
        font-size: 1.25rem;
    }

    .card {
        font-size: 0.45rem;
        min-height: 35px;
        padding: 0.25rem 0.15rem;
    }

    .game-board {
        gap: 3px;
    }

    .score-display {
        font-size: 0.9rem;
    }

    .turn-indicator {
        font-size: 1rem;
        padding: 0.25rem 0.5rem;
    }

    .share-link a {
        max-width: 150px;
    }

    .view-btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.5rem;
    }

    .btn-next-game {
        font-size: 0.8rem;
    }

    .admin-lock-btn {
        bottom: 1rem;
        left: 1rem;
    }

    .lock-icon {
        width: 20px;
        height: 20px;
    }
}

/* Landscape mobile orientation fix */
@media (max-height: 500px) and (orientation: landscape) {
    #home-screen {
        padding-top: 3vh;
    }

    .home-description {
        margin-top: 3vh;
    }

    #create-screen,
    #join-screen {
        padding-top: 5vh;
    }

    .game-header {
        margin-bottom: 0.25rem;
    }

    .game-title {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .game-info-bar {
        margin-bottom: 0.25rem;
        padding: 0.25rem 0;
    }

    .turn-indicator {
        font-size: 1rem;
        padding: 0.2rem 0.5rem;
    }

    .card {
        min-height: 30px;
    }

    .game-controls {
        margin-top: 0.5rem;
    }

    .timer-display {
        margin-bottom: 0.25rem;
    }

    .timer-display span {
        font-size: 1.25rem;
        padding: 0.25rem 0.75rem;
    }
}

/* === Admin Screen === */
#admin-screen {
    position: relative;
    justify-content: flex-start;
    padding-top: 5vh;
}

.admin-container {
    width: 100%;
    max-width: 900px;
    padding: 0 1rem;
}

.admin-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
}

.admin-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 1.5rem 2.5rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--btn-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.admin-section {
    background: white;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--input-border);
}

.admin-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.rooms-list {
    max-height: 400px;
    overflow-y: auto;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
}

.room-item:last-child {
    border-bottom: none;
}

.room-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.room-code {
    font-weight: 600;
    font-size: 1rem;
}

.room-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.room-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
}

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

.btn-icon.delete {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-icon.delete:hover {
    background: #dc3545;
    color: white;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.no-rooms {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}