* {
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

body {
    margin: 0;
    padding: 0;
}

.page-bg {
    background: #111827;
    color: #fff;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.card {
    background: #1f2937;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    padding: 24px;
}

.home-card {
    max-width: 700px;
    margin: 40px auto;
}

h1, h2, h3 {
    margin-top: 0;
}

.sub {
    color: #d1d5db;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #374151;
    background: #111827;
    color: #fff;
    font-size: 16px;
}

.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.btn {
    border: none;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.primary { background: #2563eb; color: white; }
.success { background: #16a34a; color: white; }
.warning { background: #f59e0b; color: white; }

.divider {
    border: none;
    border-top: 1px solid #374151;
    margin: 24px 0;
}

.tips {
    margin-top: 24px;
    color: #d1d5db;
}

code {
    background: #111827;
    padding: 4px 8px;
    border-radius: 8px;
}

.game-card {
    margin-top: 20px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.status-pill {
    background: #374151;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: bold;
}

.meta-line {
    color: #d1d5db;
    margin-top: 6px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 20px;
}

.info-box {
    background: #111827;
    padding: 16px;
    border-radius: 14px;
}

.info-box .label {
    color: #9ca3af;
    font-size: 13px;
    margin-bottom: 6px;
}

.info-box .value {
    font-size: 18px;
    font-weight: bold;
}

.word-box {
    margin-top: 24px;
    background: #111827;
    border-radius: 16px;
    padding: 24px;
    font-size: 34px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: bold;
    word-break: break-word;
    white-space: pre-wrap;
}

.hangman-section {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    margin-top: 20px;
}

.hangman-drawing,
.players-panel,
.wrong-box,
.controls,
.result-box {
    background: #111827;
    border-radius: 16px;
    padding: 18px;
}

.hangman-drawing pre {
    font-size: 20px;
    margin: 0;
    white-space: pre;
    overflow-x: auto;
}

.player-item {
    display: flex;
    justify-content: space-between;
    background: #1f2937;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.current-turn {
    border: 2px solid #22c55e;
}

.wrong-box {
    margin-top: 20px;
}

.controls {
    margin-top: 20px;
}

.guess-row {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.guess-row input {
    max-width: 120px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.key-btn {
    padding: 12px 10px;
    border: none;
    border-radius: 10px;
    background: #374151;
    color: white;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
}

.key-btn:hover {
    background: #4b5563;
}

.result-box {
    margin-top: 20px;
    font-size: 18px;
    min-height: 60px;
}

/* BOARD PAGE */
.board-page {
    background: #0b1220;
    color: white;
    min-height: 100vh;
    padding: 20px;
}

.board-wrap {
    max-width: 1500px;
    margin: 0 auto;
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.board-meta {
    font-size: 22px;
    color: #cbd5e1;
}

.board-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
}

.big-word {
    font-size: 40px;
    letter-spacing: 10px;
    background: #111827;
    padding: 28px;
    border-radius: 20px;
    text-align: center;
    margin-bottom: 20px;
    white-space: pre-wrap;
}

.board-hint,
.board-turn,
.board-wrong,
.board-result,
.score-panel {
    background: #111827;
    padding: 20px;
    border-radius: 18px;
    margin-bottom: 18px;
    font-size: 22px;
}

.board-art {
    background: #111827;
    padding: 20px;
    border-radius: 18px;
    font-size: 28px;
    min-height: 340px;
    white-space: pre;
    overflow-x: auto;
}

@media (max-width: 900px) {
    .info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .hangman-section {
        grid-template-columns: 1fr;
    }

    .keyboard {
        grid-template-columns: repeat(5, 1fr);
    }

    .board-grid {
        grid-template-columns: 1fr;
    }

    .big-word {
        font-size: 34px;
        letter-spacing: 6px;
    }
}

@media (max-width: 600px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .word-box {
        font-size: 24px;
        letter-spacing: 4px;
    }

    .keyboard {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* =========================
   RESULT POPUP + CONFETTI
   ========================= */

.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    overflow: hidden;
}

.result-overlay.hidden {
    display: none;
}

.result-popup {
    position: relative;
    z-index: 3;
    width: min(92vw, 560px);
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    color: white;
    border-radius: 24px;
    padding: 28px 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
    border: 2px solid rgba(255,255,255,0.08);
    animation: popupBounce 0.45s ease;
}

.popup-emoji {
    font-size: 56px;
    margin-bottom: 10px;
}

.result-popup h2 {
    margin: 0 0 12px 0;
    font-size: 34px;
}

.result-popup p {
    margin: 0 0 20px 0;
    font-size: 20px;
    line-height: 1.5;
    color: #e5e7eb;
}

@keyframes popupBounce {
    0% {
        transform: scale(0.75);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

.confetti-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 18px;
    opacity: 0.95;
    border-radius: 3px;
    animation-name: confettiFall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.confetti-piece.circle {
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.confetti-piece.big {
    width: 14px;
    height: 22px;
}

@keyframes confettiFall {
    0% {
        transform: translate3d(0, -20px, 0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate3d(var(--tx), 110vh, 0) rotate(var(--rot));
        opacity: 1;
    }
}

/* board popup a little larger */
.board-page .result-popup {
    width: min(92vw, 760px);
    padding: 36px 28px;
}

.board-page .result-popup h2 {
    font-size: 42px;
}

.board-page .result-popup p {
    font-size: 26px;
}

@media (max-width: 700px) {
    .result-popup {
        width: 92vw;
        padding: 22px 18px;
    }

    .result-popup h2 {
        font-size: 28px;
    }

    .result-popup p {
        font-size: 17px;
    }

    .popup-emoji {
        font-size: 42px;
    }
}

.key-btn.used,
.key-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #1f2937;
}


