:root {
  --paper: #ece6d6;
  --ink: #16171b;
  --ink-soft: #3a3a3d;
  --seal: #b8261a;
  --serif: "Shippori Mincho B1", "Noto Serif JP", "Yu Mincho", Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--serif);
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; cursor: crosshair; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
#height { position: absolute; left: max(26px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); line-height: 1;
  text-shadow: 0 0 6px var(--paper), 0 0 14px var(--paper); }
#hNum { font-size: clamp(34px, 7vmin, 56px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
#height small { font-size: 16px; margin-left: 4px; font-weight: 400; }
#best { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
#inkWrap { position: absolute; left: 50%; transform: translateX(-50%); top: max(18px, calc(env(safe-area-inset-top) + 8px)); display: flex; align-items: center; gap: 10px; }
#seal { width: 30px; height: 30px; background: var(--seal); color: var(--paper); display: grid; place-items: center; font-weight: 800; font-size: 19px;
  border-radius: 2px; box-shadow: inset 0 0 0 2px rgba(236,230,214,.35); }
#inkBar { width: clamp(120px, 34vw, 260px); height: 12px; border-radius: 6px 3px 7px 2px; background: rgba(22,23,27,.12); overflow: hidden; }
#inkFill { height: 100%; width: 100%; background: linear-gradient(90deg, #0e0f12, #2c2d31 85%, #55565a); transform-origin: left center; transition: transform .12s linear;
  border-radius: inherit; }
#inkWrap.low #inkFill { animation: low .6s ease-in-out infinite alternate; }
@keyframes low { to { opacity: .45; } }
#inkWrap.bump { animation: bump .35s ease-out; }
@keyframes bump { 25% { transform: translateX(calc(-50% - 7px)); } 50% { transform: translateX(calc(-50% + 6px)); } 75% { transform: translateX(calc(-50% - 3px)); } }
#pauseBtn { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); width: 42px; height: 42px; border: 0; background: transparent;
  pointer-events: auto; display: flex; gap: 6px; align-items: center; justify-content: center; cursor: pointer; }
#pauseBtn i { width: 5px; height: 18px; background: var(--ink); border-radius: 2px 1px 3px 1px; }

#toast { position: fixed; left: 50%; top: 22%; transform: translate(-50%, 6px); font-size: clamp(20px, 4.5vmin, 30px); font-weight: 800; opacity: 0;
  pointer-events: none; transition: opacity .15s, transform .25s; white-space: pre; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { color: var(--seal); }

#hint { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: clamp(15px, 3.6vmin, 20px); text-align: center;
  padding: 0 24px; width: 100%; pointer-events: none; transition: opacity .6s; color: var(--ink-soft); }
#hint.fade { opacity: 0; }

#tip { position: fixed; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); pointer-events: none; display: none; opacity: .7; }

/* ---------- panels ---------- */
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, 94vw); text-align: center; padding: 34px 18px 26px;
  border-radius: 40px; background: radial-gradient(closest-side, rgba(236,230,214,.96) 72%, rgba(236,230,214,.8) 88%, rgba(236,230,214,0)); }
.panel h1 { font-size: clamp(40px, 10vmin, 64px); font-weight: 800; margin: 0 0 10px; letter-spacing: -.01em; line-height: 1; }
.panel h2 { font-size: 34px; margin: 0 0 18px; }
.vtitle { position: fixed; right: calc(-12vw + 10px); top: -40px; writing-mode: vertical-rl; font-size: 22px; color: var(--seal); letter-spacing: .3em; }
.lede { font-size: 17px; margin: 0 0 26px; color: var(--ink-soft); }
.btns { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
button.ink { border: 0; cursor: pointer; padding: 14px 26px; font-size: 18px; font-weight: 800; color: var(--paper); background: var(--ink);
  border-radius: 14px 5px 16px 4px / 6px 14px 5px 15px; box-shadow: 0 1px 0 rgba(0,0,0,.2); transition: transform .08s; }
button.ink:active { transform: scale(.97); }
button.ink.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.how { list-style: none; padding: 0; margin: 28px 0 14px; font-size: 15px; line-height: 1.7; color: var(--ink-soft); }
#menuBest { font-size: 14px; color: var(--ink-soft); min-height: 1em; }

/* ---------- end card ---------- */
#card { position: fixed; text-align: center; }
#card.bottom { left: 0; right: 0; bottom: 0; padding: 14px 16px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(236,230,214,0), rgba(236,230,214,.92) 22%); }
#card.side { right: 4vw; top: 50%; transform: translateY(-50%); width: min(34vw, 380px); }
#cH { font-size: clamp(44px, 11vmin, 76px); font-weight: 800; line-height: 1; }
#cSub { font-size: 15px; color: var(--ink-soft); margin: 10px 0 16px; line-height: 1.5; }
#cSub b { color: var(--seal); }
#card button.ink { padding: 12px 20px; font-size: 16px; }

#nogl { position: fixed; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; font-size: 20px; background: var(--paper); }

@media (max-width: 600px) { .vtitle { display: none; } }

/* ---------- sound toggle ---------- */
button.mute { width: 42px; height: 42px; border: 0; background: transparent; cursor: pointer; pointer-events: auto; padding: 0; color: var(--ink); display: grid; place-items: center; }
#muteBtn { position: absolute; right: calc(max(14px, env(safe-area-inset-right)) + 44px); top: max(12px, env(safe-area-inset-top)); }
button.mute.inmenu { margin: 14px auto 0; }
button.mute .x { display: none; }
button.mute.off .x { display: inline; }
button.mute.off .w { display: none; }
