/* ==========================================================
   聖經打字機 Bible Typewriter
   ========================================================== */
:root {
  --wood-0: #1c0f08;
  --wood-1: #2c180d;
  --wood-2: #4a2a16;
  --brass: #c9a24a;
  --brass-hi: #f0d488;
  --brass-lo: #8a6a24;
  --paper: #f5ead0;
  --paper-2: #e9d6a8;
  --ink: #2b2118;
  --ink-soft: #6b5640;
  --red: #b3261e;
  --red-hi: #e0483e;
  --green: #2f7a45;
  --gold: #f3c33b;
  --sky: #3a78b8;
  --metal: #1b1b1d;
  --metal-2: #2f2f33;
  --en: 'Special Elite', 'Courier New', monospace;
  --zh: 'Noto Serif TC', 'PMingLiU', serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: #1c0f08; }
body {
  min-height: 100vh;
  color: var(--paper);
  font-family: var(--zh);
  background:
    repeating-linear-gradient(92deg, rgba(0,0,0,.07) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(88deg, rgba(255,220,170,.03) 0 1px, transparent 1px 23px),
    radial-gradient(ellipse at 50% 0%, #6a3d20 0%, var(--wood-1) 55%, var(--wood-0) 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
kbd {
  font-family: var(--en); font-size: .85em; padding: 1px 6px; border-radius: 4px;
  background: var(--paper); color: var(--ink); border: 1px solid var(--ink-soft);
}

.desk { max-width: 980px; margin: 0 auto; padding: 12px 16px 24px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 12px; }
.brand { color: var(--brass-hi); text-decoration: none; font-family: var(--en); font-size: 18px; letter-spacing: 1px; }
.topbar-actions { display: flex; gap: 8px; }
.chip {
  background: rgba(0,0,0,.35); color: var(--paper); border: 1px solid rgba(240,212,136,.4);
  border-radius: 999px; padding: 6px 14px; font-size: 14px;
}
.chip:hover { border-color: var(--brass-hi); color: var(--brass-hi); }

.screen { display: none; }
.screen.is-active { display: block; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 2px 0 rgba(255,255,255,.4) inset, 0 18px 40px rgba(0,0,0,.5);
  padding: 22px;
  position: relative;
}
.muted { color: var(--ink-soft); font-size: 14px; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 14px 0 22px; }
.hero-badge {
  display: inline-block; font-family: var(--en); letter-spacing: 4px; font-size: 12px;
  color: var(--brass-hi); border: 1px solid var(--brass); padding: 4px 12px; border-radius: 3px;
}
.logo {
  margin: 14px 0 0; font-weight: 900; font-size: clamp(44px, 10vw, 84px); line-height: 1.05;
  letter-spacing: .08em;
  background: linear-gradient(180deg, #fff3c8 0%, var(--brass-hi) 35%, var(--brass) 60%, var(--brass-lo) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #3a210e) drop-shadow(0 10px 18px rgba(0,0,0,.6));
}
.logo-en { margin: 6px 0 0; font-family: var(--en); font-size: clamp(18px, 4vw, 26px); color: var(--paper); letter-spacing: 6px; }
.logo-en::after { content: '▌'; color: var(--red-hi); animation: blink 1s steps(1) infinite; margin-left: 4px; }
@keyframes blink { 50% { opacity: 0; } }
.tagline { margin: 14px auto 0; max-width: 560px; color: #e9d9b6; font-size: 16px; line-height: 1.7; }

/* ---------- setup ---------- */
.setup { margin-bottom: 18px; }
.field-label { display: block; font-weight: 700; margin: 0 0 8px; font-size: 15px; }
.nick-input {
  width: 100%; font-size: 20px; padding: 12px 14px; margin-bottom: 18px;
  font-family: var(--en), var(--zh); color: var(--ink);
  background: #fffaf0; border: 2px solid var(--ink-soft); border-radius: 10px; outline: none;
}
.nick-input:focus { border-color: var(--brass-lo); box-shadow: 0 0 0 4px rgba(201,162,74,.3); }

.diff-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.diff-card {
  text-align: left; border: 2px solid rgba(43,33,24,.25); border-radius: 12px; padding: 12px 14px;
  background: #fbf4e2; color: var(--ink); display: flex; flex-direction: column; gap: 2px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.diff-card:hover { transform: translateY(-2px); }
.diff-card[aria-checked="true"] {
  border-color: var(--ink); background: #fff;
  box-shadow: 0 0 0 3px var(--brass), 0 8px 18px rgba(0,0,0,.18);
}
.diff-card[data-diff="easy"] .diff-name { color: var(--green); }
.diff-card[data-diff="normal"] .diff-name { color: var(--sky); }
.diff-card[data-diff="hard"] .diff-name { color: var(--red); }
.diff-name { font-size: 24px; font-weight: 900; }
.diff-en { font-family: var(--en); font-size: 12px; letter-spacing: 1px; color: var(--ink-soft); }
.diff-desc { font-size: 13px; line-height: 1.6; margin-top: 6px; color: #4a3a2a; }

.form-msg { min-height: 1.4em; color: var(--red); margin: 10px 0 4px; font-size: 14px; }

.btn-start {
  width: 100%; border: 0; border-radius: 12px; padding: 14px 20px;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 60%, #7c1812);
  color: #fff; font-size: 24px; font-weight: 900; letter-spacing: .2em;
  box-shadow: 0 5px 0 #4d0e0a, 0 12px 20px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .08s, box-shadow .08s;
}
.btn-start small { font-size: 12px; font-weight: 400; letter-spacing: 1px; opacity: .85; }
.btn-start:active { transform: translateY(4px); box-shadow: 0 1px 0 #4d0e0a, 0 6px 12px rgba(0,0,0,.35); }
.btn-start.small { width: auto; min-width: 200px; font-size: 20px; padding: 10px 24px; }

.btn-small {
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 9px 18px; font-size: 15px; font-weight: 700;
}
.btn-small.ghost { background: transparent; color: var(--ink); }

/* ---------- board ---------- */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.board-head h2 { margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  border: 1px solid rgba(43,33,24,.3); background: transparent; color: var(--ink);
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
}
.tab.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.board-body { overflow-x: auto; }
.board table { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th, .board td { padding: 8px 6px; text-align: left; border-bottom: 1px dashed rgba(43,33,24,.25); white-space: nowrap; }
.board th { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.board td.num, .board th.num { text-align: right; font-family: var(--en); }
.board .nick { font-weight: 700; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; color: #fff; }
.badge.easy { background: var(--green); }
.badge.normal { background: var(--sky); }
.badge.hard { background: var(--red); }
.medal { font-family: var(--en); display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; background: rgba(43,33,24,.1); }
.medal.m1 { background: var(--gold); }
.medal.m2 { background: #cfd3d8; }
.medal.m3 { background: #d79a63; }
.board tr.me td { background: rgba(243,195,59,.25); }

/* ---------- HUD ---------- */
.hud { display: grid; grid-template-columns: repeat(5, 1fr) 48px; gap: 8px; margin-bottom: 8px; }
.plate {
  position: relative; border-radius: 8px; padding: 6px 10px 5px;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 45%, var(--brass-lo));
  color: #2a1a06; box-shadow: 0 2px 0 rgba(255,255,255,.5) inset, 0 4px 8px rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 54px;
}
.plate::before, .plate::after {
  content: ''; position: absolute; top: 50%; width: 5px; height: 5px; margin-top: -2px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff6d8, #6b5017);
}
.plate::before { left: 5px; } .plate::after { right: 5px; }
.plate-k { font-size: 11px; font-weight: 700; letter-spacing: 2px; opacity: .8; }
.plate b { font-family: var(--en); font-size: 22px; line-height: 1.1; }
.plate-combo i { position: absolute; top: 3px; right: 12px; font-style: normal; font-family: var(--en); font-size: 13px; color: var(--red); }
.plate-combo.hot { animation: hot .5s ease; }
@keyframes hot { 40% { transform: scale(1.12); } }
.plate-btn { border: 0; font-size: 16px; color: #2a1a06; }
.lives { display: flex; gap: 4px; height: 24px; align-items: flex-end; }
.ink {
  width: 14px; height: 20px; border-radius: 3px 3px 5px 5px; position: relative;
  background: linear-gradient(180deg, transparent 0 25%, #1e2a5c 25%, #0d1433 100%);
  border: 2px solid #2a1a06; border-top-width: 1px;
}
.ink::before { content: ''; position: absolute; top: -6px; left: 2px; width: 6px; height: 5px; background: #2a1a06; border-radius: 1px; }
.ink.empty { background: transparent; opacity: .35; }
.ink.spill { animation: spill .6s ease forwards; }
@keyframes spill { 50% { transform: rotate(-70deg) translateX(-4px); } 100% { transform: rotate(-90deg) translateX(-4px); opacity: .35; } }
.ink.gain { animation: gain .6s ease; }
@keyframes gain { 0% { transform: scale(0); } 70% { transform: scale(1.4); } }

.canon { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; color: #ead7ae; }
.canon-k { white-space: nowrap; font-weight: 700; }
.canon-v { font-family: var(--en); white-space: nowrap; min-width: 62px; text-align: right; }
.canon-bar { flex: 1; height: 10px; border-radius: 99px; background: rgba(0,0,0,.45); overflow: hidden; border: 1px solid rgba(240,212,136,.35); }
.canon-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brass-lo), var(--brass-hi)); transition: width .4s ease; }

/* ---------- play field ---------- */
.field {
  position: relative; overflow: hidden; height: clamp(280px, calc(100vh - 500px), 540px);
  border-radius: 12px 12px 0 0;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(120,70,20,.25), transparent 60%),
    linear-gradient(180deg, #f7eed6, #ead8ab);
  box-shadow: inset 0 0 60px rgba(110,70,20,.45), inset 0 0 0 6px #3a2312, inset 0 0 0 8px var(--brass);
  cursor: text;
  user-select: none;
}
.field-lines {
  position: absolute; inset: 8px;
  background: repeating-linear-gradient(180deg, transparent 0 35px, rgba(120,80,40,.13) 35px 36px);
  pointer-events: none;
}
.field.frozen { box-shadow: inset 0 0 90px rgba(255,190,40,.8), inset 0 0 0 6px #3a2312, inset 0 0 0 8px var(--gold); }
.field.hurt { animation: hurt .45s ease; }
@keyframes hurt { 30% { box-shadow: inset 0 0 120px rgba(179,38,30,.85), inset 0 0 0 6px #3a2312, inset 0 0 0 8px var(--red); } }
.field.shake { animation: shake .25s linear; }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

.inkline {
  position: absolute; left: 8px; right: 8px; bottom: 8px; height: 28px; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(16,24,70,.25));
  border-top: 2px dashed rgba(16,24,70,.55);
}
.inkline span { position: absolute; right: 10px; top: 4px; font-size: 11px; color: rgba(16,24,70,.7); letter-spacing: 2px; }

/* scrolls */
.scroll {
  position: absolute; top: 0; left: 0; z-index: 2;
  padding: 6px 16px 5px; min-width: 70px; text-align: center;
  background: linear-gradient(180deg, #fffaf0 0%, #f1e1b8 100%);
  border-top: 1px solid #c8ad74; border-bottom: 1px solid #b8995c;
  box-shadow: 0 6px 12px rgba(60,35,10,.35);
  will-change: transform;
}
.scroll::before, .scroll::after {
  content: ''; position: absolute; top: -5px; bottom: -5px; width: 10px; border-radius: 5px;
  background: linear-gradient(90deg, #5a3618, #a8743a 45%, #4a2b12);
  box-shadow: 0 2px 3px rgba(0,0,0,.4);
}
.scroll::before { left: -6px; } .scroll::after { right: -6px; }
.scroll .en { font-family: var(--en); font-size: 24px; color: var(--ink); white-space: pre; letter-spacing: 1px; line-height: 1.2; }
.scroll .zh { display: block; font-size: 12px; color: var(--ink-soft); line-height: 1.3; }
.scroll .done { color: var(--green); }
.scroll .cur { color: var(--red); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.scroll .hid { color: rgba(43,33,24,.45); }
.scroll.locked { z-index: 5; box-shadow: 0 0 0 3px var(--red), 0 10px 20px rgba(60,35,10,.5); }
.scroll.locked .en { font-size: 26px; }
.scroll.danger:not(.locked) { box-shadow: 0 0 0 2px rgba(179,38,30,.6), 0 6px 12px rgba(60,35,10,.35); }
.scroll .tag {
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; color: #fff;
}
.scroll.sp-gold { background: linear-gradient(180deg, #fff6c9, var(--gold)); animation: glow 1.2s ease-in-out infinite; }
.scroll.sp-gold .tag { background: #a87a00; }
.scroll.sp-manna { background: linear-gradient(180deg, #ffffff, #e6eef7); }
.scroll.sp-manna .tag { background: var(--sky); }
.scroll.sp-trumpet { background: linear-gradient(180deg, #fff1e0, #f2c08a); }
.scroll.sp-trumpet .tag { background: #b5601d; }
.scroll.sp-sun { background: linear-gradient(180deg, #fff8d8, #ffd36b); }
.scroll.sp-sun .tag { background: #c47d00; }
@keyframes glow { 50% { box-shadow: 0 0 22px 4px rgba(243,195,59,.9), 0 6px 12px rgba(60,35,10,.35); } }
.scroll.pop { animation: pop .35s ease forwards; }
@keyframes pop { to { transform: var(--t) scale(1.5); opacity: 0; filter: blur(2px); } }
.scroll.drop { animation: drop .5s ease-in forwards; }
@keyframes drop { to { transform: var(--t) translateY(40px) rotate(8deg); opacity: 0; } }

.float {
  position: absolute; z-index: 8; pointer-events: none; font-family: var(--en); font-size: 22px; font-weight: 700;
  color: var(--green); text-shadow: 0 2px 0 #fff; animation: floatUp .9s ease-out forwards; white-space: nowrap;
}
.float.big { font-size: 30px; color: #a87a00; }
.float.bad { color: var(--red); }
@keyframes floatUp { to { transform: translateY(-50px); opacity: 0; } }

.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; z-index: 20;
  font-family: var(--en); font-size: 120px; color: var(--red); text-shadow: 0 4px 0 #fff;
  background: rgba(245,234,208,.55);
}
.overlay.show { display: flex; }
.overlay .tick { animation: tick .8s ease forwards; }
@keyframes tick { 0% { transform: scale(2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { opacity: .2; } }

.banner {
  position: absolute; left: 0; right: 0; top: 38%; z-index: 15; text-align: center; pointer-events: none;
  font-weight: 900; font-size: clamp(26px, 6vw, 44px); color: var(--ink); opacity: 0;
}
.banner small { display: block; font-size: 16px; font-weight: 400; color: var(--ink-soft); }
.banner.show { animation: banner 1.6s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: 1; transform: scale(1.05); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

.ime-warn {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 18; display: none;
  background: var(--red); color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 14px; white-space: nowrap;
}
.ime-warn.show { display: block; }

.pause-layer { position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; background: rgba(28,15,8,.6); }
.pause-layer.show { display: flex; }
.pause-card { background: var(--paper); color: var(--ink); border-radius: 12px; padding: 20px 26px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,.5); }
.pause-card h3 { margin: 0 0 6px; font-size: 24px; }
.pause-card p { margin: 0 0 14px; color: var(--ink-soft); }
.pause-card .btn-small { margin: 4px; }

/* ---------- typewriter ---------- */
.typewriter { position: relative; }
.platen { position: relative; margin: 0 6%; }
.paper {
  position: relative; z-index: 2; margin: 0 8%; padding: 10px 16px 8px; min-height: 74px; text-align: center;
  background: #fffdf6; color: var(--ink);
  box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 -2px 10px rgba(0,0,0,.25);
}
.paper-line { font-family: var(--en); font-size: clamp(22px, 5vw, 34px); min-height: 1.2em; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.paper-line .done { color: var(--ink); }
.paper-line .rest { color: rgba(43,33,24,.28); }
.paper-line .caret { color: var(--red); animation: blink 1s steps(1) infinite; }
.paper-zh { font-size: 13px; color: var(--ink-soft); min-height: 1.3em; }
.roller {
  position: relative; z-index: 3; height: 26px; margin-top: -6px; border-radius: 13px;
  background: linear-gradient(180deg, #4b4b50 0%, #0e0e10 45%, #2a2a2e 70%, #555 100%);
  box-shadow: 0 4px 8px rgba(0,0,0,.6);
}
.roller::before, .roller::after {
  content: ''; position: absolute; top: -3px; width: 30px; height: 32px; border-radius: 8px;
  background: linear-gradient(180deg, var(--brass-hi), var(--brass-lo));
}
.roller::before { left: -16px; } .roller::after { right: -16px; }
.machine {
  position: relative; margin-top: -4px; padding: 12px 14px 16px;
  border-radius: 10px 10px 26px 26px;
  background: linear-gradient(180deg, var(--metal-2), var(--metal) 40%, #0c0c0d);
  border-top: 3px solid var(--brass);
  box-shadow: 0 20px 30px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.15);
}
.machine-plate {
  text-align: center; font-family: var(--en); font-size: 12px; letter-spacing: 4px; color: var(--brass-hi);
  margin-bottom: 10px; opacity: .85;
}
.keyboard { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.krow { display: flex; gap: 6px; }
.krow:nth-child(3) { margin-left: 18px; }
.krow:nth-child(4) { margin-left: 36px; }
.key {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--en); font-size: 16px; color: #1a1a1a;
  background: radial-gradient(circle at 40% 35%, #ffffff, #e9e2cf 55%, #bfb59c);
  border: 3px solid #9c9c9c; box-shadow: 0 4px 0 #000, 0 5px 6px rgba(0,0,0,.5);
  transition: transform .05s, box-shadow .05s;
}
.key.space { width: 240px; border-radius: 17px; font-size: 12px; letter-spacing: 3px; color: #555; }
.key.hit { transform: translateY(3px); box-shadow: 0 1px 0 #000, 0 1px 2px rgba(0,0,0,.5); }
.key.next { background: radial-gradient(circle at 40% 35%, #fff9de, var(--gold) 60%, #c08f12); border-color: var(--brass-hi); animation: nextKey 1s ease-in-out infinite; }
.key.wrong { background: radial-gradient(circle at 40% 35%, #ffd4d0, var(--red-hi) 70%); }
@keyframes nextKey { 50% { box-shadow: 0 4px 0 #000, 0 0 16px 4px rgba(243,195,59,.8); } }

.ghost-input { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* ---------- result ---------- */
.result { text-align: center; padding-top: 34px; overflow: hidden; }
.seal {
  position: absolute; top: 18px; right: 22px; width: 92px; height: 92px; border-radius: 10px;
  border: 4px solid var(--red); color: var(--red); font-weight: 900; font-size: 26px;
  display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; letter-spacing: 4px;
  transform: rotate(-12deg); opacity: 0; mix-blend-mode: multiply;
  background: radial-gradient(circle, rgba(179,38,30,.08), transparent 70%);
}
.seal.stamp { animation: stamp .5s cubic-bezier(.3,1.6,.5,1) .5s forwards; }
@keyframes stamp { 0% { opacity: 0; transform: rotate(-12deg) scale(2.4); } 100% { opacity: .9; transform: rotate(-12deg) scale(1); } }
.result-kicker { margin: 0; letter-spacing: 3px; color: var(--ink-soft); font-size: 14px; }
.result-title { margin: 6px 0 4px; font-size: 30px; }
.result-score { margin: 0; font-family: var(--en); font-size: 64px; line-height: 1.1; color: var(--red); }
.result-score small { font-family: var(--zh); font-size: 18px; margin-left: 4px; color: var(--ink); }
.result-rank { margin: 6px 0 16px; min-height: 1.4em; color: var(--ink-soft); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 auto 16px; max-width: 560px; }
.stats div { background: rgba(255,255,255,.55); border: 1px solid rgba(43,33,24,.15); border-radius: 10px; padding: 10px 6px; }
.stats b { display: block; font-family: var(--en); font-size: 26px; }
.stats span { font-size: 12px; color: var(--ink-soft); }
.review { max-width: 560px; margin: 0 auto 18px; text-align: left; display: none; }
.review.show { display: block; }
.review h3 { font-size: 16px; margin: 0 0 8px; }
.review ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.review li { background: #fff; border: 1px dashed var(--ink-soft); border-radius: 8px; padding: 4px 10px; font-size: 14px; }
.review li b { font-family: var(--en); font-weight: 400; margin-right: 6px; }
.result-actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* ---------- rules dialog ---------- */
.rules {
  max-width: 640px; width: calc(100% - 32px); border: 0; border-radius: 14px; padding: 0;
  background: var(--paper); color: var(--ink); box-shadow: 0 30px 60px rgba(0,0,0,.6);
}
.rules::backdrop { background: rgba(20,10,4,.7); }
.rules form { padding: 22px 24px; max-height: 85vh; overflow-y: auto; }
.rules h2 { margin: 0 0 10px; }
.rules ol { padding-left: 20px; line-height: 1.75; font-size: 15px; }
.rules ul { padding-left: 4px; list-style: none; }
.sp { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; border-radius: 999px; padding: 0 8px; margin-right: 6px; }
.sp-gold { background: #a87a00; } .sp-manna { background: var(--sky); }
.sp-trumpet { background: #b5601d; } .sp-sun { background: #c47d00; }

.foot { text-align: center; color: rgba(240,212,136,.5); font-size: 12px; margin-top: 18px; }

/* ---------- responsive ---------- */
@media (max-height: 820px) and (min-width: 561px) {
  .key { width: 28px; height: 28px; font-size: 13px; border-width: 2px; box-shadow: 0 3px 0 #000; }
  .key.space { width: 190px; }
  .krow { gap: 4px; } .keyboard { gap: 4px; }
  .machine-plate { margin-bottom: 6px; }
  .paper { min-height: 64px; padding-top: 6px; }
  .field { height: clamp(260px, calc(100vh - 420px), 540px); }
}
@media (max-width: 720px) {
  .key { width: 28px; height: 28px; font-size: 13px; border-width: 2px; }
  .key.space { width: 180px; }
  .krow { gap: 4px; }
  .krow:nth-child(3) { margin-left: 12px; } .krow:nth-child(4) { margin-left: 24px; }
  .scroll .en { font-size: 20px; } .scroll.locked .en { font-size: 22px; }
}
@media (max-width: 560px) {
  .desk { padding: 8px 12px 20px; }
  .diff-cards { grid-template-columns: 1fr; }
  .diff-desc br { display: none; }
  .hud { grid-template-columns: repeat(3, 1fr); }
  .hud .plate-btn { grid-column: span 1; }
  .plate { min-height: 46px; }
  .plate b { font-size: 18px; }
  .keyboard { display: none; }
  .machine { padding: 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .seal { width: 70px; height: 70px; font-size: 20px; top: 12px; right: 12px; }
  .result-score { font-size: 48px; }
  .platen { margin: 0 2%; } .paper { margin: 0 4%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
