/* ============================================================
   BRAIN GYM v2 — bright, playful, dopamine-engineered
   Palette: green #58cc02 | blue #1cb0f6 | yellow #ffc800
            red #ff4b4b   | purple #ce82ff | ink #3b3b54
   Type: Nunito 700/800/900 (rounded, chunky)
   Responsive: desktop-first; additive media queries at
   900px / 600px / 480px (per HeyPN 4-breakpoint standard)
   ============================================================ */

:root {
    --bg: #eaf6ff;
    --card: #ffffff;
    --ink: #3b3b54;
    --ink-soft: #8a8aa3;
    --line: #e5e5f0;

    --green: #58cc02;        --green-shade: #46a302;
    --blue: #1cb0f6;         --blue-shade: #1493cf;
    --yellow: #ffc800;       --yellow-shade: #e0a500;   --yellow-soft: #fff3c4;
    --red: #ff4b4b;          --red-shade: #d93636;
    --purple: #ce82ff;       --purple-shade: #a95fd6;
    --orange: #ff9600;

    --radius: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', 'Segoe UI', Tahoma, sans-serif;
}

body {
    background:
        radial-gradient(circle at 12% 18%, rgba(88, 204, 2, 0.10), transparent 32%),
        radial-gradient(circle at 88% 12%, rgba(206, 130, 255, 0.14), transparent 30%),
        radial-gradient(circle at 82% 88%, rgba(28, 176, 246, 0.14), transparent 34%),
        var(--bg);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 16px;
    padding-top: 72px; /* clears the fixed top-header below */
    overflow-x: hidden;
}

.ad-placeholder { display: none; }

/* Issues #1-3: logo, version tag, and sound toggle live together in one
   fixed bar that's always on screen — including over the Game Over overlay
   and the mode-select screen. */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 2px solid var(--line);
    z-index: 110;
}

.brand-inline {
    font-weight: 900;
    font-size: 1.05rem;
    letter-spacing: 3px;
    color: var(--ink);
    white-space: nowrap;
    user-select: none;
}

/* ---------------- Game card ---------------- */

.game-container {
    width: 100%;
    max-width: 600px;
    background: var(--card);
    border-radius: 24px;
    border: 2px solid var(--line);
    border-bottom-width: 6px;
    box-shadow: 0 12px 40px rgba(59, 59, 84, 0.08);
    padding: 20px;
    position: relative;
}

/* ---------------- Header pills ---------------- */

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.pill {
    background: #fff;
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 1rem;
    font-weight: 900;
    color: var(--ink);
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.pill-stage  { color: var(--blue); }
.pill-streak { color: var(--orange); }

/* Pro badge — white fill, bold red border/text; approved SUBCONV 93 */
.pill-pro {
    background: #fff;
    border: 3px solid var(--red);
    border-bottom-width: 5px;
    color: var(--red);
    letter-spacing: 1px;
    padding: 8px 14px;
    font-size: 0.9rem;
    gap: 6px;
}

.stat-pop { animation: statPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* The Pressure Pill — calm → warn → panic */
.timer-container {
    font-size: 1.25rem;
    letter-spacing: 1px;
    color: var(--green);
    border-color: #d9f0c5;
    min-width: 86px;
    text-align: center;
}

.timer-warn {
    color: #8a6d00;
    background: var(--yellow-soft);
    border-color: var(--yellow);
}

.timer-danger {
    color: #fff;
    background: var(--red);
    border-color: var(--red-shade);
    animation: heartbeat 0.7s ease-in-out infinite;
}

/* ---------------- Condition rule chip ---------------- */

.condition-box {
    background: var(--purple);
    border-bottom: 4px solid var(--purple-shade);
    color: #fff;
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 1.15rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------------- Grid ---------------- */

.grid-wrapper { position: relative; margin-bottom: 20px; }

.puzzle-grid { display: grid; gap: 10px; }

.meta-grid-wrapper {
    display: flex !important;
    flex-direction: column;
    gap: 18px;
}

.sub-grid {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: #f4f9ff;
    border-radius: 18px;
    border: 2px dashed #c3ddf5;
}

.locked-key {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--yellow-shade);
    text-shadow: 0 0 8px rgba(255, 200, 0, 0.55);
    animation: pulse 1.4s infinite;
}

.grid-cell {
    aspect-ratio: 1;
    background: var(--blue);
    border-bottom: 4px solid var(--blue-shade);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.35rem;
    font-weight: 900;
    border-radius: 16px;
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1.4) forwards;
    opacity: 0;
    transform: scale(0.7);
    min-height: 44px;
    overflow: hidden;
    text-align: center;
    word-break: break-word;
}

/* Long string content (equations, factorizations, binary) — relax the square */
.cell-wide {
    aspect-ratio: auto;
    padding: 12px 8px;
    font-size: 1rem;
    line-height: 1.3;
}

.grid-input {
    width: 100%;
    height: 100%;
    min-height: 44px;
    border: 3px solid var(--yellow);
    border-bottom-width: 5px;
    background: var(--yellow-soft);
    color: var(--ink);
    text-align: center;
    font-size: 1.45rem;
    font-weight: 900;
    border-radius: 13px;
    outline: none;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    -moz-appearance: textfield;
}

.grid-input::-webkit-outer-spin-button,
.grid-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.grid-input:focus {
    border-color: var(--orange);
    background: #fff;
    transform: scale(1.06);
}

.grid-input:disabled {
    background: #eef0f4;
    border-color: #d5d9e2;
    color: var(--ink-soft);
    transform: none;
}

.shake {
    animation: errorShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    border-color: var(--red) !important;
    background: #ffe3e3 !important;
}

.success-pulse { animation: successGreen 0.45s ease-out forwards; }

/* ---------------- Single-answer puzzles (Odd One Out) ---------------- */

.single-answer-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f4f9ff;
    border: 2px dashed #c3ddf5;
    border-radius: 16px;
    padding: 12px;
    margin-top: 4px;
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1.4) forwards;
}

.single-answer-label {
    flex: 1;
    font-weight: 900;
    font-size: 1rem;
    color: var(--ink);
    line-height: 1.35;
}

.single-answer-input {
    flex: 0 0 110px;
    height: 56px;
}

/* ---------------- Buttons: chunky 3D press-down ---------------- */

.btn-primary, .btn-lifeline {
    padding: 15px 24px;
    font-size: 1.1rem;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 900;
    width: 100%;
    min-height: 44px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #fff;
    transition: filter 0.15s ease, transform 0.05s ease, border-bottom-width 0.05s ease;
}

.btn-primary {
    background: var(--green);
    border-bottom: 5px solid var(--green-shade);
}

.btn-lifeline {
    background: var(--orange);
    border-bottom: 5px solid #cc7800;
    margin-bottom: 14px;
}

.btn-primary:hover, .btn-lifeline:hover { filter: brightness(1.06); }

.btn-primary:active, .btn-lifeline:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

/* ---------------- Mode selection (first launch) ---------------- */

.mode-select {
    position: fixed;
    inset: 0;
    z-index: 100;
    background:
        radial-gradient(circle at 15% 20%, rgba(88, 204, 2, 0.14), transparent 34%),
        radial-gradient(circle at 85% 80%, rgba(255, 75, 75, 0.14), transparent 34%),
        var(--bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    padding-top: 76px;
    text-align: center;
    overflow-y: auto;
}

.mode-select .ms-title {
    font-weight: 900;
    font-size: 1.6rem;
    letter-spacing: 5px;
    margin-bottom: 8px;
}

.mode-select .ms-sub {
    font-weight: 900;
    font-size: 1.15rem;
    color: var(--ink-soft);
    margin-bottom: 28px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-mode {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 420px;
    padding: 18px 22px;
    margin-bottom: 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    color: #fff;
    font-weight: 900;
    font-size: 1.3rem;
    letter-spacing: 2px;
    min-height: 44px;
    transition: filter 0.15s ease, transform 0.05s ease, border-bottom-width 0.05s ease;
}

.btn-mode span {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    opacity: 0.92;
    text-transform: none;
}

.btn-mode-newbie { background: var(--green); border-bottom: 6px solid var(--green-shade); }
.btn-mode-pro    { background: var(--red);   border-bottom: 6px solid var(--red-shade); }

.btn-mode:hover { filter: brightness(1.06); }
.btn-mode:active { transform: translateY(3px); border-bottom-width: 3px; }

.mode-note {
    margin-top: 8px;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

/* ---------------- Game-over overlay ---------------- */

.overlay {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(234, 246, 255, 0.94);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 65;
    padding: 10px 14px 14px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
}

.hidden { display: none !important; }

.overlay h2 {
    font-size: 2rem;
    font-weight: 900;
    color: var(--ink);
    margin-bottom: 10px;
}

.grace-period {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 82%;
    margin-top: 10vh;
}

.heartbeat-timer {
    font-size: 3.2rem;
    color: var(--red);
    font-weight: 900;
    animation: heartbeat 0.9s ease-in-out infinite;
}

.restart-menu {
    text-align: center;
    background: #fff;
    padding: 14px;
    border-radius: 20px;
    border: 2px solid var(--line);
    border-bottom-width: 5px;
    box-shadow: 0 12px 30px rgba(59, 59, 84, 0.14);
    width: 92%;
    max-width: 480px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    margin: 0 auto;
}

.answer-reveal {
    background: #fff6f6;
    border: 2px solid #ffd6d6;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 14px;
    text-align: left;
}

/* Issue #3: mini snapshot of the last puzzle, shown above the reveal so the
   answer + logic can be related back to what the player was actually looking at. */
.reveal-puzzle {
    display: grid;
    gap: 5px;
    margin-bottom: 10px;
}

.reveal-puzzle .sub-grid {
    padding: 6px;
    gap: 5px;
}

.reveal-puzzle .grid-cell {
    font-size: 0.85rem;
    min-height: 28px;
    animation: none;
    opacity: 1;
    transform: none;
}

.reveal-puzzle .cell-wide {
    font-size: 0.68rem;
    padding: 5px 4px;
}

.reveal-blank-cell {
    background: #eef0f4;
    color: var(--ink-soft);
    border-bottom-color: #d5d9e2;
}

.reveal-answer-cell {
    background: var(--green);
    border-bottom-color: var(--green-shade);
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.reveal-key-cell {
    background: var(--yellow);
    border-bottom-color: var(--yellow-shade);
    color: var(--ink);
    font-size: 0.8rem;
}

.reveal-prompt-label {
    grid-column: 1 / -1;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--ink-soft);
    text-align: left;
    padding-top: 2px;
}

/* Issue #2: gated reveal — no auto-shown answer */
.btn-reveal {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: var(--orange);
    border-bottom: 4px solid #cc7800;
    color: #fff;
    font-weight: 900;
    font-size: 0.95rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.05s ease, border-bottom-width 0.05s ease;
}

.btn-reveal:hover { filter: brightness(1.06); }
.btn-reveal:active { transform: translateY(2px); border-bottom-width: 2px; }

.reveal-content { animation: fadeIn 0.25s ease-out; }

#reveal-text {
    font-weight: 900;
    color: var(--red);
    margin-bottom: 4px;
    font-size: 0.95rem;
}

#logic-text {
    color: var(--ink-soft);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.35;
}

.iq-badge {
    margin-bottom: 10px;
    padding: 8px;
    background: var(--purple);
    border-bottom: 4px solid var(--purple-shade);
    color: #fff;
    text-align: center;
    border-radius: 12px;
    font-weight: 900;
    font-size: 1rem;
}

.restart-menu p {
    font-size: 0.95rem;
    font-weight: 900;
    color: var(--ink);
    margin-bottom: 0;
}

/* Peak Stage label + checkpoint dropdown share one row instead of stacking —
   reclaims a full line of height so the buttons below never need a scroll. */
.peak-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.peak-row p { white-space: nowrap; flex: 0 0 auto; }

.restart-menu select {
    margin: 0;
    padding: 10px;
    font-size: 0.95rem;
    width: 100%;
    min-height: 44px;
    flex: 1;
    min-width: 0;
    border-radius: 14px;
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    outline: none;
    font-weight: 800;
    color: var(--ink);
    background: #fff;
}

.restart-actions {
    display: flex;
    gap: 10px;
}

.restart-actions .btn-primary,
.restart-actions .btn-secondary {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    padding-left: 10px;
    padding-right: 10px;
}

.btn-secondary {
    padding: 15px 24px;
    font-size: 1.1rem;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 900;
    min-height: 44px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #fff;
    background: var(--blue);
    border-bottom: 5px solid var(--blue-shade);
    transition: filter 0.15s ease, transform 0.05s ease, border-bottom-width 0.05s ease;
}

.btn-secondary:hover { filter: brightness(1.06); }
.btn-secondary:active { transform: translateY(3px); border-bottom-width: 2px; }

/* ---------------- Loading / error state ---------------- */

.load-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 26px 12px;
    font-weight: 800;
    color: var(--ink);
}

.load-error .btn-primary { margin-top: 14px; }

.load-error-reason {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--ink-soft);
    opacity: 0.8;
    margin-top: 6px;
}

/* ---------------- FX: confetti, praise, toast, vignette ---------------- */

#fx-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 60;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    left: 50%;
    top: 44%;
    animation: confettiPop 0.95s cubic-bezier(0.15, 0.85, 0.45, 1) forwards;
}

.praise {
    position: absolute;
    left: 50%;
    top: 40%;
    transform: translateX(-50%);
    font-size: 2.1rem;
    font-weight: 900;
    color: var(--green);
    text-shadow: 0 3px 0 rgba(70, 163, 2, 0.25);
    animation: praiseRise 0.85s ease-out forwards;
    white-space: nowrap;
}

#toast {
    position: fixed;
    top: -70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--blue);
    border-bottom: 4px solid var(--blue-shade);
    color: #fff;
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 1px;
    padding: 12px 26px;
    border-radius: 999px;
    z-index: 70;
    transition: top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    white-space: nowrap;
    max-width: 92vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

#toast.show { top: 16px; }

#danger-vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    box-shadow: inset 0 0 130px rgba(255, 75, 75, 0.55);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#danger-vignette.active {
    opacity: 1;
    animation: vignettePulse 0.7s ease-in-out infinite;
}

/* ---------------- Sound toggle (lives inside .top-header) ---------------- */

.btn-sound {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-bottom-width: 3px;
    background: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    transition: transform 0.05s ease;
}

.btn-sound:active { transform: translateY(2px); }

/* Build version marker — instant visual check of which deployment is loaded */
.build-tag {
    display: inline;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--ink-soft);
    opacity: 0.7;
    white-space: nowrap;
    user-select: none;
    margin-left: 4px;
}

/* ---------------- Keyframes ---------------- */

@keyframes popIn {
    0%   { opacity: 0; transform: scale(0.6); }
    100% { opacity: 1; transform: scale(1); }
}

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

@keyframes errorShake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes successGreen {
    0%   { background: var(--yellow-soft); }
    50%  { background: var(--green); border-color: var(--green-shade); color: #fff; transform: scale(1.08); }
    100% { background: var(--yellow-soft); transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.25); opacity: 0.85; }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

@keyframes statPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes confettiPop {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.6);
    }
}

@keyframes praiseRise {
    0%   { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.7); }
    25%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.12); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-46px) scale(1); }
}

@keyframes vignettePulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}

/* ============================================================
   RESPONSIVE — HeyPN 4-breakpoint standard (additive only)
   Desktop >900px = base styles above (never compromised)
   ============================================================ */

/* ---- Tablet: 601px – 900px ---- */
@media (max-width: 900px) {
    body { padding: 14px; padding-top: 70px; }
    .game-container { max-width: 560px; padding: 18px; }
    .puzzle-grid, .sub-grid { gap: 9px; }
    .brand-inline { font-size: 0.95rem; letter-spacing: 2px; }
    .grid-cell { font-size: 1.25rem; }
    .cell-wide { font-size: 0.95rem; }
}

/* ---- Mobile Large: 481px – 600px ---- */
@media (max-width: 600px) {
    body { padding: 12px; padding-top: 66px; }
    .game-container { padding: 16px; border-radius: 20px; }
    .game-header { gap: 6px; }
    .pill { padding: 8px 11px; font-size: 0.95rem; }
    .pill-pro { padding: 8px 10px; font-size: 0.8rem; letter-spacing: 1px; }
    .timer-container { font-size: 1.15rem; min-width: 78px; }
    .puzzle-grid, .sub-grid { gap: 8px; }
    .grid-cell { font-size: 1.2rem; border-radius: 14px; }
    .cell-wide { font-size: 0.9rem; padding: 10px 6px; }
    .grid-input { font-size: 1.3rem; }
    .condition-box { font-size: 1.05rem; letter-spacing: 2px; }
    /* Stack the single-answer prompt vertically for comfortable tapping */
    .single-answer-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .single-answer-input { flex: none; width: 100%; height: 56px; }
    .btn-mode { max-width: 100%; }
    .restart-menu { width: 96%; padding: 14px; }
    .overlay h2 { font-size: 1.8rem; margin-bottom: 8px; }
    .restart-actions .btn-primary,
    .restart-actions .btn-secondary { font-size: 0.9rem; padding: 13px 6px; letter-spacing: 0.5px; }
}

/* ---- Mobile Small: ≤480px ---- */
@media (max-width: 480px) {
    body { padding: 10px; padding-top: 60px; }
    .top-header { height: 48px; padding: 0 12px; }
    .brand-inline { font-size: 0.85rem; letter-spacing: 1.5px; }
    .game-container { padding: 12px; border-radius: 18px; }
    .game-header { gap: 5px; margin-bottom: 14px; }
    .pill { padding: 7px 9px; font-size: 0.85rem; border-bottom-width: 3px; }
    .pill-pro { font-size: 0.72rem; padding: 7px 8px; }
    .timer-container { font-size: 1.05rem; min-width: 70px; }
    .puzzle-grid, .sub-grid { gap: 6px; }
    .sub-grid { padding: 10px; }
    .grid-cell { font-size: 1.05rem; border-radius: 12px; border-bottom-width: 3px; }
    .cell-wide { font-size: 0.82rem; padding: 9px 5px; }
    /* Inputs never drop below 1rem — prevents iOS auto-zoom */
    .grid-input { font-size: 1.15rem; border-width: 2px; border-bottom-width: 4px; }
    .condition-box { font-size: 0.95rem; letter-spacing: 1.5px; padding: 9px 12px; }
    .btn-primary, .btn-lifeline { font-size: 1rem; padding: 14px 16px; letter-spacing: 1px; }
    .single-answer-label { font-size: 0.92rem; }
    .heartbeat-timer { font-size: 2.6rem; }
    .overlay { top: 48px; padding: 8px 10px 10px; }
    .overlay h2 { font-size: 1.5rem; margin-bottom: 6px; }
    .restart-menu { padding: 10px; max-height: calc(100vh - 66px); }
    .answer-reveal { padding: 8px; margin-bottom: 8px; }
    .restart-actions .btn-primary,
    .restart-actions .btn-secondary { font-size: 0.72rem; padding: 11px 3px; letter-spacing: 0.2px; }
    .reveal-puzzle { gap: 4px; margin-bottom: 8px; }
    .reveal-puzzle .grid-cell { font-size: 0.72rem; min-height: 24px; border-radius: 8px; }
    .reveal-puzzle .cell-wide { font-size: 0.58rem; padding: 4px 3px; }
    .btn-reveal { font-size: 0.82rem; padding: 10px; }
    #reveal-text { font-size: 0.85rem; }
    #logic-text { font-size: 0.75rem; line-height: 1.28; }
    .iq-badge { font-size: 0.9rem; padding: 7px; margin-bottom: 8px; }
    .restart-menu p { font-size: 0.85rem; }
    .peak-row { margin-bottom: 8px; }
    .restart-menu select { font-size: 0.82rem; padding: 8px 9px; min-height: 44px; }
    .mode-select .ms-title { font-size: 1.35rem; letter-spacing: 3px; }
    .btn-mode { font-size: 1.15rem; padding: 16px 18px; }
    .btn-mode span { font-size: 0.85rem; }
    .praise { font-size: 1.7rem; }
    #toast { font-size: 0.95rem; padding: 10px 18px; }
    .btn-sound { width: 34px; height: 34px; font-size: 0.95rem; }
}

/* ---------------- Reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   CONTENT PAGES (about / contact / privacy / terms / 404)
   ============================================================ */

.brand-link { text-decoration: none; }

.btn-play {
    flex-shrink: 0;
    display: inline-block;
    background: var(--green);
    border-bottom: 4px solid var(--green-shade);
    color: #fff;
    font-weight: 900;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 999px;
    transition: filter 0.15s ease, transform 0.05s ease, border-bottom-width 0.05s ease;
}

.btn-play:hover { filter: brightness(1.06); }
.btn-play:active { transform: translateY(2px); border-bottom-width: 2px; }

.page-wrap {
    width: 100%;
    max-width: 720px;
    background: var(--card);
    border: 2px solid var(--line);
    border-bottom-width: 6px;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(59, 59, 84, 0.08);
    padding: 28px;
    margin-bottom: 20px;
}

.page-wrap h1 {
    font-size: 1.7rem;
    font-weight: 900;
    margin-bottom: 14px;
    color: var(--ink);
}

.page-wrap h2 {
    font-size: 1.15rem;
    font-weight: 900;
    margin: 22px 0 8px;
    color: var(--blue);
}

.page-wrap p {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.6;
    color: var(--ink);
    margin-bottom: 12px;
}

.page-wrap ul {
    margin: 0 0 12px 22px;
}

.page-wrap li {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.6;
    margin-bottom: 6px;
}

.page-wrap a {
    color: var(--blue);
    font-weight: 800;
}

.page-updated {
    color: var(--ink-soft);
    font-size: 0.85rem;
}

/* Contact form embed */
.contact-embed {
    border: 2px dashed #c3ddf5;
    border-radius: 18px;
    overflow: hidden;
    background: #f4f9ff;
    margin: 14px 0 10px;
}

.contact-frame {
    display: block;
    width: 100%;
    height: 1150px;
    border: 0;
}

.contact-fallback {
    font-size: 0.88rem;
    color: var(--ink-soft);
}

/* 404 */
.error-page { text-align: center; }
.error-emoji { font-size: 3.4rem; margin-bottom: 10px; }
.btn-play-big { font-size: 1.05rem; padding: 14px 26px; margin-top: 8px; }

/* Site footer (shared across all pages incl. game) */
.site-footer {
    width: 100%;
    max-width: 720px;
    text-align: center;
    padding: 10px 0 18px;
}

.site-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
    margin-bottom: 8px;
}

.site-footer a {
    color: var(--ink);
    font-weight: 800;
    font-size: 0.9rem;
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.site-footer a:hover { color: var(--blue); border-bottom-color: var(--blue); }

.site-footer p {
    color: var(--ink-soft);
    font-weight: 800;
    font-size: 0.78rem;
}

/* Content pages — responsive (HeyPN 4-breakpoint standard, additive) */
@media (max-width: 900px) {
    .page-wrap { max-width: 640px; padding: 24px; }
}

@media (max-width: 600px) {
    .page-wrap { padding: 18px; border-radius: 20px; }
    .page-wrap h1 { font-size: 1.45rem; }
    .page-wrap h2 { font-size: 1.05rem; }
    .contact-frame { height: 1250px; }
}

@media (max-width: 480px) {
    .page-wrap { padding: 14px; border-radius: 18px; }
    .page-wrap h1 { font-size: 1.25rem; }
    .page-wrap p, .page-wrap li { font-size: 0.92rem; }
    .btn-play { font-size: 0.75rem; padding: 7px 11px; }
    .error-emoji { font-size: 2.6rem; }
}

/* ============================================================
   HOMEPAGE CONTENT + FAQ (Phase 3)
   ============================================================ */

.home-content {
    margin-top: 22px;
    max-width: 600px; /* match the game card width for a clean column */
}

.faq-item {
    border: 2px solid var(--line);
    border-bottom-width: 4px;
    border-radius: 14px;
    margin-bottom: 10px;
    background: #fff;
    overflow: hidden;
}

.faq-item summary {
    cursor: pointer;
    font-weight: 900;
    font-size: 0.95rem;
    color: var(--ink);
    padding: 12px 14px;
    list-style: none;
    position: relative;
    padding-right: 34px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 14px;
    font-size: 1.2rem;
    color: var(--blue);
    font-weight: 900;
}

.faq-item[open] summary::after { content: '−'; }

.faq-item[open] summary { color: var(--blue); }

.faq-item p {
    padding: 0 14px 12px;
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .home-content { margin-top: 16px; }
    .faq-item summary { font-size: 0.88rem; }
}

/* ============================================================
   HEADER SUBMENU (V3-1)
   ============================================================ */

.btn-menu {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-bottom-width: 3px;
    background: #fff;
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--ink);
    cursor: pointer;
    transition: transform 0.05s ease;
}

.btn-menu:active { transform: translateY(2px); }

.hdr-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hdr-right .btn-menu { margin-left: 0; }

.menu-panel {
    position: fixed;
    top: 60px;
    right: 10px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    min-width: 210px;
    background: #fff;
    border: 2px solid var(--line);
    border-bottom-width: 5px;
    border-radius: 16px;
    box-shadow: 0 14px 34px rgba(59, 59, 84, 0.18);
    overflow: hidden;
    animation: popIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.menu-panel a {
    padding: 13px 18px;
    font-weight: 900;
    font-size: 0.95rem;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 2px solid var(--line);
    min-height: 44px;
    display: flex;
    align-items: center;
}

.menu-panel a:last-child { border-bottom: none; }

.menu-panel a:hover, .menu-panel a:active {
    background: #f0f9ff;
    color: var(--blue);
}

/* FAQ anchor lands clear of the fixed header */
#faq { scroll-margin-top: 72px; }

/* Footer HeyPN brand link */
.site-footer p a {
    color: var(--ink-soft);
    font-weight: 900;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-footer p a:hover { color: var(--blue); }

@media (max-width: 480px) {
    .btn-menu { width: 34px; height: 34px; font-size: 0.95rem; }
    .menu-panel { top: 52px; right: 8px; min-width: 190px; }
    .menu-panel a { font-size: 0.88rem; padding: 12px 16px; }
    #faq { scroll-margin-top: 60px; }
}
