:root {
  --cyan: #6ff3ff;
  --pink: #ff5fa8;
  --gold: #ffd27a;
  --ink: #e9f3ff;
  --dim: #8aa0c0;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: #000;
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none;
}
#stage {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  overflow: hidden; background: #03040a;
}
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud-top {
  position: absolute; left: 0; right: 0; top: 0; padding: 10px 14px 0;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex; justify-content: space-between; align-items: flex-start;
  text-shadow: 0 0 8px rgba(80, 200, 255, .6);
}
.lbl { font-size: 10px; letter-spacing: .25em; color: var(--dim); }
#score, #best { font-size: 20px; font-weight: 700; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
#best { font-size: 14px; color: var(--dim); }
.hud-r { text-align: right; }
.hud-c { padding-top: 6px; }
#mult {
  font-size: 18px; font-weight: 800; color: var(--gold); letter-spacing: .04em;
  text-shadow: 0 0 10px rgba(255, 190, 80, .8); transition: transform .08s;
}
#mult.bump { transform: scale(1.18); }
#hud-sub {
  position: absolute; left: 14px; top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  display: flex; gap: 12px; align-items: center; font-size: 12px;
}
#lives span {
  display: inline-block; width: 12px; height: 14px; margin-right: 3px;
  background: var(--cyan); clip-path: polygon(50% 0, 100% 100%, 50% 78%, 0 100%);
  filter: drop-shadow(0 0 4px var(--cyan));
}
#power { color: #7dffa8; letter-spacing: .15em; font-weight: 700; text-shadow: 0 0 6px #3f9; }

#bossbar {
  position: absolute; left: 14px; right: 14px; top: calc(max(10px, env(safe-area-inset-top)) + 70px);
}
#bossbar .name { font-size: 10px; letter-spacing: .3em; color: var(--pink); margin-bottom: 3px; }
#bossbar .bar { height: 6px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 95, 168, .6); }
#bossbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff3d7f, #ffb36b); box-shadow: 0 0 10px #ff5fa8; transition: width .1s; }

#link {
  position: absolute; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom)); text-align: center;
  font-size: 13px; font-weight: 800; letter-spacing: .3em; color: #9fe9ff; opacity: 0; transition: opacity .15s;
  text-shadow: 0 0 10px rgba(80, 200, 255, .9);
}
#link.on { opacity: 1; }
#link b { font-size: 22px; color: #fff; }
#link small { display: block; font-size: 10px; letter-spacing: .15em; color: var(--gold); margin-top: 2px; }
.aster-pop {
  position: absolute; transform: translate(-50%, -50%); text-align: center; pointer-events: none; white-space: nowrap;
  animation: pop 1.7s ease-out forwards;
}
.aster-pop b {
  display: block; font-size: 24px; font-weight: 900; letter-spacing: .25em; color: #fff;
  text-shadow: 0 0 14px #6ff3ff, 0 0 30px #3aa0ff;
}
.aster-pop small { display: block; font-size: 11px; letter-spacing: .12em; color: var(--gold); margin-top: 3px; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%); } }
#nova {
  position: absolute; right: 14px; bottom: max(18px, env(safe-area-inset-bottom)); width: 76px; height: 76px;
  border: 0; background: rgba(10, 14, 30, .45); border-radius: 50%; color: var(--dim);
  pointer-events: auto; font-weight: 800; font-size: 12px; letter-spacing: .15em; touch-action: none;
}
#nova svg { position: absolute; inset: 0; transform: rotate(-90deg); }
#nova circle { fill: none; stroke-width: 6; }
#nova .track { stroke: rgba(255, 255, 255, .12); }
#nova .fill { stroke: var(--pink); stroke-dasharray: 276.5; stroke-dashoffset: 276.5; stroke-linecap: round; filter: drop-shadow(0 0 4px var(--pink)); }
#nova span { position: relative; }
#nova.ready { color: #fff; background: rgba(255, 60, 150, .35); animation: pulse 0.9s infinite; }
#nova.ready .fill { stroke: #fff; }
@keyframes pulse { 50% { box-shadow: 0 0 26px 6px rgba(255, 95, 168, .7); } }

#pause-btn {
  position: absolute; right: 14px; top: calc(max(10px, env(safe-area-inset-top)) + 44px); width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(0, 0, 0, .3); color: var(--ink);
  font-weight: 800; font-size: 11px; pointer-events: auto;
}

#msg {
  position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none;
  font-size: 30px; font-weight: 900; letter-spacing: .3em; opacity: 0;
  text-shadow: 0 0 18px rgba(110, 240, 255, .9);
}
#msg.show { animation: msg 2.6s ease-out forwards; }
#msg.warn { color: #ff6a8a; text-shadow: 0 0 22px rgba(255, 40, 90, 1); }
#msg.warn.show { animation: warn 3.2s linear forwards; }
#msg small { display: block; font-size: 12px; letter-spacing: .4em; margin-top: 8px; opacity: .8; }
@keyframes msg { 0% { opacity: 0; transform: scale(1.4); letter-spacing: .8em; } 12% { opacity: 1; transform: none; letter-spacing: .3em; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes warn { 0%, 20%, 40%, 60%, 80% { opacity: 1; } 10%, 30%, 50%, 70% { opacity: .15; } 100% { opacity: 0; } }

#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }

/* ---------------- 画面 */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px;
}
#title { justify-content: flex-start; padding-top: 18vh; background: radial-gradient(ellipse at 50% 30%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, .5)); }
#pause, #result { background: rgba(2, 3, 10, .72); backdrop-filter: blur(4px); }
#loading { background: #03040a; }
.logo {
  font-size: min(46px, 11vw); font-weight: 900; letter-spacing: .22em; padding-left: .22em;
  background: linear-gradient(180deg, #fff 20%, #8ff6ff 60%, #ff8cc6); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(110, 230, 255, .7));
}
.logo.small { font-size: 30px; }
.sub { font-size: 12px; letter-spacing: .35em; color: var(--dim); }
.start { margin-top: 34vh; font-size: 16px; font-weight: 700; letter-spacing: .4em; color: #fff; text-shadow: 0 0 10px var(--cyan); }
.blink { animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.howto { font-size: 12px; line-height: 1.8; color: var(--dim); max-width: 100%; }
.howto p { margin-bottom: 2px; }
.howto b { color: var(--ink); }
.hi { font-size: 12px; letter-spacing: .2em; color: var(--gold); }
button.big, button.small {
  pointer-events: auto; border: 1px solid rgba(111, 243, 255, .6); background: rgba(10, 30, 50, .6); color: #fff;
  font-weight: 700; letter-spacing: .15em; border-radius: 4px; font-family: inherit;
}
button.big { font-size: 16px; padding: 12px 34px; box-shadow: 0 0 16px rgba(111, 243, 255, .35); }
button.small { font-size: 11px; padding: 7px 16px; opacity: .8; }
#result-table { border-collapse: collapse; font-size: 14px; min-width: 240px; }
#result-table td { padding: 5px 8px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
#result-table td:first-child { text-align: left; color: var(--dim); letter-spacing: .1em; }
#result-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.total { font-size: 22px; font-weight: 800; color: var(--gold); letter-spacing: .1em; }
#result-new { color: var(--pink); font-weight: 900; letter-spacing: .3em; animation: blink .8s infinite; }

/* ---------------- HOLDFIRE */
#title { justify-content: flex-start; padding-top: 9vh; background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,0) 30%, rgba(0,0,0,0) 55%, rgba(0,0,0,.7)); }
#title .start { margin-top: 44vh; }
.logo { background: linear-gradient(180deg, #fff 25%, #9fe9ff 60%, #4aa8ff); -webkit-background-clip: text; background-clip: text; }
#mode { font-size: 12px; font-weight: 800; letter-spacing: .2em; color: #c9a45a; text-shadow: 0 0 6px rgba(255, 190, 80, .5); }
#mode.lv1 { color: #8fe6ff; text-shadow: 0 0 8px #3bd; }
#mode.lv2 { color: #bff2ff; text-shadow: 0 0 10px #4cf; }
#mode.lv3 { color: #fff; text-shadow: 0 0 12px #6ff, 0 0 24px #39f; animation: blink .25s infinite; }
#hint {
  position: absolute; left: 0; right: 0; bottom: max(26px, env(safe-area-inset-bottom)); text-align: center;
  font-size: 13px; letter-spacing: .12em; color: var(--dim); opacity: 0; transition: opacity .6s;
  text-shadow: 0 0 8px #000;
}
#hint.on { opacity: 1; }
#hint b { color: #9fe9ff; }
.pop {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  font-weight: 900; letter-spacing: .12em; font-size: 15px; color: #ffe9a8; text-shadow: 0 0 8px #fa4;
  animation: popup .9s ease-out forwards;
}
.pop.mult3 { font-size: 18px; color: #dff6ff; text-shadow: 0 0 10px #4cf; }
.pop.mult4 { font-size: 22px; color: #fff; text-shadow: 0 0 12px #6ff, 0 0 26px #39f; }
.pop.lv2, .pop.lv3 { font-size: 16px; letter-spacing: .3em; color: #bff2ff; text-shadow: 0 0 12px #4cf; }
.pop.lv3 { font-size: 22px; color: #fff; text-shadow: 0 0 14px #6ff, 0 0 30px #39f; }
@keyframes popup { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -120%); } }

/* ---------------- 機体選択・ランク */
#title { padding-top: 6vh; gap: 10px; }
#title .start { margin-top: 30vh; }
#ship-sel { display: flex; align-items: center; gap: 8px; margin-top: 4px; pointer-events: auto; }
#ship-sel button {
  width: 40px; height: 56px; border: 1px solid rgba(111, 243, 255, .5); background: rgba(10, 30, 50, .55); color: #fff;
  font-size: 26px; border-radius: 6px; font-family: inherit; line-height: 1;
}
.ship-card { width: 236px; padding: 8px 10px; background: rgba(4, 10, 22, .55); border: 1px solid rgba(255, 255, 255, .12); border-radius: 6px; }
#ship-name { font-size: 20px; font-weight: 900; letter-spacing: .3em; padding-left: .3em; color: #fff; text-shadow: 0 0 10px #4cf; }
#ship-desc { font-size: 11px; color: var(--dim); margin: 3px 0 6px; min-height: 2.6em; line-height: 1.3; }
#ship-stats div { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--dim); margin: 2px 0; }
#ship-stats i { display: flex; gap: 3px; }
#ship-stats b, #ship-stats u { display: block; width: 16px; height: 6px; border-radius: 1px; background: #6ff3ff; box-shadow: 0 0 5px #6ff3ff; }
#ship-stats u { background: rgba(255, 255, 255, .13); box-shadow: none; }
#ship-rec { font-size: 10px; letter-spacing: .1em; color: var(--gold); margin-top: 6px; }
.howto { font-size: 11px; line-height: 1.6; }
.rank {
  font-size: 84px; font-weight: 900; line-height: 1; color: #fff; text-shadow: 0 0 18px #6ff3ff, 0 0 44px #39f;
  animation: rankin .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
.rank.rS { color: #fff3c0; text-shadow: 0 0 18px #ffd27a, 0 0 46px #ff9d2e; }
.rank.rA { color: #dff6ff; }
.rank.rB { color: #b9c9dd; text-shadow: 0 0 12px #68a; }
.rank.rC { color: #8a97aa; text-shadow: none; }
@keyframes rankin { 0% { transform: scale(3); opacity: 0; } 100% { transform: none; opacity: 1; } }
#result-nomiss { color: var(--gold); font-weight: 900; letter-spacing: .4em; font-size: 14px; }
#result { gap: 10px; }
#result-table { font-size: 12px; }
#result-table td { padding: 3px 8px; }

/* ---------------- ランキング */
.row { display: flex; gap: 8px; pointer-events: auto; }
.rk-entry { display: flex; gap: 6px; align-items: center; pointer-events: auto; }
.rk-entry input {
  width: 130px; padding: 7px 8px; font-size: 14px; font-family: inherit; color: #fff; text-align: center;
  background: rgba(0, 0, 0, .5); border: 1px solid rgba(111, 243, 255, .5); border-radius: 4px; user-select: text; -webkit-user-select: text;
}
#rank-panel { background: rgba(2, 3, 10, .92); z-index: 5; gap: 10px; }
#rank-list { width: 100%; max-width: 340px; pointer-events: auto; }
table.rk { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rk td { padding: 5px 4px; border-bottom: 1px solid rgba(255, 255, 255, .08); text-align: left; }
table.rk td:first-child { width: 22px; color: var(--gold); font-weight: 800; }
table.rk td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
table.rk td:nth-child(4) { text-align: right; font-size: 10px; color: var(--dim); }
table.rk tr.me td { color: #fff; background: rgba(111, 243, 255, .14); }
.rk-empty { color: var(--dim); font-size: 13px; padding: 20px; }

/* ---------------- THREADLINE（よけるだけのゲーム） */
.dodge .logo { font-size: min(40px, 9.6vw); background: linear-gradient(180deg, #fff 25%, #ffd9f0 60%, #ff6fb0); -webkit-background-clip: text; background-clip: text; }
#graze { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: #9fe9ff; text-shadow: 0 0 6px #3bd; }
#wavebar { position: absolute; left: 14px; right: 58px; top: calc(max(10px, env(safe-area-inset-top)) + 70px); }
#wavebar .name { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .25em; color: #ffb3d6; margin-bottom: 3px; }
#wavebar .name span:last-child { color: var(--dim); letter-spacing: .1em; }
#wavebar .bar { height: 5px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 120, 180, .5); }
#wavebar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6ff3ff, #ff6fb0); box-shadow: 0 0 8px #ff6fb0; }
.dodge #ship-desc { min-height: 0; }

/* ---------------- ホームに戻る */
a.home {
  pointer-events: auto; display: inline-block; text-decoration: none; color: #fff; font-size: 11px; font-weight: 700;
  letter-spacing: .15em; padding: 7px 16px; border: 1px solid rgba(111, 243, 255, .6); background: rgba(10, 30, 50, .6);
  border-radius: 4px; opacity: .8;
}

/* ---------------- モード選択（最初の画面） */
#boot { background: radial-gradient(ellipse at 50% 20%, #0c1830, #03040a 70%); gap: 16px; }
.mode-btn {
  width: min(320px, 86%); padding: 16px 14px; text-align: left; font-family: inherit; color: #fff; cursor: pointer;
  background: rgba(10, 30, 50, .6); border: 1px solid rgba(111, 243, 255, .6); border-radius: 8px;
  box-shadow: 0 0 18px rgba(111, 243, 255, .25);
}
.mode-btn b { display: block; font-size: 20px; letter-spacing: .25em; text-shadow: 0 0 10px #4cf; }
.mode-btn span { display: block; font-size: 12px; line-height: 1.5; color: var(--dim); margin-top: 6px; }
.mode-btn.pink { border-color: rgba(255, 120, 180, .7); box-shadow: 0 0 18px rgba(255, 110, 176, .25); }
.mode-btn.pink b { text-shadow: 0 0 10px #ff6fb0; }
.dodge .logo { font-size: min(46px, 11vw); }
