/* 折立方 · 样式
 * 陶瓷与暖纸色板；图案形状与判定状态颜色含义不变。
 * 一屏放下、不滚动：#app 高 = --app-h（layout.js 按 innerHeight 写），各栏用 flex 分配，格子尺寸由 app.js 按栏的实际大小算。
 * 竖屏：顶栏 / 立方体栏 / 展开图栏上下排；横屏（html.land）：顶栏下左右两栏。640×360 是最小可玩档。
 */
:root {
  --bg: #eeeae0;
  --ink: #263c37;
  --ink-2: #f6f2e8;
  --paper: #263c37;
  --paper-2: #59665c;
  --paper-3: #8a8b79;
  --gold: #a4533b;
  --line: #d2cbbc;
  --muted: #72776c;
  --ok: #00866a;
  --half: #f2c14e;
  --bad: #626c7b;
  --r: 10px;
  --app-h: 100vh;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  --serif: Georgia, "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { touch-action: manipulation; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--paper);
  font-family: var(--sans); font-size: 15px; line-height: 1.4;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }

#app { position: relative; width: 100%; height: var(--app-h); overflow: hidden;
  background: var(--bg); }

.screen { position: absolute; inset: 0; display: none; flex-direction: column;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0); }
.screen.on { display: flex; }

/* ---------- 按钮 ---------- */
.btn { border: 1.5px solid var(--gold); background: transparent; color: var(--paper);
  padding: 10px 22px; border-radius: 999px; font-weight: 600; letter-spacing: .02em; min-height: 44px;
  transition: transform .1s, background .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); color: var(--ink); }
.btn.primary:disabled { opacity: .35; }
.btn.ghost { border-color: var(--line); color: var(--paper-2); }
.btn.big { min-width: 200px; font-size: 17px; }
.btn .num { opacity: .7; font-weight: 500; margin-left: 4px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--paper-2);
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; padding: 0; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }
.text-btn { border: 1px solid var(--line); background: transparent; color: var(--paper-2); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; min-height: 32px; }
/* 悬停效果只给有鼠标的设备：iOS 上带 :hover 的元素第一下点击会被当成悬停，要点两下 */
@media (hover: hover) {
  .btn:hover { filter: brightness(1.08); }
  .icon-btn:hover { background: rgba(255, 255, 255, .06); }
  .cell:not(.filled):hover .skin { background: rgba(232,221,198,.2); }
  .pk-item:hover .skin { box-shadow: 0 0 0 2px var(--gold); }
}

.corner-bar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 8px 10px 0; flex: none; }
#result .corner-bar { justify-content: space-between; }

/* ---------- 首页 ---------- */
.home-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 0 16px 16px; min-height: 0; }
.logo-stage { width: min(46vw, 30vh, 220px); height: min(46vw, 30vh, 220px); flex: none; }
.home-text { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
h1 { font-family: var(--serif); font-size: clamp(30px, 6vh, 46px); margin: 0; letter-spacing: .01em; color: var(--paper); }
.tagline { margin: 0 0 6px; color: var(--paper-2); max-width: 22em; }
.home-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 4px; }
.home-streak { min-height: 1.4em; font-weight: 600; margin-top: 4px; }
.home-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
html.land .home-main { flex-direction: row; gap: 5vw; }
html.land .logo-stage { width: min(34vh, 30vw, 260px); height: min(34vh, 30vw, 260px); }
html.land .home-text { align-items: flex-start; text-align: left; }
html.land .home-actions { align-items: flex-start; }

/* 页脚：一行小字 Privacy（阿金 09-29 答复第 2 条） */
.home-foot { flex: none; text-align: center; padding: 0 0 8px; font-size: 12px; }
.home-foot a { color: var(--muted); text-decoration: none; }
.home-foot a:active { color: var(--paper-2); }
@media (hover: hover) { .home-foot a:hover { color: var(--paper-2); text-decoration: underline; } }
html.land .home-foot { position: absolute; right: 14px; bottom: 6px; padding: 0; }

/* 隐私说明页（privacy.html）：正常滚动的文章页 */
body.doc-page { overflow: auto; height: 100%; -webkit-user-select: text; user-select: text; }
.doc { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; line-height: 1.6; }
.doc h1 { margin: 8px 0 12px; font-size: 30px; }
.doc p { color: var(--paper-2); margin: 0 0 14px; }
.doc-back { margin-left: -8px; }

/* ---------- 3D ---------- */
.stage { position: relative; display: flex; align-items: center; justify-content: center; }
.cube3d, .fold-root { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.face, .fold-face { position: absolute; transform-style: preserve-3d; }
.skin { position: absolute; inset: 0; background: var(--paper); border-radius: 6%;
  box-shadow: inset 0 0 0 2px var(--paper-3); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face .skin, .fold-face .skin { border-radius: 3%; box-shadow: inset 0 0 0 2px var(--paper-3), inset 0 0 0 4px rgba(217,180,90,.35); }
.fold-face .back { position: absolute; inset: 0; background: var(--paper-3); border-radius: 3%; transform: rotateY(180deg);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: inset 0 0 0 2px #9a8966; }
.skin.empty { background: rgba(232, 221, 198, .12); box-shadow: inset 0 0 0 2px rgba(232,221,198,.35); }
.skin .pat { position: absolute; left: 10%; top: 10%; width: 80%; height: 80%; transition: transform .18s ease-out; }
.draggable { cursor: grab; touch-action: none; }
.draggable:active { cursor: grabbing; }

/* ---------- 做题画面 ---------- */
.bar { flex: none; height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; gap: 8px; }
.bar-mid { display: flex; align-items: center; gap: 14px; }
.mode-tag { color: var(--muted); font-size: 13px; font-weight: 600; }
.qdots, .tries { display: flex; gap: 6px; align-items: center; }
.qdot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--paper-2); opacity: .6; }
.qdot.cur { opacity: 1; background: var(--paper); border-color: var(--paper); transform: scale(1.15); }
.qdot.ok { opacity: 1; background: var(--ok); border-color: var(--ok); }
.qdot.bad { opacity: 1; background: #5b6474; border-color: #5b6474; }
.pip { width: 7px; height: 14px; border-radius: 3px; background: rgba(232,221,198,.18); }
.pip.on { background: var(--gold); }
.timer { font-variant-numeric: tabular-nums; color: var(--paper-2); min-width: 48px; text-align: right; padding-right: 6px; font-size: 15px; }

.play { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px; }
.panel { position: relative; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,.025); min-height: 0; min-width: 0; }
.cube-panel { flex: 0 0 36%; display: flex; }
.net-panel { flex: 1; display: flex; flex-direction: column; padding: 8px; transition: box-shadow .3s; }
.net-panel.won { box-shadow: 0 0 0 2px var(--ok) inset; }
html.land .play { flex-direction: row; max-width: 1400px; width: 100%; margin: 0 auto; }
html.land .cube-panel { flex: 0 0 40%; }
.corner { position: absolute; right: 4px; bottom: 4px; }

.cubes { flex: 1; display: flex; min-width: 0; min-height: 0; }
.cubes.col { flex-direction: column; }
.cubes > .stage { flex: 1; min-width: 0; min-height: 0; }
/* 第 3 题两张视角之间的细分隔线，免得看成一个连续画面 */
.cubes.row > .stage + .stage { border-left: 1px solid var(--line); }
.cubes.col > .stage + .stage { border-top: 1px solid var(--line); }
.view-b { position: absolute; left: 8px; top: 6px; display: flex; align-items: center; gap: 3px; color: var(--paper-2);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; pointer-events: none; }
.view-b svg { width: 22px; height: 22px; }

.net-area { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.net-area.folding > .stage { position: absolute; inset: 0; }
.net { position: relative; flex: none; }
.cell { position: absolute; padding: 0; border: 0; background: transparent; }
.cell .skin { inset: 2px; }
.cell .plus { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: rgba(232,221,198,.45); font-size: 26px; font-weight: 300; pointer-events: none; }
.cell.sel .skin { box-shadow: 0 0 0 3px var(--gold); }
.rot-hint { position: absolute; right: 5px; top: 5px; width: 16px; height: 16px; color: var(--paper-3); pointer-events: none; }
.rot-hint svg { width: 100%; height: 100%; display: block; }
.badge { position: absolute; left: 5px; top: 5px; width: 20px; height: 20px; border-radius: 5px; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 1px 2px #263c3740; }
.net.answer .cell { cursor: default; }

.mk, .badge { display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font: 700 13px/1 var(--sans); }
.mk.m1, .badge.m1 { color: #49360a; }
.m2 { background: var(--ok); }
.m1 { background: var(--half); }
.m0 { background: var(--bad); box-shadow: inset 0 0 0 1px rgba(232,221,198,.35); }


.marks-row { flex: none; display: flex; justify-content: center; gap: 5px; min-height: 0; }
.marks-row:not(:empty) { padding: 6px 0 2px; }
.marks-row .mk { width: 18px; height: 18px; border-radius: 4px; }
.net-actions { flex: none; display: flex; justify-content: center; padding-top: 8px; min-height: 52px; }
.net-actions .btn { min-width: 160px; }

/* ---------- 选图面板 ---------- */
.picker { position: absolute; z-index: 20; display: none; padding: 8px; border-radius: 12px; background: var(--ink-2);
  border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.picker.on { display: block; }
.pk-grid { display: grid; grid-template-columns: repeat(3, 52px); gap: 6px; }
.pk-item { position: relative; width: 52px; height: 52px; padding: 0; border: 0; background: transparent; border-radius: 8px; }
.pk-item .skin { inset: 0; }
.pk-item.used { opacity: .35; }
.pk-item.cur .skin { box-shadow: 0 0 0 2px var(--gold); }
.pk-rot { display: flex; align-items: center; justify-content: center; width: 100%; height: 40px; margin-top: 6px; padding: 0;
  border: 1.5px solid var(--gold); border-radius: 8px; background: transparent; color: var(--gold); }
.pk-rot svg { width: 22px; height: 22px; }
.pk-rot:active { background: rgba(217,180,90,.15); }
.pk-clear { position: absolute; right: -12px; top: -12px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); border: 1px solid var(--line); color: var(--paper-2); padding: 4px; display: flex; }
.pk-clear svg { width: 100%; height: 100%; }

/* ---------- 结果页 ---------- */
.res-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 0 16px 16px; text-align: center; }
.res-title { font-family: var(--serif); font-size: clamp(22px, 4.5vh, 34px); font-weight: 700; }
.res-score { display: flex; align-items: baseline; gap: 16px; }
.res-score b { font-size: clamp(40px, 10vh, 72px); color: var(--gold); line-height: 1; }
.res-score span { color: var(--paper-2); font-size: 20px; font-variant-numeric: tabular-nums; }
.res-grid { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.res-row { display: flex; gap: 18px; }
.res-try { display: flex; gap: 4px; }
.res-try .mk { width: clamp(16px, 3.4vh, 26px); height: clamp(16px, 3.4vh, 26px); border-radius: 5px; }
.res-streak { font-weight: 600; font-size: 17px; }
.res-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.level-pick { display: flex; gap: 6px; }
.btn.small { min-width: 0; padding: 8px 14px; font-size: 14px; border-color: var(--line); }
.btn.small.on { border-color: var(--gold); color: var(--gold); }
.res-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* 矮屏（640×360 横屏）：收紧间距 */
@media (max-height: 420px) {
  .bar { height: 38px; }
  .icon-btn { width: 34px; height: 34px; }
  .play { gap: 6px; padding: 0 6px 6px; }
  .net-panel { padding: 4px; }
  .net-actions { min-height: 44px; padding-top: 4px; }
  .btn { min-height: 38px; padding: 7px 18px; }
  .btn.big { min-width: 170px; font-size: 16px; }
  .res-body { gap: 7px; }
  .home-main { gap: 6px; }
  .tagline { margin-bottom: 2px; }
}

/* ---------- 统计浮层 ---------- */
.modal { position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center;
  background: rgba(5, 12, 22, .7); padding: 16px; }
.modal.on { display: flex; }
.modal-card { width: min(420px, 100%); max-height: 100%; overflow: auto; background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 16px 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-size: 18px; margin-bottom: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 24px; color: var(--paper); font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 12px; color: var(--muted); line-height: 1.25; }

/* ---------- Porcelain on warm paper ----------
 * All lighting is on face skins; the preserve-3d ancestors stay unfiltered.
 */
#home, #game, #result, body.doc-page {
  background:
    radial-gradient(ellipse at 22% 18%, #fffdf7a6, transparent 65%),
    repeating-linear-gradient(0deg, #71644d03 0 1px, transparent 1px 4px),
    #eeeae0;
}
#home::before {
  content: ''; position: absolute; inset: 24px; border: 1px solid #a99c8138;
  border-radius: 3px; pointer-events: none;
}
#home .corner-bar { padding: 36px 42px 0; gap: 12px; }
#home .text-btn { border-radius: 6px; border-color: #bdb4a1; }
#home .home-main { gap: 30px; }
#home .home-text { gap: 16px; }
#home h1 { color: #263c37; font-weight: 400; font-size: clamp(42px, 6vw, 84px); letter-spacing: -.055em; line-height: 1.08; }
#home .tagline { font-size: 17px; line-height: 1.65; max-width: 18em; }
#home .home-actions { gap: 12px; margin-top: 16px; }
#home .home-streak:empty { min-height: 0; margin: 0; }
#home .home-count { margin-top: 16px; font-size: 12px; letter-spacing: .035em; }
#home .home-foot { padding-bottom: 30px; }
html.land #home .home-foot { bottom: 40px; right: 44px; padding: 0; }
html.land #home .home-main { gap: clamp(50px, 7vw, 136px); }
#home .logo-stage {
  width: min(65vw, 29vh, 270px); height: min(65vw, 29vh, 270px);
  background: radial-gradient(ellipse at 45% 32%, #fffcf0, #e1d8c4 90%);
  border: 1px solid #bcb29c66; border-radius: 50%;
  box-shadow: inset 0 2px 3px #ffffffb3, 0 30px 70px -45px #5b492e80;
}
html.land #home .logo-stage { width: min(48vh, 35vw, 470px); height: min(48vh, 35vw, 470px); }
#home .logo-stage::before {
  content: ''; position: absolute; inset: 12px; border: 1px solid #aa9b7940; border-radius: 50%; pointer-events: none;
}
#home .logo-stage::after, #game .cubes > .stage::after {
  content: ''; position: absolute; left: 20%; right: 14%; top: 77%; height: 17%;
  background: radial-gradient(ellipse, #51412b38, #51412b0d 45%, transparent 70%);
  pointer-events: none;
}
#home .btn, #game .btn, #result .btn {
  border-radius: 8px; border: 1px solid #b8ae9b; color: #38483e;
  background: linear-gradient(#fffdf666, #fffdf61a);
  box-shadow: inset 0 1px 0 #ffffffa6, 0 2px 2px #6853370a;
  font-weight: 500; letter-spacing: .02em;
}
#home .btn.big { min-width: 244px; min-height: 52px; }
#home .btn.primary, #game .btn.primary, #result .btn.primary {
  background: linear-gradient(180deg, #ae6046, #984a35); color: #fff8eb; border-color: #954b37;
  box-shadow: inset 0 1px 0 #e2a68a, 0 3px 0 #753e30, 0 7px 16px #7e4b3024;
}
#game .btn.primary:disabled {
  opacity: 1; background: #ded7c9; border-color: #cbc2af; color: #81796a;
  box-shadow: inset 0 1px 0 #faf6ec, 0 2px 0 #c9bfad;
}
#home .btn:active, #game .btn:active, #result .btn:active { transform: translateY(2px); }
#game .bar { height: 64px; padding: 0 18px; border-bottom: 1px solid #bdb3a14d; margin-bottom: 16px; }
#game .bar-mid { gap: 22px; }
#game .qdot { border-color: #9caa9d; width: 8px; height: 8px; }
#game .qdot.cur { background: #425c50; border-color: #425c50; }
#game .pip { width: 6px; height: 13px; background: #ccc6b8; }
#game .pip.on { background: #a86c48; }
#game .play { gap: 16px; padding: 0 16px 18px; }
#game .panel { border: 1px solid #cfc7b6; border-radius: 14px; }
#game .cube-panel {
  background: radial-gradient(ellipse at 38% 26%, #fdfaf1, #e0d8c7);
  box-shadow: inset 0 1px 0 #fffefa, 0 8px 24px -14px #6b583533;
}
#game .net-panel {
  padding: 16px;
  background: radial-gradient(circle, #a494731b .7px, transparent .9px) 0 0 / 16px 16px, #f6f2e8;
  box-shadow: inset 0 1px 0 #fffefa, 0 8px 24px -14px #6b583533;
}
#game .net-actions { padding-top: 14px; min-height: 64px; }
#game .net-actions .btn { min-width: 170px; }
#game .corner { right: 12px; bottom: 12px; }
#game .cell .skin { inset: 3px; }
#game .cell .plus { color: #9c9483; font-size: 23px; }
#home .skin, #game .skin, #picker .skin {
  background: linear-gradient(145deg, #fffdf4, #f1eada 64%, #e2d7c0);
  border-radius: 7%;
  box-shadow: inset 0 0 0 1px #c4b797, inset 0 2px 1px 1px #fffef7,
    inset 0 -3px 2px #c9b99599, 0 3px 0 #b9aa8e, 0 5px 8px #715c3626;
}
#home .face .skin, #game .face .skin, #game .fold-face .skin {
  border-radius: 2.5%;
  background: linear-gradient(145deg, #ffffff52, #84705212), var(--ceramic, #eee5d2);
  box-shadow: inset 0 0 0 1px #b9ab8d, inset 2px 2px 1px #fffdf1c9,
    inset -2px -2px 1px #8d7d5b66;
}
#game .skin.empty {
  background: linear-gradient(145deg, #e3ddce, #f0ebdf);
  box-shadow: inset 0 0 0 1px #c9bfaa, inset 0 2px 4px #88714c1f, 0 1px 0 #ffffff;
}
#home .skin .pat, #game .skin .pat, #picker .skin .pat {
  left: 14%; top: 14%; width: 72%; height: 72%;
  filter: drop-shadow(0 -0.6px 0.35px #4b3a2b66) drop-shadow(0 1px 0.3px #fff9e9b3);
}
/* Keep every silhouette, ID and directional property; only mute the glaze palette. */
:is(#home, #game, #picker) .pat [fill="#C0392B"] { fill: #a8543e; }
:is(#home, #game, #picker) .pat [fill="#b8422f"] { fill: #ae6347; }
:is(#home, #game, #picker) .pat [fill="#3A8F5D"] { fill: #587863; }
:is(#home, #game, #picker) .pat [fill="#2E6FA3"] { fill: #4e7482; }
:is(#home, #game, #picker) .pat [fill="#8C6D3F"] { fill: #8e7555; }
:is(#home, #game, #picker) .pat [fill="#C9A227"] { fill: #b59145; }
:is(#home, #game, #picker) .pat [stroke="#C9A227"] { stroke: #b59145; }
:is(#home, #game, #picker) .pat [fill="#12233a"] { fill: #3e534d; }
:is(#home, #game, #picker) .pat [stroke="#12233a"] { stroke: #3e534d; }
#game .cell.sel .skin { outline: 2px solid #a4533b; outline-offset: 2px; }
#picker { border-color: #bcb09a; background: #eee8da; border-radius: 12px; padding: 12px; box-shadow: 0 12px 32px #493b2b40, inset 0 1px 0 #fffaf1; }
#picker .pk-grid { gap: 8px; }
#picker .pk-clear { background: #f5f0e4; color: #586453; }
@media (hover: hover) {
  #home .btn:hover, #game .btn:not(:disabled):hover, #result .btn:hover { filter: brightness(1.04); }
  #game .cell:not(.filled):hover .skin { background: #f7f0dd; }
  #home .icon-btn:hover, #game .icon-btn:hover, #result .icon-btn:hover, #stats .icon-btn:hover { background: #56634810; }
}
@media (min-width: 1000px) and (min-height: 600px) {
  #game .bar { margin: 20px auto 28px; width: calc(100% - 80px); max-width: 1370px; }
  #game .play { max-height: 790px; margin: auto; padding-bottom: 26px; }
  #game .net-panel { padding: 28px; }
}
@media (max-width: 559px) {
  #home::before { inset: 12px; }
  #home .corner-bar { padding: 24px 24px 0; }
  #home .home-main { padding-bottom: 12px; gap: 32px; }
  #home .home-text { gap: 12px; }
  #home .home-actions { margin-top: 8px; }
  #home .tagline { font-size: 15px; }
  #home .home-count { margin-top: 8px; font-size: 11px; }
  #game .bar { height: 52px; margin-bottom: 8px; padding: 0 10px; }
  #game .play { gap: 10px; padding: 0 10px 12px; }
  #game .cube-panel { flex-basis: 34%; }
  #game .net-panel { padding: 10px; }
  #game .net-actions { min-height: 54px; padding-top: 8px; }
}
@media (max-height: 420px) {
  #home::before { inset: 10px; }
  #home .corner-bar { padding: 14px 18px 0; }
  #home .home-main { gap: 34px; padding-bottom: 12px; }
  html.land #home .logo-stage { width: 190px; height: 190px; }
  #home h1 { font-size: 40px; }
  #home .home-text { gap: 8px; }
  #home .tagline { font-size: 13px; }
  #home .home-actions { margin-top: 4px; gap: 9px; }
  #home .btn.big { min-width: 186px; min-height: 38px; font-size: 14px; }
  #home .home-count { font-size: 10px; margin-top: 8px; }
  html.land #home .home-foot { bottom: 18px; right: 20px; }
  #game .bar { height: 38px; margin-bottom: 6px; padding: 0 10px; }
  #game .play { gap: 8px; padding: 0 8px 8px; }
  #game .net-panel { padding: 6px; }
  #game .net-actions { min-height: 44px; padding-top: 4px; }
  #game .corner { right: 4px; bottom: 4px; }
  #game .cell .skin { inset: 2px; }
}

/* Direction 02: local ceramic grain and view-dependent soft light.
 * Composite material layers into the opaque skin background. Separate translucent
 * pseudo layers caused backside bleed in Safari. No filter on 3D ancestors.
 */
:is(#home, #game, #picker) .skin {
  background-image: url('../assets/porcelain-grain.svg'),
    radial-gradient(ellipse at 32% 20%, #fffef7, #f2eddf 70%, #e8dfcd);
  background-size: 96px 96px, 100% 100%;
  box-shadow: inset 0 0 0 1px #c2b69e, inset 0 2px 1px #fffefa,
    inset 0 -4px 3px #b5a38266, 0 3px 0 #b5a78e, 0 6px 9px #604b2e24;
}
#home .face .skin, #game .face .skin, #game .fold-face .skin {
  background-image: linear-gradient(rgba(62,51,35,var(--face-shade, 0)), rgba(62,51,35,var(--face-shade, 0))),
    url('../assets/porcelain-grain.svg'), radial-gradient(ellipse at 38% 30%, #fffdf4, #f6f0e1 78%, #e9dfca);
  background-size: 100% 100%, 96px 96px, 100% 100%;
  border-radius: 3.5%;
  box-shadow: inset 0 0 0 1px #b2a084, inset 3px 3px 2px #ffffff,
    inset -3px -3px 3px #a88e6366;
}
:is(#home, #game, #picker) .skin .pat {
  filter: brightness(calc(1 - var(--face-shade, 0))) drop-shadow(0 -.8px .45px #3e302875) drop-shadow(0 1.1px .4px #ffffffe6);
}
#game .skin.empty {
  background-image: url('../assets/porcelain-grain.svg'), radial-gradient(ellipse at 50% 65%, #ede7d9, #dfd7c7);
  box-shadow: inset 0 0 0 1px #c6baa4, inset 1px 3px 5px #7c684330, 0 1px 0 #ffffff;
}
#home .logo-stage::after { top: 79%; height: 17%; left: 23%; right: 16%; }
#game .cubes > .stage::after { top: calc(50% + min(22vw, 145px)); height: 12%; }
#game .cubes:has(.stage + .stage) > .stage::after { top: 74%; }
/* Cull the assembled cube face too; folding faces keep their separate back. */
#home .face, #game .face {
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}

/* Completed screens share the same paper / ceramic visual vocabulary. */
#result .corner-bar { padding: 20px 24px 0; }
#result .res-body {
  flex: 0 1 auto; width: min(580px, calc(100% - 32px)); margin: auto;
  padding: 36px 28px; gap: 20px; border: 1px solid #cfc7b6; border-radius: 16px;
  background: radial-gradient(ellipse at 30% 0, #fffdf7, #f4efe3);
  box-shadow: inset 0 1px 0 #fffef9, 0 18px 55px -30px #67513255;
}
#result .res-body::before {
  content: ''; flex: none; width: 64px; height: 64px;
  background: url('../favicon.svg?ceramic=1') center / contain no-repeat;
}
#result .res-title { font-weight: 400; font-size: clamp(26px, 4vh, 38px); letter-spacing: -.025em; }
#result .res-score { gap: 18px; }
#result .res-score b { font-family: var(--serif); font-weight: 400; font-size: clamp(56px, 9vh, 88px); }
#result .res-score span { font-size: 18px; }
#result .res-grid { gap: 12px; padding: 14px 0 18px; }
#result .res-try .mk { width: clamp(14px, 4.1vw, 26px); height: clamp(14px, 4.1vw, 26px); }
#result .mk, #game .marks-row .mk {
  box-shadow: inset 0 1px 0 #ffffff66, inset 0 -2px 0 #0000001a, 0 2px 2px #77634a1a;
}
#result .res-streak { font-size: 15px; color: #59665c; }
#result .res-actions { gap: 12px; align-items: center; }
#result .res-count { font-size: 12px; }
#result .btn.ghost { border-color: transparent; box-shadow: none; background: none; color: #59665c; }
#result .btn.small.on { background: #e5d8c4; border-color: #a4533b; color: #8b432e; }
#stats { background: #2d342d73; }
#stats .modal-card {
  width: min(460px, 100%); background: #f6f2e8; border-color: #c8bda7;
  padding: 22px; box-shadow: inset 0 1px 0 #ffffff, 0 20px 70px #292b2938;
}
#stats .modal-head { font-family: var(--serif); font-size: 28px; margin-bottom: 20px; }
#stats .modal-head b { font-weight: 400; }
#stats .stats-grid { gap: 10px; }
#stats .stat {
  padding: 14px 4px; border-radius: 8px; border: 1px solid #d9d0be;
  background: linear-gradient(#fffdf5, #eee6d7); box-shadow: inset 0 1px 0 #ffffff;
}
#stats .stat b { font-family: var(--serif); font-weight: 400; font-size: 30px; }
#stats .stat span { color: #666d60; }
body.doc-page { background-attachment: fixed; }
.doc { max-width: 720px; padding: 38px 28px 60px; line-height: 1.85; }
.doc h1 { font-size: 44px; font-weight: 400; margin: 20px 0 30px; }
.doc p { color: #4f5b50; margin-bottom: 22px; }
#game .fold-face .back {
  background: url('../assets/porcelain-grain.svg') 0 0 / 96px 96px, linear-gradient(135deg, #ebe2d0, #c7b99c);
  box-shadow: inset 0 0 0 1px #b4a589, inset 2px 2px 2px #f8f1e3, inset -2px -2px 3px #95846555;
}
/* The result area centers its contents; stretch the stages so the 180-degree
 * marker anchors to the panel edge instead of the cube's vertical center. */
#netArea.cubes { align-items: stretch; }
#netArea.cubes.col > .stage { width: 100%; }
/* A dedicated 32px header keeps the marker clear of both cube projections. */
#game .dual-view .cube3d { top: calc(50% + 16px); }
#game .view-b { z-index: 2; top: 4px; left: 8px; height: 22px; }
#result .res-try .mk { font-size: clamp(12px, 3.3vw, 18px); }
@media (max-width: 559px) {
  #result .corner-bar { padding: 12px 16px 0; }
  #result .res-body { padding: 28px 16px; gap: 18px; }
  #stats .modal-card { padding: 18px; }
  #stats .stat { padding: 12px 3px; }
  .doc { padding: 20px 24px 40px; }
}
@media (max-height: 420px) {
  #result .corner-bar { padding: 6px 12px 0; }
  #result .res-body { width: min(540px, calc(100% - 100px)); padding: 12px 20px; gap: 6px; }
  #result .res-body::before { display: none; }
  #result .res-title { font-size: 22px; line-height: 1.15; }
  #result .res-score b { font-size: 40px; }
  #result .res-score span { font-size: 15px; }
  #result .res-grid { gap: 6px; padding: 3px 0 5px; }
  #result .res-try .mk { width: 16px; height: 16px; border-radius: 4px; font-size: 12px; }
  #result .res-streak { font-size: 12px; }
  #result .res-count { font-size: 10px; }
  #result .btn.ghost { min-height: 28px; padding: 3px 12px; font-size: 12px; }
  #stats .modal-card { padding: 12px 18px; }
  #stats .modal-head { margin-bottom: 8px; font-size: 24px; }
  #stats .stat { padding: 6px 4px; }
  #stats .stat b { font-size: 24px; }
}

/* One manual / reduced-motion switch; never enabled from viewport size alone.
 * Per-face fixed tones retain depth without dynamic lighting or heavy shadows. */
html.no-light :is(#home, #game) .face .skin {
  --face-shade: var(--static-shade, .16) !important;
}
html.no-light :is(#home, #game, #picker) .skin .pat { filter: none; }
html.no-light :is(#home, #game, #picker) .skin,
html.no-light #game .fold-face .back { box-shadow: inset 0 0 0 1px #b2a084; }
html.no-light :is(.btn, .picker, .modal-card, .res-body, .net-panel, .bar, .stat, .mk, .logo-stage) { box-shadow: none !important; }
html.no-light #game .cell.sel .skin,
html.no-light #picker .pk-item.cur .skin { outline: 3px solid var(--gold); }
html.no-light #home .logo-stage::after,
html.no-light #game .cubes > .stage::after { display: none; }
