:root {
    color-scheme: dark;
    --bg: #0d0c0a;
    --surface: #1a1814;
    --text: #f7f3e9;
    --muted: rgba(247, 243, 233, 0.62);
    --accent: #e8b84b;
    --accent-2: #b8863b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 20px 64px;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.65 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    -webkit-text-size-adjust: 100%;
}

main { max-width: 720px; margin: 0 auto; }

h1 {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 56px 0 8px;
    background: linear-gradient(100deg, #f3d07a, #b8863b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

h2 {
    font-size: 21px;
    font-weight: 700;
    margin: 40px 0 8px;
    color: var(--text);
}

h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 28px 0 6px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

p { margin: 0 0 16px; color: var(--muted); }
strong { color: var(--text); }
code {
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.9em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul { margin: 0 0 16px; padding-left: 22px; color: var(--muted); }
li { margin: 0 0 8px; }

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 24px;
    font-size: 14px;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    vertical-align: top;
}

th { color: var(--text); font-weight: 650; }
td { color: var(--muted); }

footer {
    max-width: 720px;
    margin: 48px auto 0;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

footer p { font-size: 12px; color: rgba(247, 243, 233, 0.38); }

/* The landing page */
.landing { padding-top: 48px; }
.landing .tagline { font-size: 18px; line-height: 1.55; margin-bottom: 28px; }

.cta {
    display: block;
    text-align: center;
    padding: 16px 24px;
    border-radius: 16px;
    background: linear-gradient(100deg, #f3d07a, #b8863b);
    color: #0d0c0a;
    font-weight: 800;
    letter-spacing: 0.01em;
    margin-bottom: 44px;
}
.cta:hover { text-decoration: none; }

/* 商店按钮下方的小字说明。上边距用负值把 .cta 的 44px 下边距收回来，
   否则按钮和说明之间会隔出一大片空白。 */
.cta-note {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(247, 243, 233, 0.5);
    text-align: center;
    margin: -32px 0 40px;
}

/* ⚠️ 必须显式盖掉 .cta 的 display:block —— 否则 [hidden] 会被它覆盖，
   按钮在「链接缺参数」时依然会显示出来。 */
.cta[hidden] { display: none; }

.landing ul.cards { list-style: none; padding: 0; margin: 0 0 36px; }
.landing ul.cards li {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.landing ul.cards strong { display: block; font-size: 16px; }
.landing ul.cards span { font-size: 14px; color: rgba(247, 243, 233, 0.6); }

.landing ul.plain li { margin-bottom: 8px; }

.landing .legal { font-size: 13px; margin-top: 40px; }

/* ============================================================
   分享落地页的棋盘
   ============================================================
   ⚠️ 这块样式必须和 App 内 `Crowned/Theme/Theme.swift` + `PuzzleBoardView.swift`
      的视觉规则一致，网页上显示的盘面要像 App 里那一张：
      · 格子间距 2px（App 的 Metrics.cellSpacing）
      · 区域之间的边界 3px 白线，同区域内部 0.5px 淡线（App 的 regionBorder）
      · 外框 3px 白线，圆角 18px（App 的 cornerRadius + 6）
   边界用 inset box-shadow 画在格子的内侧，每条内部边界只画一次，
   否则相邻两格各画一条会叠成 6px，比 App 里粗一倍。 */
.board {
    display: grid;
    gap: 2px;
    width: min(90vw, 420px);
    margin: 0 auto 18px;
    padding: 0;
    /* 棋盘底色 = App 内 ThemeColor.surface，让缝隙和外框和 App 里完全一致 */
    background: #21242E;
    border: 3px solid rgba(255, 255, 255, 0.85);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.board .cell {
    aspect-ratio: 1 / 1;
    border-radius: 2px;
}

.board[hidden] { display: none; }

.board-note {
    text-align: center;
    font-size: 13px;
    color: rgba(247, 243, 233, 0.5);
    margin: 0 0 8px;
}

.board-note[hidden] { display: none; }


/* ============================================================
   可玩的分享页棋盘（网页端直接玩同题）
   ============================================================
   ⚠️ 这块的视觉规则必须和 App 内 `Crowned/Views/Gameplay/PuzzleBoardView.swift`
      对齐，网页上看到的盘面要和 App 里那一张一模一样：
      · 叉号线宽 = max(1.6px, 格子边长 × 0.075)，App 里是 `max(1.6, size * 0.075)`
      · 叉号长度 = 格子边长 × 0.36
      · 皇冠字号 = 格子边长 × 0.52，App 里是 `.font(.system(size: size * 0.52, weight: .bold))`
      · 玩家手动标的 × 不透明度 0.8；自动 × 不透明度 0.42
      · 冲突格盖红色斜纹
   格子边长由 JS 写进 `--cw`（board 宽 ÷ N），所以棋盘缩放时这些值跟着缩放。 */

.board {
    touch-action: none;          /* 拖拽连涂时不要顺带滚页面 */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.board .cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 皇冠 / 叉号默认不显示，由格子上的状态类控制 */
.board .mark {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    line-height: 1;
}

.board .cell.is-cross .mark-x { display: flex; }
.board .cell.is-crown .mark-crown { display: flex; }

/* 叉号：用两条带圆头的线交叉，和 App 的 CrossMark 形状一致 */
.board .mark-x i {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(var(--cw, 40px) * 0.36);
    height: 0;
    margin-left: calc(var(--cw, 40px) * -0.18);
    border-top: max(1.6px, calc(var(--cw, 40px) * 0.075)) solid var(--text);
    border-radius: 2px;
    opacity: 0.8;
}
.board .mark-x i:nth-child(1) { transform: rotate(45deg); }
.board .mark-x i:nth-child(2) { transform: rotate(-45deg); }
/* 自动 × 更淡 —— App 里 `opacity(cell.isAutoCrossed ? 0.42 : 0.8)` */
.board .cell.is-auto .mark-x i { opacity: 0.42; }

/* 皇冠 */
.board .mark-crown {
    font-size: calc(var(--cw, 40px) * 0.52);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* 冲突：红色斜纹盖在格子上 */
.board .cell.is-conflict::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(220, 60, 60, 0.45) 0 4px,
        rgba(220, 60, 60, 0.12) 4px 8px
    );
    pointer-events: none;
}

/* ============================================================
   棋盘下方的计时器与操作条
   ============================================================ */
.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: min(90vw, 420px);
    margin: 0 auto 10px;
}

.hud-time {
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
}

.hud-actions { display: flex; gap: 8px; }

.hud-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 14px;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.hud-btn:disabled { opacity: 0.35; cursor: default; }
.hud-btn:not(:disabled):hover { background: rgba(255, 255, 255, 0.12); }

.board-status {
    width: min(90vw, 420px);
    margin: 0 auto 10px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    min-height: 1.4em;
}
.board-status[hidden] { display: none; }

/* 通关后的分享按钮 */
.cta-button {
    appearance: none;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.cta-button:hover { background: rgba(255, 255, 255, 0.14); }

/* 复制被浏览器拦下时，摊开战报让用户手动选中复制 */
#share-fallback {
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
}
#share-fallback-wrap small { color: var(--muted); }

/* 落地页的两个 CTA（主 + 次） */
.cta-stack { margin-bottom: 20px; }
.cta-stack .cta { margin-bottom: 12px; }
.cta-stack .cta:last-child { margin-bottom: 0; }

/* 次要 CTA：视觉上不能和主 CTA 抢 */
.cta-secondary {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text);
    font-weight: 700;
}
.cta-secondary:hover { background: rgba(255, 255, 255, 0.12); }

/* .cta 的 44px 下边距被 .cta-stack 收掉了，说明文字往上贴一点 */
.landing .cta-note { margin: -8px 0 40px; }
