/* ===== スターレイダー Star Raider ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --cyan: #4de8ff;
  --cyan-dim: #1a8fb0;
  --gold: #ffd54d;
  --red: #ff4d6a;
  --violet: #b57bff;
  --panel: rgba(10, 18, 38, 0.86);
  --panel-line: rgba(77, 232, 255, 0.35);
  --text: #d9f4ff;
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #04060f;
  font-family: var(--font);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 70% 55% at 18% 12%, rgba(38, 22, 78, 0.55), transparent 65%),
    radial-gradient(ellipse 60% 50% at 85% 80%, rgba(10, 55, 80, 0.5), transparent 65%),
    radial-gradient(ellipse 40% 35% at 70% 20%, rgba(90, 25, 70, 0.28), transparent 70%),
    #04060f;
}

#game-wrap {
  position: relative;
  height: min(97vh, 920px);
  aspect-ratio: 640 / 880;
  max-width: 98vw;
  box-shadow: 0 0 60px rgba(30, 120, 180, 0.28), 0 0 0 1px rgba(77, 232, 255, 0.18);
  border-radius: 10px;
  overflow: hidden;
  background: #060a18;
}
@media (max-aspect-ratio: 640/880) {
  #game-wrap { width: 100vw; height: auto; aspect-ratio: 640 / 880; max-height: 100vh; }
}

#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

.hidden { display: none !important; }

/* ===== 低体力警告ビネット ===== */
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, rgba(255, 30, 50, 0.55) 100%);
  opacity: 0; transition: opacity 0.35s;
}

/* ===== HUD ===== */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 6; }

#hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 14px;
}
#hud-score {
  font-size: clamp(20px, 3.4vh, 30px); font-weight: 800; letter-spacing: 1px;
  color: #fff; text-shadow: 0 0 12px rgba(77, 232, 255, 0.9), 0 2px 3px rgba(0,0,0,.6);
  font-variant-numeric: tabular-nums;
}
#hud-combo {
  font-size: clamp(12px, 1.8vh, 16px); font-weight: 700; color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 213, 77, 0.8); margin-top: 2px;
}
#hud-wave-box { text-align: right; }
#hud-wave {
  font-size: clamp(14px, 2.2vh, 19px); font-weight: 700; color: var(--cyan);
  text-shadow: 0 0 10px rgba(77, 232, 255, 0.7);
}
#hud-hiscore { font-size: clamp(10px, 1.5vh, 13px); color: rgba(217, 244, 255, 0.55); margin-top: 3px; }

#boss-bar-wrap {
  position: absolute; top: clamp(48px, 8vh, 72px); left: 50%; transform: translateX(-50%);
  width: 72%; text-align: center;
}
#boss-name {
  font-size: clamp(11px, 1.7vh, 14px); font-weight: 700; color: #ffb3c0;
  text-shadow: 0 0 8px rgba(255, 77, 106, 0.8); margin-bottom: 4px; letter-spacing: 2px;
}
#boss-bar {
  position: relative; height: 10px; border-radius: 5px;
  background: rgba(60, 8, 20, 0.8); border: 1px solid rgba(255, 77, 106, 0.5);
  overflow: hidden;
}
#boss-bar-fill {
  height: 100%; width: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #ff2d55, #ff7a5c, #ffb84d);
  box-shadow: 0 0 10px rgba(255, 60, 80, 0.9);
  transition: width 0.15s linear;
}
.boss-notch { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.55); }

#hud-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 10px 14px;
}
#hud-hp { display: flex; gap: 4px; margin-bottom: 6px; }
.hp-cell {
  width: clamp(14px, 2.2vh, 19px); height: clamp(14px, 2.2vh, 19px);
  clip-path: polygon(50% 0, 100% 28%, 100% 72%, 50% 100%, 0 72%, 0 28%);
  background: linear-gradient(180deg, #ff6b81, #d61f3e);
  box-shadow: 0 0 8px rgba(255, 60, 90, 0.7);
}
.hp-cell.off { background: rgba(120, 40, 55, 0.35); box-shadow: none; }
#hud-shield {
  width: clamp(90px, 16vh, 140px); height: 8px; border-radius: 4px;
  background: rgba(15, 40, 60, 0.8); border: 1px solid rgba(77, 232, 255, 0.4);
  overflow: hidden;
}
#hud-shield-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #2bb8e6, #7df3ff);
  box-shadow: 0 0 8px rgba(77, 232, 255, 0.9);
  transition: width 0.12s linear;
}
#hud-right { text-align: right; }
#hud-bombs { display: flex; gap: 3px; justify-content: flex-end; margin-bottom: 5px; font-size: clamp(13px, 2vh, 17px); }
.bomb-cell { filter: drop-shadow(0 0 4px rgba(255, 180, 60, 0.8)); }
#hud-coins {
  display: flex; align-items: center; gap: 5px; justify-content: flex-end;
  font-size: clamp(13px, 2vh, 17px); font-weight: 700; color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 213, 77, 0.5);
}
.coin-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff2b0, #ffd54d 45%, #b8860b);
  box-shadow: 0 0 6px rgba(255, 213, 77, 0.8);
}

#hud-upgrades {
  position: absolute; left: 8px; top: 20%;
  display: flex; flex-direction: column; gap: 5px; max-height: 55%; flex-wrap: wrap;
}
.up-icon {
  position: relative; width: clamp(24px, 3.6vh, 32px); height: clamp(24px, 3.6vh, 32px);
  border-radius: 7px; background: rgba(12, 30, 55, 0.85);
  border: 1px solid var(--panel-line);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(13px, 2vh, 17px);
  box-shadow: 0 0 6px rgba(77, 232, 255, 0.25);
}
.up-icon .up-n {
  position: absolute; right: -4px; bottom: -4px;
  background: var(--cyan); color: #03202c; font-size: 10px; font-weight: 800;
  min-width: 14px; height: 14px; line-height: 14px; border-radius: 7px; text-align: center;
  padding: 0 2px;
}

#btn-pause {
  position: absolute; top: clamp(44px, 7.5vh, 66px); right: 12px;
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(12, 30, 55, 0.7); border: 1px solid var(--panel-line);
  color: var(--cyan); font-size: 14px; font-weight: 800; cursor: pointer;
  pointer-events: auto; font-family: var(--font);
}
#btn-pause:hover { background: rgba(30, 70, 110, 0.85); }

#btn-bomb {
  position: absolute; right: 14px; bottom: 72px; z-index: 7;
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(60, 90, 130, 0.9), rgba(15, 30, 60, 0.9));
  border: 2px solid rgba(255, 190, 80, 0.7);
  font-size: 24px; cursor: pointer; color: #fff;
  box-shadow: 0 0 14px rgba(255, 170, 60, 0.45);
}
#btn-bomb:active { transform: scale(0.92); }
#bomb-btn-count {
  position: absolute; right: 0; top: -4px; background: var(--gold); color: #402c00;
  font-size: 12px; font-weight: 800; min-width: 18px; height: 18px; line-height: 18px;
  border-radius: 9px; font-family: var(--font);
}

/* ===== ウェーブバナー / ヒント ===== */
#wave-banner {
  position: absolute; top: 34%; left: 0; right: 0; text-align: center; z-index: 8;
  font-size: clamp(26px, 4.5vh, 40px); font-weight: 900; letter-spacing: 8px;
  color: #fff; text-shadow: 0 0 24px var(--cyan), 0 0 60px rgba(77, 232, 255, 0.6);
  pointer-events: none; animation: bannerIn 0.5s cubic-bezier(.2,1.4,.4,1);
}
#wave-banner.boss-warn { color: #ffccd5; text-shadow: 0 0 24px var(--red), 0 0 60px rgba(255, 45, 85, 0.7); animation: bossFlash 0.5s infinite alternate; }
@keyframes bannerIn { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bossFlash { from { opacity: 0.6; } to { opacity: 1; } }

#hint-text {
  position: absolute; bottom: 22%; left: 0; right: 0; text-align: center; z-index: 8;
  font-size: clamp(13px, 2vh, 16px); color: rgba(217, 244, 255, 0.9);
  text-shadow: 0 0 10px rgba(77, 232, 255, 0.6); pointer-events: none;
  animation: hintFade 0.6s;
}
@keyframes hintFade { from { opacity: 0; transform: translateY(10px); } }

/* ===== オーバーレイ共通 ===== */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 1.6vh, 16px); padding: 20px;
  background: rgba(4, 8, 20, 0.78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
}
.screen-h2 {
  font-size: clamp(22px, 3.8vh, 32px); font-weight: 900; letter-spacing: 6px;
  color: #fff; text-shadow: 0 0 18px rgba(77, 232, 255, 0.8);
}
.pulse-h2 { animation: h2pulse 1.4s ease-in-out infinite; }
@keyframes h2pulse { 0%,100% { text-shadow: 0 0 12px rgba(77,232,255,.6); } 50% { text-shadow: 0 0 28px rgba(77,232,255,1); } }

.menu-col { display: flex; flex-direction: column; gap: clamp(8px, 1.4vh, 14px); align-items: center; }

.btn {
  font-family: var(--font);
  min-width: 200px; padding: clamp(9px, 1.5vh, 13px) 28px;
  font-size: clamp(14px, 2.1vh, 18px); font-weight: 700; letter-spacing: 3px;
  color: var(--text); cursor: pointer;
  background: linear-gradient(180deg, rgba(28, 60, 100, 0.85), rgba(12, 28, 58, 0.85));
  border: 1px solid var(--panel-line); border-radius: 10px;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 18px rgba(77, 232, 255, 0.3); background: linear-gradient(180deg, rgba(40, 85, 135, 0.9), rgba(18, 40, 78, 0.9)); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn.big { font-size: clamp(17px, 2.6vh, 22px); padding: clamp(12px, 1.9vh, 16px) 40px; }
.btn.small { min-width: 150px; font-size: clamp(12px, 1.8vh, 15px); padding: 8px 20px; }
.btn.glow {
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(77, 232, 255, 0.4), inset 0 0 12px rgba(77, 232, 255, 0.12);
  animation: btnGlow 2s ease-in-out infinite;
}
@keyframes btnGlow { 0%,100% { box-shadow: 0 0 12px rgba(77,232,255,.3); } 50% { box-shadow: 0 0 26px rgba(77,232,255,.65); } }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

/* ===== タイトル ===== */
#screen-title { gap: clamp(6px, 1.2vh, 12px); }
.title-star-deco {
  width: 76px; height: 76px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, #cfffff, #4de8ff 40%, #1550a0 75%, #0a1e3f);
  box-shadow: 0 0 40px rgba(77, 232, 255, 0.7), 0 0 90px rgba(77, 232, 255, 0.3);
  animation: planetFloat 4s ease-in-out infinite;
}
@keyframes planetFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
#game-logo {
  font-size: clamp(38px, 7vh, 60px); font-weight: 900; letter-spacing: 12px;
  background: linear-gradient(180deg, #fff, #7df3ff 55%, #2b8fd6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 22px rgba(77, 232, 255, 0.55));
}
#game-sub { font-size: clamp(11px, 1.7vh, 14px); letter-spacing: 4px; color: rgba(217, 244, 255, 0.6); margin-top: -6px; }
#title-meta-coins {
  display: flex; align-items: center; gap: 6px;
  font-size: clamp(13px, 2vh, 16px); font-weight: 700; color: var(--gold);
  background: rgba(50, 38, 8, 0.5); border: 1px solid rgba(255, 213, 77, 0.35);
  padding: 5px 16px; border-radius: 20px;
}
#help-box {
  max-width: 82%; text-align: center;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
  padding: clamp(8px, 1.6vh, 14px) 18px;
  font-size: clamp(11px, 1.65vh, 13.5px); line-height: 1.85; color: rgba(217, 244, 255, 0.85);
}
.help-title { color: var(--cyan); font-weight: 700; letter-spacing: 3px; margin-bottom: 2px; }
#title-best { font-size: clamp(11px, 1.7vh, 14px); color: rgba(217, 244, 255, 0.55); }

/* ===== アップグレードカード ===== */
#upgrade-cards { display: flex; gap: clamp(10px, 2vw, 18px); justify-content: center; flex-wrap: wrap; width: 100%; }
.up-card {
  width: clamp(140px, 26%, 172px); min-height: clamp(180px, 30vh, 230px);
  background: linear-gradient(165deg, rgba(20, 45, 85, 0.95), rgba(8, 18, 40, 0.95));
  border: 1px solid var(--panel-line); border-radius: 14px;
  padding: 16px 12px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  animation: cardIn 0.4s cubic-bezier(.2,1.5,.4,1) backwards;
}
.up-card:nth-child(2) { animation-delay: 0.08s; }
.up-card:nth-child(3) { animation-delay: 0.16s; }
@keyframes cardIn { from { transform: translateY(40px) scale(0.8); opacity: 0; } }
.up-card:hover { transform: translateY(-8px) scale(1.04); box-shadow: 0 10px 30px rgba(77, 232, 255, 0.35); border-color: var(--cyan); }
.up-card.rare { border-color: rgba(181, 123, 255, 0.6); }
.up-card.rare:hover { border-color: var(--violet); box-shadow: 0 10px 30px rgba(181, 123, 255, 0.4); }
.up-card .card-icon { font-size: clamp(30px, 5vh, 42px); filter: drop-shadow(0 0 10px rgba(77, 232, 255, 0.5)); }
.up-card .card-name { font-size: clamp(14px, 2.2vh, 17px); font-weight: 800; color: #fff; letter-spacing: 1px; }
.up-card .card-rarity { font-size: 10px; letter-spacing: 2px; color: var(--cyan-dim); }
.up-card.rare .card-rarity { color: var(--violet); }
.up-card .card-desc { font-size: clamp(11px, 1.7vh, 13px); line-height: 1.6; color: rgba(217, 244, 255, 0.8); flex: 1; }
.up-card .card-lv { font-size: 11px; color: var(--gold); }
#upgrade-tip { font-size: clamp(11px, 1.6vh, 13px); color: rgba(217, 244, 255, 0.5); }

/* ===== ショップ ===== */
#shop-coins { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--gold); font-size: clamp(14px, 2.2vh, 17px); }
#shop-items { display: flex; flex-direction: column; gap: 10px; width: min(86%, 440px); }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
  padding: 10px 14px;
}
.shop-item .si-icon { font-size: 26px; width: 40px; text-align: center; }
.shop-item .si-mid { flex: 1; }
.shop-item .si-name { font-weight: 800; font-size: clamp(13px, 2vh, 16px); color: #fff; }
.shop-item .si-desc { font-size: clamp(10px, 1.6vh, 12.5px); color: rgba(217, 244, 255, 0.65); margin-top: 2px; }
.si-pips { display: flex; gap: 4px; margin-top: 5px; }
.si-pip { width: 26px; height: 6px; border-radius: 3px; background: rgba(77, 232, 255, 0.15); }
.si-pip.on { background: var(--cyan); box-shadow: 0 0 6px rgba(77, 232, 255, 0.7); }
.si-buy {
  font-family: var(--font); min-width: 86px; padding: 8px 10px;
  font-size: 13px; font-weight: 700; color: #2b1e00; cursor: pointer;
  background: linear-gradient(180deg, #ffe082, #ffb830); border: none; border-radius: 9px;
}
.si-buy:hover { filter: brightness(1.1); }
.si-buy:disabled { background: rgba(120, 120, 120, 0.3); color: rgba(255,255,255,0.4); cursor: default; }

/* ===== ランキング ===== */
#board-list { width: min(88%, 460px); display: flex; flex-direction: column; gap: 6px; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid rgba(77, 232, 255, 0.18); border-radius: 10px;
  padding: 8px 14px; font-size: clamp(12px, 1.9vh, 15px);
}
.board-row.top1 { border-color: var(--gold); box-shadow: 0 0 12px rgba(255, 213, 77, 0.25); }
.board-row .b-rank { width: 34px; font-weight: 900; color: var(--cyan); }
.board-row.top1 .b-rank { color: var(--gold); }
.board-row .b-score { flex: 1; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.board-row .b-wave { width: 74px; color: rgba(217, 244, 255, 0.75); }
.board-row .b-date { width: 92px; text-align: right; color: rgba(217, 244, 255, 0.45); font-size: 0.85em; }
.board-empty { text-align: center; color: rgba(217, 244, 255, 0.5); padding: 30px 0; }

/* ===== 実績 ===== */
#achv-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: min(90%, 500px); }
.achv-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid rgba(77, 232, 255, 0.18); border-radius: 10px;
  padding: 9px 12px;
}
.achv-item.done { border-color: rgba(255, 213, 77, 0.55); }
.achv-item .a-icon { font-size: 22px; filter: grayscale(1) opacity(0.4); }
.achv-item.done .a-icon { filter: none; }
.achv-item .a-name { font-size: clamp(12px, 1.8vh, 14px); font-weight: 700; color: #fff; }
.achv-item .a-desc { font-size: clamp(10px, 1.5vh, 12px); color: rgba(217, 244, 255, 0.55); margin-top: 2px; }

/* ===== リザルト ===== */
#over-title.win { color: #b9ffd0; text-shadow: 0 0 20px rgba(80, 255, 150, 0.7); }
#over-newrecord {
  color: var(--gold); font-weight: 900; letter-spacing: 4px; font-size: clamp(15px, 2.4vh, 20px);
  animation: h2pulse 1s infinite; text-shadow: 0 0 14px rgba(255, 213, 77, 0.9);
}
#over-stats {
  width: min(80%, 380px); background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: clamp(10px, 2vh, 18px) 24px;
  display: flex; flex-direction: column; gap: clamp(5px, 1.1vh, 10px);
}
.over-row { display: flex; justify-content: space-between; font-size: clamp(13px, 2vh, 16px); color: rgba(217, 244, 255, 0.8); }
.over-row b { color: #fff; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  #achv-list { grid-template-columns: 1fr; }
  .btn { min-width: 170px; }
  #help-box { max-width: 94%; }
}

/* ---------- KanaWorks_AI クレジット ---------- */
.kw-credit {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 16px; padding: 6px 16px 6px 8px;
  background: rgba(10, 18, 38, 0.6);
  border: 1px solid rgba(77, 232, 255, 0.25);
  border-radius: 999px;
  text-decoration: none;
  color: #9db4d8; font-size: 12.5px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.kw-credit img { width: 28px; height: 28px; display: block; }
.kw-credit b { color: var(--cyan); }
.kw-credit:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(77, 232, 255, 0.25);
}
