:root {
  --red: #e2202f; --red2: #ff4252; --blue: #1f3fa8; --ink: #0b0f1a; --cyan: #5ff3ff; --gold: #ffcc45;
  --font: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --display: "Arial Black", "Impact", "Segoe UI Black", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff; font-family: var(--font); -webkit-user-select: none; user-select: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#touch-area { position: fixed; inset: 0; z-index: 2; pointer-events: none; touch-action: none; }
body[data-touch="1"][data-state="play"] #touch-area { pointer-events: auto; }
button { font-family: inherit; cursor: pointer; }

/* ---- 読み込み ---- */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(ellipse at 50% 40%, #1a2350 0%, #070a14 70%); transition: opacity .7s; }
#loading.done { opacity: 0; pointer-events: none; }
.ld-logo { font-family: var(--display); font-size: clamp(36px, 7vw, 72px); letter-spacing: .04em; color: var(--red); text-shadow: 0 4px 0 #6a0b14, 0 0 40px rgba(226, 32, 47, .45); text-align: center; line-height: 1; }
.ld-logo span { color: #fff; }
.ld-logo small { display: block; font-size: .28em; color: #cfd6ff; letter-spacing: .6em; margin-top: 10px; text-shadow: none; }
.ld-bar { width: min(360px, 70vw); height: 4px; background: rgba(255, 255, 255, .12); border-radius: 4px; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), #ff8a5c); transition: width .25s; }
#ld-text { color: #aab3d6; font-size: 14px; letter-spacing: .1em; }

/* ---- 共通の上部 ---- */
#hub { position: fixed; top: 14px; left: 16px; z-index: 30; color: #fff; text-decoration: none; font-size: 13px; font-weight: 700; padding: 8px 14px;
  background: rgba(10, 14, 28, .55); border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; backdrop-filter: blur(6px); letter-spacing: .05em; }
#hub:hover { background: rgba(226, 32, 47, .8); }
#topbar { position: fixed; top: 14px; right: 16px; z-index: 30; display: flex; gap: 8px; }
#topbar button { color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .06em; padding: 8px 12px; background: rgba(10, 14, 28, .55); border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; backdrop-filter: blur(6px); }
#topbar button:hover { border-color: #fff; }
#btn-abort { background: rgba(226, 32, 47, .75) !important; }

/* ---- タイトル ---- */
#title { position: fixed; z-index: 10; left: 0; top: 0; bottom: 0; width: min(560px, 100vw); padding: 86px 44px 30px; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(90deg, rgba(5, 8, 20, .82) 0%, rgba(5, 8, 20, .55) 62%, rgba(5, 8, 20, 0) 100%); pointer-events: none; }
#title > * { pointer-events: auto; }
.t-eyebrow { display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: .32em; color: #c8cff5; font-weight: 700; }
.t-eyebrow i { width: 28px; height: 3px; background: var(--red); display: block; }
.t-logo { margin: 0; font-family: var(--display); font-size: clamp(54px, 10vw, 104px); line-height: .86; letter-spacing: -.01em; transform: skewX(-6deg); }
.t-logo .a { display: block; color: var(--red); text-shadow: 0 5px 0 #6a0b14, 0 0 50px rgba(226, 32, 47, .4); }
.t-logo .b { display: block; color: #fff; text-shadow: 0 5px 0 var(--blue), 0 0 40px rgba(60, 100, 255, .35); }
.t-sub { font-weight: 800; letter-spacing: .5em; color: #ffd9b0; font-size: 15px; }
.t-tag { margin: 4px 0 6px; font-size: 17px; color: #fff; font-weight: 700; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.t-modes { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.mode { position: relative; text-align: left; color: #fff; padding: 14px 18px 14px 20px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .22);
  background: linear-gradient(100deg, rgba(226, 32, 47, .92), rgba(160, 18, 34, .85)); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); transition: transform .12s, filter .12s; }
.mode + .mode { background: linear-gradient(100deg, rgba(31, 63, 168, .92), rgba(18, 36, 110, .85)); }
.mode:hover { transform: translateX(6px); filter: brightness(1.12); }
.mode b { display: block; font-family: var(--display); font-size: 22px; letter-spacing: .04em; }
.mode span { display: block; font-size: 13px; opacity: .9; margin-top: 3px; }
.mode em { position: absolute; right: 14px; top: 14px; font-style: normal; font-size: 11px; font-weight: 800; letter-spacing: .1em; opacity: .75; }
.t-keys { display: grid; gap: 5px; margin-top: 8px; font-size: 12.5px; color: #dfe4ff; }
.t-keys div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.t-keys span { opacity: .9; }
kbd { font-family: inherit; font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 5px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); }
.t-keys.touch { display: none; }
body[data-touch="1"] .t-keys.pc { display: none; }
body[data-touch="1"] .t-keys.touch { display: grid; }
.t-hint { margin-top: auto; font-size: 12px; letter-spacing: .1em; color: #aeb6da; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .45; } }
#demo-tag { position: fixed; z-index: 9; right: 18px; bottom: 16px; font-size: 12px; font-weight: 800; letter-spacing: .25em; color: #fff; display: none; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px; background: rgba(0, 0, 0, .35); }
#demo-tag i { width: 9px; height: 9px; border-radius: 50%; background: var(--red2); box-shadow: 0 0 10px var(--red2); animation: blink 1s infinite; }
body[data-state="title"] #demo-tag { display: flex; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
.h-label { font-size: 11px; font-weight: 800; letter-spacing: .28em; color: #c9d1ff; }
.h-big { font-family: var(--display); font-size: 26px; letter-spacing: .02em; }
.h-sub { font-size: 13px; font-weight: 700; color: #dfe4ff; letter-spacing: .08em; }
.h-row { display: flex; align-items: baseline; gap: 6px; }
#h-mode { position: absolute; left: 20px; top: 16px; padding: 10px 16px 10px 14px; border-left: 4px solid var(--red); background: linear-gradient(90deg, rgba(5, 8, 20, .6), rgba(5, 8, 20, 0)); text-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
#h-mode #h-time { font-family: var(--display); font-size: 20px; color: #fff; }
#h-style { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .6); min-width: 150px; }
#h-style b { font-family: var(--display); font-size: 24px; }
#h-style span { font-family: var(--display); font-size: 18px; color: var(--gold); }
#h-style .h-row { justify-content: center; }
#h-style-bar { height: 3px; background: rgba(255, 255, 255, .15); margin-top: 4px; border-radius: 3px; overflow: hidden; }
#h-style-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ff7a3c); }
#h-speed { position: absolute; left: 22px; bottom: 20px; text-shadow: 0 2px 8px rgba(0, 0, 0, .7); }
#h-speed b { font-family: var(--display); font-size: 46px; line-height: 1; font-style: italic; }
#h-speed span { font-weight: 800; font-size: 14px; letter-spacing: .1em; color: #ffd9b0; }
#h-state { margin-top: 4px; display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .2em; padding: 3px 9px; border-radius: 4px; background: rgba(226, 32, 47, .8); }
#minimap { position: absolute; right: 18px; top: 60px; width: 170px; height: 170px; border-radius: 50%; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); opacity: .92; }
#h-pop { position: absolute; left: 50%; top: 64%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }
.pop { font-family: var(--display); font-size: 20px; letter-spacing: .04em; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .5), 0 0 18px rgba(255, 255, 255, .35); animation: pop 1.4s ease-out forwards; white-space: nowrap; }
.pop.gold { color: var(--gold); }
.pop.cyan { color: var(--cyan); font-size: 24px; }
@keyframes pop { 0% { transform: scale(.6) translateY(10px); opacity: 0; } 12% { transform: scale(1.12); opacity: 1; } 22% { transform: scale(1); } 75% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }
#h-reticle { position: absolute; left: 0; top: 0; width: 0; height: 0; }
#h-reticle i { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 10px rgba(255, 255, 255, .6); }
#h-reticle i::after { content: "E"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 11px; font-weight: 900; }
body[data-touch="1"] #h-reticle i::after { content: "ZIP"; font-size: 8px; }
#h-marker { position: absolute; left: 0; top: 0; width: 0; height: 0; }
#h-marker::before { content: ""; position: absolute; left: -9px; top: -22px; border: 9px solid transparent; border-top: 13px solid var(--cyan); filter: drop-shadow(0 0 6px var(--cyan)); }
#h-marker::after { content: attr(data-d); position: absolute; left: 50%; top: -40px; transform: translateX(-50%); font-size: 12px; font-weight: 800; text-shadow: 0 1px 4px #000; white-space: nowrap; }
#h-arrow { position: absolute; left: 0; top: 0; width: 0; height: 0; }
#h-arrow::before { content: ""; position: absolute; left: -12px; top: -10px; border: 10px solid transparent; border-left: 22px solid var(--cyan); filter: drop-shadow(0 0 6px var(--cyan)); }
#h-count { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-family: var(--display); font-size: 120px; color: #fff; text-shadow: 0 6px 0 var(--red), 0 0 40px rgba(0, 0, 0, .5); }
#h-count.beat { animation: beat .6s ease-out; }
@keyframes beat { 0% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
#h-toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 8px 18px; border-radius: 999px; background: rgba(5, 8, 20, .7); font-weight: 700; font-size: 14px; opacity: 0; transition: opacity .3s; }
#h-toast.on { opacity: 1; }

/* ---- タッチ ---- */
#touch { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#stick { position: fixed; display: none; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .06); }
#stick i { position: absolute; left: 34px; top: 34px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .55); }
#tbtns { position: fixed; right: 18px; bottom: 18px; width: 230px; height: 200px; pointer-events: none; }
#tbtns button { position: absolute; pointer-events: auto; border-radius: 50%; color: #fff; font-weight: 900; letter-spacing: .06em; border: 2px solid rgba(255, 255, 255, .5); touch-action: none; }
#tbtns button.on { filter: brightness(1.5); transform: scale(.94); }
#tbtns .lg { right: 0; bottom: 0; width: 104px; height: 104px; font-size: 16px; background: rgba(226, 32, 47, .78); }
#tbtns .md { right: 116px; bottom: 6px; width: 74px; height: 74px; font-size: 13px; background: rgba(31, 63, 168, .75); }
#tbtns .sm { width: 58px; height: 58px; font-size: 11px; background: rgba(20, 24, 40, .7); }
#tbtns [data-k="zip"] { right: 20px; bottom: 118px; }
#tbtns [data-k="dive"] { right: 96px; bottom: 96px; }
body[data-touch="1"] #h-speed { bottom: auto; top: 136px; left: 12px; }
body[data-touch="1"] #h-speed b { font-size: 30px; }
body[data-touch="1"] .t-hint.pc { display: none; }
.t-hint.touch { display: none; }
body[data-touch="1"] .t-hint.touch { display: block; }

/* ---- 一時停止・結果 ---- */
#pause, #result { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(3, 5, 12, .55); backdrop-filter: blur(3px); }
#pause[hidden], #result[hidden], #title[hidden], #hud[hidden], #touch[hidden] { display: none; }
.card { width: min(440px, calc(100vw - 32px)); padding: 26px 28px; border-radius: 18px; background: linear-gradient(160deg, rgba(20, 26, 52, .95), rgba(10, 12, 24, .95)); border: 1px solid rgba(255, 255, 255, .15); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); text-align: center; }
.card h2 { margin: 6px 0 4px; font-family: var(--display); font-size: 34px; letter-spacing: .03em; }
.card p { color: #cdd3f0; }
.r-tag { font-size: 12px; font-weight: 800; letter-spacing: .3em; color: var(--red2); }
#result-big { font-family: var(--display); font-size: 52px; margin: 6px 0 12px; color: var(--gold); }
#result-rows { display: grid; gap: 6px; margin-bottom: 18px; }
#result-rows div { display: flex; justify-content: space-between; padding: 7px 12px; border-radius: 8px; background: rgba(255, 255, 255, .06); font-size: 14px; }
#result-rows b { font-weight: 800; }
.r-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.r-btns button { padding: 11px 18px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .08); color: #fff; font-weight: 800; font-size: 14px; }
.r-btns .primary { background: var(--red); border-color: var(--red2); }
#error { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #0b0f1a; padding: 20px; text-align: center; }
#error[hidden] { display: none; }
#error a { color: var(--gold); }

@media (max-width: 720px) {
  #title { padding: 70px 22px 22px; width: 100vw; background: linear-gradient(180deg, rgba(5, 8, 20, .75), rgba(5, 8, 20, .25) 70%, rgba(5, 8, 20, 0)); }
  .t-logo { font-size: 58px; }
  .t-tag { font-size: 14px; }
  .mode b { font-size: 18px; }
  #minimap { width: 120px; height: 120px; top: 58px; right: 12px; }
  #h-style { top: 186px; left: auto; right: 12px; transform: none; min-width: 0; text-align: right; }
  #h-style .h-row { justify-content: flex-end; }
  #h-mode { top: 54px; left: 10px; }
  .h-big { font-size: 20px; }
  #h-count { font-size: 90px; }
}
@media (max-height: 680px) {
  .t-keys { display: none !important; }
}
@media (max-height: 520px) {
  #title { padding-top: 56px; gap: 8px; }
  .t-logo { font-size: 48px; }
  .t-keys { display: none !important; }
}
