/* ==========================================================================
   GAME 04: NUMBER HUNT STYLESHEET
   ========================================================================== */

/* -------------------------------------------------------------
   Container Centering & Header Layout Rules
   ------------------------------------------------------------- */
.game-container.nh-game-centered,
.game-container:has(.number-hunt-container) {
    grid-template-columns: 1fr !important;
    max-width: 920px !important;
    width: 100% !important;
    margin: 0 auto !important;
}

.game-container.nh-game-centered .game-play-area,
.game-container:has(.number-hunt-container) .game-play-area {
    width: 100% !important;
    max-width: 920px !important;
    margin: 0 auto !important;
}

.number-hunt-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    gap: 14px;
    box-sizing: border-box;
}

.game-container.nh-game-centered .game-hud,
.game-container:has(.number-hunt-container) .game-hud {
    width: 100% !important;
    max-width: 920px !important;
    margin: 0 auto 14px auto !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
}

.game-hud .hud-exit-item {
    margin-left: auto !important;
    flex-shrink: 0 !important;
}


/* -------------------------------------------------------------
   HUD Header Styling
   ------------------------------------------------------------- */
.nh-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--bg-surface, #10131B);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    gap: 12px;
    flex-wrap: wrap;
}

.nh-hud-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.nh-challenge-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nh-badge-category {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--cyan, #42D9E8);
    letter-spacing: 0.8px;
}

.nh-badge-diff {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nh-badge-diff.diff-easy {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.nh-badge-diff.diff-medium {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.nh-badge-diff.diff-hard {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.nh-prompt-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.nh-hud-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nh-target-box {
    background: rgba(66, 217, 232, 0.12);
    padding: 6px 18px;
    border-radius: 20px;
    border: 1.5px solid var(--cyan, #42D9E8);
    box-shadow: 0 4px 12px rgba(66, 217, 232, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nh-target-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.nh-target-display {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--cyan, #42D9E8);
    letter-spacing: 0.5px;
    display: inline-block;
    font-family: var(--font-display);
}

.nh-hud-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nh-hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.nh-stat-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
}

.nh-stat-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.nh-attempts-badge {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--cyan, #42D9E8);
}

.nh-attempts-badge.locked {
    color: var(--crimson, #E11D48);
    font-weight: 900;
}

/* -------------------------------------------------------------
   Timer Pill & Pulse Warning
   ------------------------------------------------------------- */
.nh-timer-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(66, 217, 232, 0.12);
    border: 1.5px solid var(--cyan, #42D9E8);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--cyan, #42D9E8);
    transition: all 0.2s ease;
}

.nh-timer-unit {
    font-size: 0.8rem;
    font-weight: 600;
}

.nh-timer-pill.timer-warning {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
    animation: nhPulse 1s infinite alternate;
}

.nh-timer-pill.timer-expired {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
    font-size: 0.95rem;
}

@keyframes nhPulse {
    from {
        transform: scale(1);
        box-shadow: 0 0 4px rgba(239, 68, 68, 0.3);
    }
    to {
        transform: scale(1.06);
        box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
    }
}

/* -------------------------------------------------------------
   Play Grid Canvas Area
   ------------------------------------------------------------- */
.nh-canvas {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    min-height: auto;
    padding: 12px 10px;
    box-sizing: border-box;
    background: var(--bg-surface, #10131B);
    border-radius: 16px;
    border: 2px solid var(--border-subtle);
    touch-action: manipulation;
    user-select: none;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    align-items: center;
    justify-items: center;
}

.nh-scattered-number {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 6px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    background: var(--bg-card, #181C27);
    border: 1.5px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: background-color 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    user-select: none;
    min-height: 42px;
}

.nh-scattered-number.orient-upside-down .nh-num-text {
    transform: rotate(180deg);
    display: inline-block;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.3px;
    pointer-events: none;
    line-height: 1;
}

.nh-scattered-number:hover:not(.disabled) {
    background: rgba(66, 217, 232, 0.15);
    border-color: var(--cyan, #42D9E8);
    transform: scale(1.06);
    box-shadow: 0 6px 15px rgba(66, 217, 232, 0.2);
    z-index: 5;
}

.nh-scattered-number.correct {
    background: rgba(16, 185, 129, 0.18) !important;
    border-color: #10b981 !important;
    transform: scale(1.08) !important;
    z-index: 6;
}

.nh-scattered-number.correct .nh-num-text {
    color: #10b981 !important;
}

.nh-scattered-number.incorrect {
    background: rgba(225, 29, 72, 0.18) !important;
    border-color: var(--crimson) !important;
    animation: nhShake 0.4s ease-in-out;
}

.nh-scattered-number.incorrect .nh-num-text {
    color: var(--crimson) !important;
}

.nh-scattered-number.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none !important;
    filter: grayscale(0.8);
    background: var(--bg-card) !important;
    border-color: var(--border-subtle) !important;
}

@keyframes nhShake {
    0%, 100% { transform: scale(1.0); }
    20%, 60% { transform: scale(0.95) translateX(-4px); }
    40%, 80% { transform: scale(0.95) translateX(4px); }
}

/* -------------------------------------------------------------
   Local Feedback Overlay
   ------------------------------------------------------------- */
.nh-feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    font-size: 1.8rem;
    font-weight: 800;
    border-radius: 16px;
    z-index: 100;
    animation: nhFadeIn 0.25s ease-out;
    pointer-events: none;
    text-align: center;
    padding: 20px;
}

.nh-feedback-overlay.correct {
    color: #00ffaa;
    border: 2px solid #00ffaa;
    text-shadow: 0 0 15px rgba(0, 255, 170, 0.4);
}

.nh-feedback-overlay.incorrect {
    color: #ff0055;
    border: 2px solid #ff0055;
    text-shadow: 0 0 15px rgba(255, 0, 85, 0.4);
}

@keyframes nhFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* -------------------------------------------------------------
   Scoreboard Bottom Strip
   ------------------------------------------------------------- */
.nh-scores-panel {
    background: var(--bg-surface, #10131B);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.nh-scores-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary, #9B9EAA);
    font-weight: 800;
}

.nh-player-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nh-score-card {
    background: var(--bg-card, #181C27);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--text-primary, #F5F3EE);
}

.nh-score-card.self {
    border-color: var(--cyan, #42D9E8);
    background: var(--bg-card, #181C27);
    box-shadow: 0 2px 10px rgba(66, 217, 232, 0.2);
}

.nh-score-name {
    font-weight: 700;
}

.nh-score-val {
    color: var(--cyan, #42D9E8);
    font-weight: 800;
}

/* -------------------------------------------------------------
   Target and Match Results Screen
   ------------------------------------------------------------- */
.nh-results-wrapper {
    background: var(--bg-surface, #10131B);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 20px;
    padding: 28px 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.nh-results-card, .nh-final-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.nh-results-top-badge {
    margin-bottom: 8px;
}

.nh-results-card-title {
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: var(--text-color);
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 6px;
}

.nh-results-reveal {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-muted);
}

.nh-answer-pill {
    display: inline-block;
    background: rgba(255, 79, 112, 0.1);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 1.25rem;
}

.nh-results-list {
    width: 100%;
    max-width: 580px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nh-results-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.02);
    border-left: 4px solid var(--card-border);
    font-size: 1rem;
}

.nh-results-row.completed {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.06);
}

.nh-results-row.failed {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.04);
}

.nh-row-name {
    font-weight: 700;
}

.nh-row-time {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.nh-row-points {
    font-weight: 800;
    color: var(--primary);
}

/* -------------------------------------------------------------
   Final Results Podium
   ------------------------------------------------------------- */
.nh-results-header {
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.nh-results-complete-title {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-color);
    margin-bottom: 20px;
}

.nh-podium-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 580px;
    margin-bottom: 25px;
    min-height: 180px;
}

.nh-podium-slot {
    flex: 1;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px 12px 8px 8px;
    padding: 12px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.nh-podium-slot.rank-1 {
    height: 190px;
    background: rgba(255, 215, 0, 0.08);
    border-color: #ffd700;
}

.nh-podium-slot.rank-2 {
    height: 155px;
    border-color: #c0c0c0;
}

.nh-podium-slot.rank-3 {
    height: 130px;
    border-color: #cd7f32;
}

.nh-podium-trophy {
    font-size: 1.4rem;
}

.nh-podium-trophy.rank-1 { color: #ffd700; }
.nh-podium-trophy.rank-2 { color: #a0a0a0; }
.nh-podium-trophy.rank-3 { color: #cd7f32; }

.nh-podium-rank {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-color);
}

.nh-podium-name {
    font-weight: 700;
    font-size: 0.95rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nh-podium-score {
    color: var(--primary);
    font-weight: 800;
    font-size: 0.85rem;
}

.nh-leaderboard-list {
    width: 100%;
    max-width: 580px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.nh-leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--card-border);
    font-size: 0.95rem;
}

.nh-row-player {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nh-rank-badge {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.nh-final-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
}

/* -------------------------------------------------------------
   Responsive Breakpoints (Tablet & 390px Mobile: 8 rows x 5 cols)
   ------------------------------------------------------------- */
@media (max-width: 868px) {
    .game-container.nh-game-centered,
    .game-container:has(.number-hunt-container),
    .number-hunt-container,
    .game-container.nh-game-centered .game-play-area,
    .game-container:has(.number-hunt-container) .game-play-area,
    .game-container.nh-game-centered .game-hud,
    .game-container:has(.number-hunt-container) .game-hud,
    .nh-hud,
    .nh-podium-container,
    .nh-leaderboard-list {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    .nh-hud-left {
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

@media (max-width: 768px) {
    .nh-canvas {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        grid-template-rows: repeat(8, minmax(0, 1fr));
        gap: 6px;
        padding: 10px 8px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .nh-scattered-number {
        min-height: 40px;
        padding: 6px 4px;
        border-radius: 8px;
    }

    .nh-scattered-number.orient-upside-down .nh-num-text,
    .nh-scattered-number.orient-normal .nh-num-text {
        font-size: 1.0rem !important;
        letter-spacing: 0.5px !important;
    }
    
    .nh-hud {
        padding: 10px 14px;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .nh-hud {
        padding: 8px 10px;
        gap: 6px;
    }

    .nh-hud-left {
        min-width: 0 !important;
    }

    .nh-challenge-meta {
        gap: 4px;
    }

    .nh-badge-category {
        font-size: 0.68rem;
    }

    .nh-badge-diff {
        font-size: 0.6rem;
        padding: 1px 6px;
    }

    .nh-prompt-text {
        font-size: 0.75rem;
    }

    .nh-target-box {
        padding: 4px 12px;
    }

    .nh-target-display {
        font-size: 1.15rem;
    }

    .nh-timer-pill {
        padding: 4px 10px;
        font-size: 0.95rem;
    }

    .nh-canvas {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        grid-template-rows: repeat(8, minmax(0, 1fr));
        gap: 5px;
        padding: 8px 6px;
    }

    .nh-scattered-number {
        min-height: 38px;
        padding: 4px 2px;
        border-radius: 6px;
    }

    .nh-scattered-number.orient-upside-down .nh-num-text,
    .nh-scattered-number.orient-normal .nh-num-text {
        font-size: 0.92rem !important;
        letter-spacing: 0.3px !important;
    }

    .nh-podium-container {
        gap: 6px;
        min-height: 150px;
    }

    .nh-podium-slot.rank-1 { height: 160px; }
    .nh-podium-slot.rank-2 { height: 135px; }
    .nh-podium-slot.rank-3 { height: 115px; }
}

@media (max-width: 350px) {
    .nh-canvas {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        grid-template-rows: repeat(8, minmax(0, 1fr));
        gap: 4px;
        padding: 6px 4px;
    }

    .nh-scattered-number {
        min-height: 34px;
        padding: 3px 1px;
        border-radius: 5px;
    }

    .nh-scattered-number.orient-upside-down .nh-num-text,
    .nh-scattered-number.orient-normal .nh-num-text {
        font-size: 0.82rem !important;
        letter-spacing: 0px !important;
    }
}
