/* 本页专用样式，配色变量与背景渐变来自 /css/theme.css（全站唯一一份，在本条之前引用）
   布局沿用原结构：提示词在数字上方、两个按钮并排居底；顶部导航与页脚仍由 css/site.css 管 */

/* 标题行：仍保留 flex 容器，h1 作为 flex item 下外边距不会塌陷穿出去，标题与正文的间距和之前一致
   上间距 39px = 原来的 6px + 面包屑删除后让出的 21px 高和 12px 下边距，标题的纵向位置不变 */
.title-row {
    display: flex;
    align-items: center;
    max-width: 760px;
    margin: 39px 0 0;
}

.title-row h1 {
    font-size: clamp(30px, 6vw, 46px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.5px;
}

/* 数字 24 用琥珀强调（index.html 里是 <h1><span>24</span> Game</h1>，未加 class） */
.title-row h1 span {
    color: var(--amber-text);
}

/* 文字仍收到 760px 这一列靠左（排版样式不变）；游戏卡片单独占满左栏，见下面 .game-area，
   How to Play / Tips / Who's It For / FAQ 已包进 .card，段落、列表的间距和缩进见下面「正文卡片」 */
.main-col > p {
    max-width: 760px;
    margin: 8px 0;
    color: var(--ink-soft);
}

/* 示例算式：淡紫小牌 + 深紫字（参考稿的 code 就是浅底深字；原来的 --tile/--ink 在白卡上是一块深色） */
code {
    padding: 2px 9px;
    background: #EFE9FD;
    border: 1px solid #E1D8F8;
    border-radius: 8px;
    color: #2a1f5c;
}

/* 算式里的分数：分子在上、分母在下，中间一条横线 */
.fraction {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    text-align: center;
    line-height: 1.1;
    font-size: 0.85em;
    margin: 0 2px;
}

.fraction span:first-child {
    border-bottom: 1.5px solid currentColor;
    padding: 0 3px 2px;
}

.fraction span:last-child {
    padding: 2px 3px 0;
}

/* ==================== 正文卡片 ==================== */
/* 参考稿：四段都是通栏白底、直角、无边框，段与段之间只留 12px 淡紫缝（透出 body::before 的渐变），
   卡片自身只带一层很轻的下投影，缝上缘最深、往下渐淡，就是参考图那条分隔的效果。
   左侧 80px 是图标列：图标绝对定位在列里，不进正文流，正文左缘因此和标题文字对齐。
   卡片内文字全部改用深色：底是接近纯白的浅紫白，原来的 --ink / --ink-soft 是深色模式的浅色字，在这种底上读不清，
   取 theme.css 浅色模式的同一组色值（#2a1f5c 标题、#5d5488 正文），两种配色方案下都够用 */
/* 卡片之间的 12px 由 grid gap 给；游戏面板到第一段原来靠 .main-col > h2 的 30px 上边距隔开，
   现在 h2 进了卡片、外边距被卡片的 padding 吃掉，这里补一条上边距，避免白块和游戏面板贴在一起 */
.content {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.card {
    position: relative;
    background: #FDFCFE;
    padding: 20px 24px 20px 80px;
    box-shadow: 0 4px 12px rgba(90, 60, 200, 0.1);
}

.card[hidden] {
    display: none;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 24px;
    color: #2a1f5c;
}

/* 标题左侧图标：四张卡片统一 48px 浅色圆底 + 24px 图标，只换圆底色和图标色；
   top:13px 让圆心落在标题这一行的视觉中线（20px 上内边距 + 24px 字号的大写中线） */
.card h2 .h-icon {
    position: absolute;
    left: 14px;
    top: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
}

.card h2 .h-icon svg {
    width: 24px;
    height: 24px;
}

.h-icon-blue {
    background: #E4EDFF;
    color: #2563EB;
}

/* How to Play：游戏手柄 */
.h-icon-green {
    background: #DDF5E7;
    color: #15803D;
}

/* Tips：灯泡 */
.h-icon-purple {
    background: #EDE4FE;
    color: #6D3BD1;
}

/* Who's It For：毕业帽 */
.h-icon-orange {
    background: #FFEBD8;
    color: #C2410C;
}

/* FAQ：问号 */
.card > p {
    max-width: 760px;
    margin: 8px 0;
    color: #5d5488;
}

/* 强调文字（FAQ 的问题、列表项的引导词）用标题色，正文保持副文案色 */
.card strong {
    color: #2a1f5c;
}

/* global.css 的 * { padding: 0 } 会把列表缩进清掉，序号和圆点也就看不见了，这里补回来；
   16px = 参考图的效果：序号/圆点几乎贴着标题左缘，文字缩进一档，折行仍和文字对齐 */
.card > ol,
.card > ul {
    max-width: 760px;
    margin: 8px 0;
    padding-left: 16px;
    color: #5d5488;
}

.card > ol > li,
.card > ul > li {
    margin: 5px 0;
}

@media (max-width: 640px) {
    .card {
        padding: 18px 18px 18px 64px;
    }

    .card h2 {
        font-size: 20px;
    }

    /* 窄屏图标列一起收窄，四张卡片仍保持一致 */
    .card h2 .h-icon {
        left: 12px;
        top: 12px;
        width: 40px;
        height: 40px;
    }

    .card h2 .h-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* ==================== 游戏主卡片 ==================== */
/* 琥珀混进卡片底色做渐变和描边，圆角 22px，与首页 .card 同一做法；宽度占满左栏（.main-col 不给宽度限制），
   和右侧栏之间只剩 .page-layout 的 32px 间距，不留大块空白 */
.game-area {
    margin: 26px 0 0;
    padding: clamp(18px, 4vw, 30px);
    border: 1px solid color-mix(in srgb, var(--amber) 35%, var(--line));
    border-radius: 22px;
    background: linear-gradient(160deg, color-mix(in srgb, var(--amber) 20%, var(--card)), var(--card) 65%);
    box-shadow: 0 18px 36px var(--shadow);
    /* 提示区绝对定位的参照物（.hint-panel 是卡片最后一个子元素），与 games/24-game-kids 同做法 */
    position: relative;
}

/* 结果行的宽度由 script.js 的 syncResultWidth() 跟输入框对齐（与 kid 版同一做法），
   所以这里不写 max-width：改输入框长度时结果行会自己跟上，它的 text-align:center 仍落在输入框正中 */
.game-area .result {
    text-align: center;
    font-size: 18px;
    min-height: 30px;
    margin: 0 0 8px;
    color: var(--ink-soft);
}

/* 按钮贴左，和数字/输入框走同一条左边缘（提示区占了右边那条横带，见下面 .hint-panel）。
   align-items: center 是两条按钮等高的关键：flex 默认 stretch，#submit-btn 的 margin:0 让它吃满整行、
   比留着上下 5px 外边距的 New Game 高 10px；改成居中后两条都回到自己的内容高，行高不变 */
.btn-row {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: flex-start;
    margin-top: 6px;
}

/* 答对/答错：沿用 script.js 写入的 .correct / .wrong，只换颜色 */
.game-area .result.correct {
    color: var(--teal);
}

.game-area .result.wrong {
    color: #ef4444;
}

@media (prefers-color-scheme: light) {
    /* 浅色的 #0fb59b 在白卡上偏淡，压暗一点；错误红保持 #ef4444 */
    .game-area .result.correct {
        color: #0a917c;
    }
}

/* ==================== 四张数字牌 ==================== */
/* 与 kid 版一致：数字块外层包 play-row（flex），避免 margin 折叠，使数字与输入框的纵向位置和 kid 版对齐；
   整行贴左，右半部分留给提示卡（.hint-panel） */
.play-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

/* flex: 1 1 auto 让 number-display 撑满 play-row，否则里面的牌 flex-basis:0 会把整行压扁 */
.number-display {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: clamp(8px, 2.2vw, 16px);
    margin: 14px 0;
}

/* flex: 1 1 0 + max-width：宽屏定宽 94px，窄屏自动等比缩放，四张牌始终占一行不换行 */
.number-item {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    max-width: 94px;
    width: auto;
    height: auto;
    aspect-ratio: 5 / 4;
    background: var(--tile);
    border: 2px solid color-mix(in srgb, var(--amber) 48%, transparent);
    border-radius: 14px;
    color: var(--ink);
    font-size: clamp(28px, 7vw, 44px);
    font-weight: 800;
    box-shadow: 0 6px 16px var(--shadow);
    /* 出新题时 script.js 会重建这四个节点，动画随之重播，无需 JS 配合 */
    animation: tile-pop .32s ease-out backwards;
    transition: transform .12s ease, border-color .18s ease;
}

.number-item:active {
    transform: scale(.94);
}

.number-item:nth-child(2) {
    animation-delay: .04s;
}

.number-item:nth-child(3) {
    animation-delay: .08s;
}

.number-item:nth-child(4) {
    animation-delay: .12s;
}

@keyframes tile-pop {
    0% {
        transform: translateY(8px) scale(.82);
        opacity: 0;
    }
    60% {
        transform: translateY(0) scale(1.06);
        opacity: 1;
    }
    100% {
        transform: none;
    }
}

/* ==================== 输入框 ==================== */
/* 包一层只为给右端的 × 做定位参照：× 跟着输入框右端走，改输入框长度不会把它甩掉。
   输入框的长度就是下面这一条 max-width（css/global.css 的 .game-area 有 text-align:center，
   所以外层用 block + margin 贴左，整块游戏内容走同一条左边缘，右边空出的横带给提示卡） */
.input-wrap {
    display: block;
    width: 100%;
    max-width: 423.5px;
    margin: 8px 0;
    position: relative;
}

.answer-input {
    display: block;
    width: 100%;
    /* css/global.css:117 的 max-width:400px 和 :124 的 margin:20px 0 会漏进这条同名规则里：
       宽度和上下间距现在都归外层 .input-wrap 管，这里收回，否则 × 会跑到输入框外面 */
    max-width: 100%;
    margin: 0;
    padding: 13px 22px;
    background: var(--tile);
    border: 2px solid color-mix(in srgb, var(--amber) 26%, var(--line));
    border-radius: 999px;
    color: var(--ink);
    text-align: center;
    font-size: 18px;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.answer-input:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 28%, transparent);
}

.answer-input::placeholder {
    color: color-mix(in srgb, var(--ink-soft) 70%, transparent);
}

/* 输入框右端的一键清除按钮：与 games/24-game-kids 同款（尺寸、配色、圆底、hover 全部一致）。
   绝对定位在 .input-wrap 内，不参与输入框宽度，所以没有内容时也不会挤动输入框 */
.expr-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: color-mix(in srgb, var(--danger) 18%, var(--tile));
    color: var(--danger);
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.expr-clear:hover {
    background: var(--danger);
    color: var(--on-accent);
}

/* 上面 display:inline-flex 会盖住 hidden 属性的默认 display:none，所以空态和答对后靠这一条收掉 */
.expr-clear[hidden] {
    display: none;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 5px 37px;
    gap: 6px;
    padding: 12px 24px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: filter .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}

/* 主按钮：琥珀底 + 深色字（Submit Answer） */
#submit-btn {
    margin: 0;
    color: var(--on-accent);
    background: linear-gradient(135deg, var(--amber), color-mix(in srgb, var(--amber) 60%, var(--pink)));
    box-shadow: 0 10px 24px color-mix(in srgb, var(--amber) 28%, transparent);
}

#submit-btn:hover {
    filter: brightness(1.07);
}

/* 描边胶囊：透明底 + 琥珀描边（New Game） */
#newgame-btn {
    color: var(--amber-text);
    background: transparent;
    border-color: color-mix(in srgb, var(--amber) 60%, transparent);
}

#newgame-btn:hover {
    color: var(--ink);
    background: color-mix(in srgb, var(--amber) 14%, transparent);
}

/* 答对后：提交按钮置灰不可点，New Game 变成琥珀色高亮胶囊提示回车开新局
   选择器要带上 #newgame-btn，否则上面 #newgame-btn 的 background: transparent 优先级更高，底色盖不掉 */
.btn-row .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#newgame-btn.btn-solved {
    color: var(--amber-text);
    background: color-mix(in srgb, var(--amber) 20%, transparent);
    border-color: var(--amber);
    font-weight: 800;
}

/* ==================== 自动提示卡（与 games/24-game-kids 同款） ==================== */
/* 提示区：卡片内部右侧那条空横带（数字牌、输入框、按钮全部贴左，1200 版心下卡片内容框 758，
   输入框右端 460，右边空出 298px），30 秒无操作后逐条显示答案步骤。
   默认 hidden → display:none：绝对定位不参与布局，没有提示时卡片高度不变、右侧看不到任何痕迹；
   第一条提示出现时 script.js 去掉 hidden，下面整条规则生效，背景和圆角同步出现。
   top:44 = 卡片 padding-top 30 + 数字行 margin-top 14，面板上沿与数字牌上沿同一条线；
   width 170 + right:30 → 面板左边缘落在内容框 588 处，和输入框右端 460 之间还剩约 128px。
   ≤1120px 卡片内容框窄到放不下这条横带（间隙 < 40px），退回卡片底部的整行块，不挤压输入框。
   底色写死浅黄 #FFF8E1，配深色文字，深浅两套配色下都是同一块浅黄提示，不跟随 --ink 变白。 */
.hint-panel {
    display: none;
}

.hint-panel:not([hidden]) {
    display: block;
    box-sizing: border-box;
    position: absolute;
    top: 44px;
    right: 30px;
    width: 170px;
    padding: 16px;
    border: 1px solid #E3D3A6;
    border-radius: 12px;
    background: #FFF8E1;
    font-size: 17px;
    line-height: 1.6;
    text-align: left;
    animation: hintIn 0.35s ease;
}

/* 窄屏退回：取消绝对定位，跟在 result 之后占满卡片内宽 */
@media (max-width: 1120px) {
    .hint-panel:not([hidden]) {
        position: static;
        width: 100%;
    }
}

.hint-panel .hint-title {
    /* 各页只加载 Inter 400/600 两个字重，加粗取 600，写成 700 只会拿到浏览器合成的假粗 */
    font-weight: 600;
    color: #7A4A00;
    margin: 6px 0 2px;
}

.hint-panel .hint-title:first-child {
    margin-top: 0;
}

.hint-panel .hint-step {
    padding-left: 2ch;
    color: #2A2058;
}

/* 每追加一步只淡入最新一行：renderHint 每次都重建内部节点，:last-child 命中的正好是新加的那行 */
.hint-panel .hint-step:last-child {
    animation: hintIn 0.3s ease;
}

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

/* 提示步骤对应数字牌的高亮闪烁：只叠加光圈，不改原有颜色；
 * 每次脉冲 1.5s、共 3 次 = 4.5s，让人来得及看清。本页没有符号按钮，所以只有数字牌的两种光圈 */
.hint-flash-a,
.hint-flash-b {
    animation: hintFlash 1.5s ease-in-out 3;
}

.hint-flash-a {
    --hint-glow: color-mix(in srgb, var(--danger) 60%, transparent);
    --hint-border: var(--danger);
}

.hint-flash-b {
    --hint-glow: color-mix(in srgb, var(--amber) 60%, transparent);
    --hint-border: var(--amber);
}

@keyframes hintFlash {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    }
    50% {
        box-shadow: 0 0 0 5px var(--hint-glow);
        border-color: var(--hint-border);
    }
}

/* ==================== 手机端 ==================== */
@media (max-width: 480px) {
    /* 四张牌保持一行：靠 flex 等比缩小，不换行 */
    .number-display {
        gap: 8px;
        margin: 12px 0;
    }

    .answer-input {
        font-size: 16px;
        padding: 12px 18px;
    }

    /* 按钮上下排列并撑满宽度 */
    .btn-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .btn-row .btn {
        width: 100%;
        margin: 0;
    }
}

/* 减少动效：只关弹出动画和过渡，牌和配色不变 */
@media (prefers-reduced-motion: reduce) {
    .number-item,
    .btn,
    .answer-input {
        animation: none !important;
        transition: none !important;
    }
}
