@font-face {
  font-family: "Oxanium";
  src: url("../../assets/fonts/oxanium.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "M PLUS 1";
  src: url("../../assets/fonts/mplus1-subset.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #e8f1ff;
  --dim: #8fa3c4;
  --accent: #49e6ff;
  --accent2: #ff7ad9;
  --danger: #ff5a3a;
  --panel: rgba(6, 12, 28, 0.82);
  --line: rgba(120, 180, 255, 0.35);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #02030a;
  color: var(--ink);
  font-family: "Oxanium", "M PLUS 1", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hidden {
  display: none !important;
}
button,
select {
  font: inherit;
  color: var(--ink);
  background: rgba(20, 40, 80, 0.7);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  min-height: 44px;
}
button:hover {
  border-color: var(--accent);
}
button.primary {
  background: linear-gradient(180deg, #1d6fd6, #0f3f8a);
  border-color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.icon-btn {
  min-width: 44px;
  padding: 6px 10px;
}

#overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
/* コンボ(右の真ん中)。下の細いバーは、次を倒すまでの残り時間 */
#combo {
  position: fixed;
  right: 18px;
  top: 38%;
  text-align: right;
  pointer-events: none;
  font-family: Oxanium, sans-serif;
  color: #ffd23a;
  text-shadow: 0 0 10px rgba(255, 154, 0, 0.8);
}
#combo-n {
  display: block;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
}
#combo .combo-label {
  font-size: 13px;
  letter-spacing: 0.3em;
}
#combo-time {
  margin-top: 4px;
  margin-left: auto;
  height: 3px;
  width: 90px;
  background: #ffd23a;
  transform-origin: right;
}
#flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#rewind-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  opacity: 0;
  background: rgba(150, 200, 255, 0.35);
  mix-blend-mode: difference;
}
#rewind-fx.on {
  animation: rewind 0.9s ease-out;
}
#rewind-fx span {
  font-size: clamp(40px, 10vw, 110px);
  letter-spacing: 0.2em;
  color: #fff;
  font-weight: 700;
}
@keyframes rewind {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#stick {
  position: fixed;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 2px solid rgba(160, 210, 255, 0.35);
  display: none;
  pointer-events: none;
}
#stick-knob {
  position: absolute;
  left: 36px;
  top: 36px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(160, 210, 255, 0.45);
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.hud-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.hud-block {
  flex: 1;
  min-width: 0;
}
.hud-block.right {
  text-align: right;
}
.hud-time {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 0 12px rgba(73, 230, 255, 0.6);
}
#pause-btn {
  pointer-events: auto;
}
/* 視点の切り替え(ポーズの下)。キーボードでは V */
#camera-btn {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  right: max(14px, env(safe-area-inset-right));
  pointer-events: auto;
  font-size: 12px;
}
/* SHIELD のバー: 自機の下にぶら下げる(左上の位置は src/view/overlay.js が transform で動かす) */
#ship-shield {
  position: fixed;
  left: 0;
  top: 0;
  width: 64px;
  will-change: transform;
}
#ship-shield .bar {
  height: 6px;
  margin: 0;
  max-width: none;
  background: rgba(0, 10, 30, 0.55);
}
/* 主観の視点では、画面の下(経験値のバーの上)の決まった位置 */
#ship-shield.cockpit {
  left: 50%;
  top: auto;
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 64px);
  width: 180px;
  transform: translateX(-50%);
}
#ship-shield.cockpit .bar {
  height: 8px;
}
.label {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.12em;
}
.label span {
  color: var(--ink);
  font-size: 15px;
}
.bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 3px;
}
.bar > div {
  height: 100%;
  width: 100%;
  transition: width 0.15s;
}
.bar.shield > div {
  background: linear-gradient(90deg, #2f8cff, #8fe6ff);
}
.bar.xp > div {
  background: linear-gradient(90deg, #ff9a00, #ffd23a); /* 経験値は金色(画面の経験値と同じ色) */
}
.bar.boss > div {
  background: linear-gradient(90deg, #ff3a1a, #ffb040);
}
.shield {
  max-width: 260px;
}
#boss-bar {
  margin: 10px auto 0;
  max-width: 520px;
  text-align: center;
}
.hud-bottom {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hud-bottom .bar.xp {
  flex: 1;
  min-width: 120px;
  height: 10px;
}
.lv {
  font-weight: 700;
}
#weapons {
  width: 100%;
  font-size: 12px;
  color: var(--dim);
}

/* オペレーター */
#operator {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: 64px;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: min(420px, calc(100vw - 28px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px 8px 8px;
  pointer-events: none;
  font-family: "M PLUS 1", system-ui, sans-serif;
  font-size: 14px;
}
#operator img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
}
.op-name {
  font-family: "Oxanium", sans-serif;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.2em;
}

/* 画面いっぱいのパネル */
.panel-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(4, 10, 30, 0.55), rgba(0, 0, 0, 0.85));
  text-align: center;
}
.panel-screen button {
  min-width: 220px;
}
.panel-title {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-shadow: 0 0 18px rgba(73, 230, 255, 0.7);
}
.panel-title.danger {
  color: var(--danger);
  text-shadow: 0 0 18px rgba(255, 90, 58, 0.7);
}
.title-logo {
  font-size: clamp(40px, 11vw, 96px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 24px rgba(73, 230, 255, 0.8);
}
.title-logo span {
  color: var(--accent2);
}
.subtitle {
  color: var(--dim);
  letter-spacing: 0.3em;
  margin-bottom: 12px;
  font-family: "M PLUS 1", system-ui, sans-serif;
}
.howto {
  color: var(--dim);
  font-size: 13px;
  font-family: "M PLUS 1", system-ui, sans-serif;
}
.howto p {
  margin: 4px 0;
}
.sister {
  color: var(--accent);
  font-size: 13px;
  font-family: "M PLUS 1", system-ui, sans-serif;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#choices {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
}
.choice {
  width: min(260px, calc(100vw - 32px));
  min-height: 120px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(20, 50, 100, 0.85), rgba(8, 18, 40, 0.9));
  font-family: "M PLUS 1", system-ui, sans-serif;
}
.choice .name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.choice .lvl {
  font-family: "Oxanium", sans-serif;
  color: var(--accent);
  font-size: 13px;
}
.choice .desc {
  color: var(--dim);
  font-size: 13px;
}
.choice .key {
  margin-left: auto;
  color: var(--dim);
  font-size: 11px;
}

/* リプレイ */
#replay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
}
.replay-head {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 28px;
  letter-spacing: 0.3em;
  color: #9fd8ff;
  text-shadow: 0 0 14px rgba(120, 200, 255, 0.8);
}
.replay-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}
#replay-seek {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  height: 32px;
}
.replay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.result-face {
  width: 96px;
  height: 96px;
  border-radius: 10px;
}
.result-text {
  font-family: "M PLUS 1", system-ui, sans-serif;
  max-width: 420px;
}
.result-stats {
  color: var(--dim);
  line-height: 1.7;
}
.credits {
  position: absolute;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  font-size: 11px;
  color: var(--dim);
  font-family: "M PLUS 1", system-ui, sans-serif;
}

/* 回復の表示(SHIELDのバーの下に「SHIELD +25」) */
#heal-pop {
  position: absolute;
  top: max(44px, calc(env(safe-area-inset-top) + 34px));
  left: max(14px, env(safe-area-inset-left));
  color: #5dff8a;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 10px rgba(93, 255, 138, 0.8);
  animation: heal-pop 1.4s ease-out forwards;
}
@keyframes heal-pop {
  0% { transform: translateY(6px) scale(1.3); opacity: 0; }
  15% { transform: translateY(0) scale(1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-10px); opacity: 0; }
}
.bar.shield.healing {
  box-shadow: 0 0 14px rgba(93, 255, 138, 0.9);
  border-color: #5dff8a;
}

/* ステージの見出し */
#stage-banner {
  position: absolute;
  top: 26%;
  left: 0;
  right: 0;
  text-align: center;
  animation: stage-in 3.2s ease-out forwards;
}
.stage-no {
  color: var(--accent);
  letter-spacing: 0.5em;
  font-size: 14px;
}
.stage-name {
  font-size: clamp(26px, 6vw, 52px);
  font-weight: 700;
  letter-spacing: 0.25em;
  text-shadow: 0 0 20px rgba(73, 230, 255, 0.7);
}
@keyframes stage-in {
  0% { opacity: 0; letter-spacing: 0.6em; }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* 強化を選んだときの一言(何が変わったか) */
#toast {
  position: absolute;
  bottom: 70px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100vw - 32px);
  padding: 8px 16px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: "M PLUS 1", system-ui, sans-serif;
  animation: toast 2.4s ease-out forwards;
}
@keyframes toast {
  0% { opacity: 0; transform: translateY(8px); }
  10% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* 停止戦の残りの敵の数 */
#hold-left {
  position: absolute;
  top: max(52px, calc(env(safe-area-inset-top) + 42px));
  left: 0;
  right: 0;
  text-align: center;
  color: #ffb040;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.12em;
  text-shadow: 0 0 10px rgba(255, 140, 40, 0.7);
}
