/* 鉄壁PK — 画面の見た目。テレビの中継の画面のように、暗い板に白い字、マシンは赤、人類は金。
   claude.ai で出すと index.html が外枠（:root の余白・body の白い背景と 14px の字）に包まれるので、
   body の背景と字はここで必ず指定する。画面全体は #app を position: fixed で敷く。 */
:root {
  --ink: #f3f2ec;
  --ink-2: rgba(243, 242, 236, 0.74);
  --ink-3: rgba(243, 242, 236, 0.5);
  --panel: rgba(8, 11, 16, 0.86);
  --panel-2: rgba(8, 11, 16, 0.68);
  --line: rgba(255, 255, 255, 0.14);
  --red: #e2262f;
  --gold: #f2c230;
  --grey: #8e98a3;
  --dark: #0b0e13;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --f-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --f-num: "Barlow Condensed", "Arial Narrow", "Zen Kaku Gothic New", sans-serif;
}

html, body { margin: 0; height: 100%; background: #04070b; }
body {
  color: var(--ink);
  font: 500 15px/1.5 var(--f-jp);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#app { position: fixed; inset: 0; overflow: hidden; background: #04070b; touch-action: none; }
#gl, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fx { touch-action: none; cursor: crosshair; }

button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── 上の帯 ── */
/* 最初の画面（z-index 7）より上に置く。12/6 まで 5 だったので、最初の画面では JA/EN・音・？ が押せなかった。板（9）よりは下 */
#top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 12px) 0 calc(var(--sal) + 12px);
  pointer-events: none;
}
#top > * { pointer-events: auto; }
.bug {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 11px 7px; transition: opacity 0.2s ease, transform 0.2s ease;
}
.bug.off { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.bug-row { display: flex; align-items: center; gap: 10px; line-height: 1; }
.bug-team { position: relative; font-weight: 700; font-size: 12px; padding-bottom: 5px; letter-spacing: 0.02em; white-space: nowrap; }
.bug-team::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
:lang(en) .bug-team { font-family: var(--f-num); font-size: 13px; letter-spacing: 0.06em; }  /* 英語は細い字にして、せまい画面でも上の帯に入るように */
.bug-team.human::after { background: var(--gold); }
.bug-team.machine::after { background: var(--red); }
.bug-score { display: flex; gap: 6px; align-items: baseline; font: 800 26px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.bug-score i { font-style: normal; font-weight: 600; opacity: 0.4; }
.bug-pips { display: flex; gap: 7px; justify-content: center; margin-top: 7px; }
.pip { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.32); box-sizing: border-box; transition: background-color 0.2s, border-color 0.2s; }
.pip.now { border-color: #fff; }
.pip.goal { background: var(--gold); border-color: var(--gold); }
.pip.save { background: var(--red); border-color: var(--red); }
.pip.miss, .pip.post { background: var(--grey); border-color: var(--grey); }

.top-btns { display: flex; gap: 8px; }
.icon, .chip {
  height: 40px; min-width: 40px; border-radius: 10px; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease-out;
}
.icon:active, .chip:active { transform: scale(0.95); }
.chip { padding: 0 11px; gap: 7px; font: 700 14px/1 var(--f-num); letter-spacing: 0.06em; }
.chip span { opacity: 0.4; }
.chip span.on { opacity: 1; }
.icon svg { width: 21px; height: 21px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon .spk { fill: var(--ink); stroke: none; }
.icon .cross { display: none; }
.icon.muted .wave { display: none; }
.icon.muted .cross { display: inline; }
.icon .q { font: 800 20px/1 var(--f-num); }

/* ── 下の操作 ── */
#controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; justify-items: center; gap: 12px;
  padding: 34px calc(var(--sar) + 16px) calc(var(--sab) + 14px) calc(var(--sal) + 16px);
  background: linear-gradient(to top, rgba(4, 7, 11, 0.82) 0%, rgba(4, 7, 11, 0.55) 55%, rgba(4, 7, 11, 0) 100%);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;   /* うすい影のところは、下のねらう面にタッチを通す */
}
#controls > * { pointer-events: auto; }
#controls.off { opacity: 0; transform: translateY(18px); }
#controls.off > * { pointer-events: none; }
#controls.locked .curve { opacity: 0.35; pointer-events: none; }

.hint {
  min-height: 30px; box-sizing: border-box; padding: 6px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; white-space: nowrap;
  opacity: 0; transform: translateY(4px); transition: opacity 0.18s ease, transform 0.18s ease;
}
.hint.on { opacity: 1; transform: none; }
.hint.warn { color: var(--gold); }

.curve { display: flex; align-items: center; gap: 10px; transition: opacity 0.15s; }
.curve-label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.curve-btns { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); }
.curve-btns button {
  width: 44px; height: 36px; border-radius: 8px; color: var(--ink-2);
  display: grid; place-items: center; transition: background-color 0.12s, color 0.12s;
}
.curve-btns button[aria-checked="true"] { background: var(--ink); color: var(--dark); }
.curve-btns svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.shoot-row { width: 100%; max-width: 340px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.readout { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.readout b { font: 800 30px/1 var(--f-num); }
.readout span { font: 700 13px/1 var(--f-num); color: var(--ink-2); letter-spacing: 0.04em; }
.readout.left { justify-self: end; }
.readout.right { justify-self: start; }
.readout.dim b { color: var(--ink-3); }

.shoot { position: relative; width: 98px; height: 98px; border-radius: 50%; display: grid; place-items: center; }
.shoot .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-bg { fill: rgba(8, 11, 16, 0.6); stroke: rgba(255, 255, 255, 0.22); stroke-width: 6; }
.ring-fg { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 282.74; stroke-dashoffset: 282.74; }
.shoot.full .ring-fg { stroke: var(--gold); }
.shoot.over .ring-fg { stroke: var(--red); }
.shoot-core {
  position: absolute; inset: 13px; border-radius: 50%;
  background: var(--ink); color: var(--dark);
  display: grid; place-items: center; font-weight: 900; font-size: 15px; letter-spacing: 0.04em;
  transition: transform 0.12s ease-out, background-color 0.12s;
}
.shoot.charging .shoot-core { transform: scale(0.92); }
.shoot.over .shoot-core { background: #ffd9d6; }

/* ── 合図と結果 ── */
.callout {
  position: absolute; left: 0; right: 0; top: 41%; z-index: 4; text-align: center; pointer-events: none;
  font: 900 30px/1.1 var(--f-jp); letter-spacing: 0.04em; opacity: 0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}
.banner {
  position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 13%); z-index: 6;
  display: grid; justify-items: center; gap: 8px; padding: 0 12px; pointer-events: none;
  visibility: hidden;
}
.banner.on { visibility: visible; }
.banner-word {
  font: 800 74px/0.92 var(--f-num); letter-spacing: 0.02em;
  padding: 10px 26px 7px 22px; background: rgba(6, 8, 12, 0.88); border-left: 6px solid currentColor;
  clip-path: inset(0 100% 0 0); transition: clip-path 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.banner.on .banner-word { clip-path: inset(0 0 0 0); }
.banner.goal .banner-word { color: var(--gold); }
.banner.save .banner-word { color: var(--red); }
.banner.miss .banner-word, .banner.post .banner-word { color: var(--ink); }
.banner-sub, .banner-tele {
  max-width: 100%; box-sizing: border-box; text-align: center;
  background: var(--panel); border-radius: 6px; padding: 6px 12px;
  opacity: 0; transform: translateY(6px); transition: opacity 0.2s ease 0.14s, transform 0.2s ease 0.14s;
}
.banner-sub { font-size: 15px; font-weight: 700; }
.banner-tele { font-size: 12px; font-weight: 700; color: var(--ink-2); transition-delay: 0.24s; }
.banner-tele:empty { display: none; }
.banner-tele .nw { white-space: nowrap; }
.banner.on .banner-sub, .banner.on .banner-tele { opacity: 1; transform: none; }
/* 背の低い縦の画面：帯を小さくして下へ寄せ、ゴールの下のすみ（ボール）にかからないように */
@media (max-aspect-ratio: 1/1) and (max-height: 700px) {
  .banner { bottom: calc(var(--sab) + 50px); gap: 6px; }
  .banner-word { font-size: 54px; padding: 8px 20px 5px 16px; }
  .banner-sub { font-size: 14px; padding: 5px 10px; }
  .banner-tele { font-size: 11px; padding: 5px 10px; }
}

.replay-tag {
  position: absolute; z-index: 5; left: calc(var(--sal) + 12px); top: calc(var(--sat) + 74px);
  display: flex; align-items: center; gap: 8px; padding: 6px 11px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--line);
  font: 700 13px/1 var(--f-jp); opacity: 0; transition: opacity 0.18s; pointer-events: none;
}
.replay-tag.on { opacity: 1; }
.replay-tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: blink 1s steps(2, start) infinite; }
.replay-angle { color: var(--ink-2); font-weight: 500; }
.replay-angle:not(:empty)::before { content: "·"; margin-right: 8px; color: var(--ink-3); }
@keyframes blink { to { visibility: hidden; } }

.watch {
  position: absolute; z-index: 5; right: calc(var(--sar) + 12px); top: calc(var(--sat) + 74px);
  display: grid; grid-template-columns: auto auto; align-items: baseline; justify-content: end; column-gap: 4px;
  padding: 7px 11px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line);
  opacity: 0; transition: opacity 0.18s; pointer-events: none; font-variant-numeric: tabular-nums;
}
.watch.on { opacity: 1; }
.watch b { font: 800 26px/1 var(--f-num); }
.watch span { font: 700 12px/1 var(--f-jp); color: var(--ink-2); }
.watch em { grid-column: 1 / -1; font: 700 12px/1.2 var(--f-jp); font-style: normal; color: var(--red); text-align: right; margin-top: 4px; }
.watch em:empty { display: none; }

.tapnext {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: calc(var(--sab) + 22px); text-align: center;
  font-size: 13px; font-weight: 700; color: var(--ink-2); opacity: 0; transition: opacity 0.25s; pointer-events: none;
}
.tapnext.on { opacity: 1; }

/* ── 最初の画面 ── */
.title {
  position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 calc(var(--sar) + 20px) calc(var(--sab) + 20px) calc(var(--sal) + 20px);
  background: linear-gradient(to top, rgba(4, 7, 11, 0.97) 0%, rgba(4, 7, 11, 0.92) 40%, rgba(4, 7, 11, 0) 66%);
  transition: opacity 0.4s ease, visibility 0s linear 0s;
}
.title.off { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.4s ease, visibility 0s linear 0.4s; }
/* 下に寄せる（上の余白を auto に）。入りきらない背の低い画面では、上から見せて、スクロールで下まで見られる */
.title-card { width: 100%; max-width: 420px; margin: auto auto 0; }
/* 縦の画面：文字の後ろはしっかり暗くする（背の低いスマホで、後ろの看板の字と重ならないように） */
@media (max-aspect-ratio: 1/1) {
  .title-card { position: relative; }
  .title-card::before {
    content: ""; position: absolute; z-index: -1; pointer-events: none;
    left: calc(50% - 50vw); right: calc(50% - 50vw); top: -64px; bottom: 0;
    background: linear-gradient(to bottom, rgba(4, 7, 11, 0) 0, rgba(4, 7, 11, 0.9) 64px);
  }
}
.kicker { display: flex; align-items: center; gap: 9px; margin: 0 0 8px; font: 700 13px/1 var(--f-num); letter-spacing: 0.2em; color: var(--ink-2); }
.kbar { width: 22px; height: 3px; background: var(--red); flex: none; }
.title h1 { margin: 0 0 10px; font-size: 40px; line-height: 1.12; font-weight: 900; letter-spacing: 0.02em; }
.lead { margin: 0 0 16px; font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.how { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 9px; }
.how li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: center; font-size: 14px; font-weight: 700; line-height: 1.4; }
.how b { width: 26px; height: 26px; box-sizing: border-box; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.3); display: grid; place-items: center; font: 800 15px/1 var(--f-num); }
.primary, .secondary {
  width: 100%; height: 54px; border-radius: 12px; font-size: 17px; font-weight: 900; letter-spacing: 0.06em;
  transition: transform 0.12s ease-out, background-color 0.12s;
}
.primary { background: var(--ink); color: var(--dark); }
.secondary { background: transparent; color: var(--ink); border: 1.5px solid rgba(255, 255, 255, 0.32); }
.primary:active, .secondary:active { transform: scale(0.98); }
.record { margin: 10px 0 0; text-align: center; font-size: 12px; color: var(--ink-3); }

/* このゲームのリンク（最初の画面と結果の板）。欄の字は選べるので、長押しや右クリックでもコピーできる */
.linkbox { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 10px 0 0; }
.link-url {
  width: 100%; min-width: 0; height: 40px; box-sizing: border-box; margin: 0; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.05);
  color: var(--ink-2); font: 600 16px/1 var(--f-num); letter-spacing: 0.02em; text-overflow: ellipsis;
  outline: none; -webkit-appearance: none; appearance: none; cursor: text;
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
.link-url:focus { border-color: rgba(255, 255, 255, 0.45); color: var(--ink); }
.link-url::selection { background: rgba(242, 194, 48, 0.42); color: #fff; }
.link-copy {
  height: 40px; padding: 0 16px; box-sizing: border-box; border-radius: 10px; border: 1.5px solid rgba(255, 255, 255, 0.32);
  font-size: 14px; font-weight: 900; letter-spacing: 0.06em; white-space: nowrap; transition: transform 0.12s ease-out;
}
.link-copy:active { transform: scale(0.97); }

/* ── 下から出る板（結果・遊び方） ── */
.sheet {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(2, 4, 7, 0.55);
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 0px) 0 calc(var(--sal) + 0px);
  animation: fadeIn 0.2s ease;
}
.sheet-card {
  width: 100%; max-width: 440px; box-sizing: border-box; max-height: 100%; overflow-y: auto;
  background: #0b0f15; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(var(--sab) + 18px);
  animation: sheetUp 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet h2 { margin: 6px 0 4px; font-size: 24px; font-weight: 900; }
.note { margin: 0 0 14px; font-size: 14px; color: var(--ink-2); line-height: 1.6; }
.final-score { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 6px; font: 800 44px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.final-score i { font-style: normal; font-weight: 600; opacity: 0.4; }
.fs-team { font: 700 13px/1 var(--f-jp); padding-bottom: 4px; border-bottom: 2px solid; align-self: center; }
:lang(en) .fs-team { font-family: var(--f-num); font-size: 14px; letter-spacing: 0.06em; }
.fs-team.human { border-color: var(--gold); }
.fs-team.machine { border-color: var(--red); }
.shot-list { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--line); }
.shot-list li { display: grid; grid-template-columns: 22px 74px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.shot-list .n { font: 800 15px/1 var(--f-num); color: var(--ink-3); }
.shot-list .w { font: 800 17px/1 var(--f-num); letter-spacing: 0.03em; }
.shot-list .w.goal { color: var(--gold); }
.shot-list .w.save { color: var(--red); }
.shot-list .w.miss, .shot-list .w.post { color: var(--ink-2); }
.shot-list .d { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-list .k { font: 700 15px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.totals { margin: 0 0 14px; font-size: 12px; color: var(--ink-3); }
.sheet-btns { display: grid; gap: 10px; }
/* 結果の板：「もう一度」と「結果をコピー」は横に並べる（リンクの欄を足しても、板が縦にのびないように） */
#final .sheet-btns { grid-template-columns: 1fr 1fr; }
.help-list { margin: 10px 0 18px; padding: 0 0 0 1.2em; display: grid; gap: 8px; font-size: 14px; line-height: 1.6; }
.help-list .tip { list-style: none; margin-left: -1.2em; padding: 8px 10px; border-radius: 8px; background: rgba(242, 194, 48, 0.1); color: var(--gold); font-weight: 700; }

/* ── ポイントと強化 ── */
.title-btns { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.shop-open {
  position: relative; height: 54px; min-width: 96px; padding: 0 14px; box-sizing: border-box; border-radius: 12px;
  display: grid; align-content: center; justify-items: center; gap: 4px;
  background: rgba(8, 11, 16, 0.6); border: 1.5px solid rgba(255, 255, 255, 0.32);
  transition: transform 0.12s ease-out, border-color 0.2s;
}
.shop-open:active { transform: scale(0.97); }
.so-label { font-size: 14px; font-weight: 900; line-height: 1; letter-spacing: 0.06em; }
.so-pts { font: 700 13px/1 var(--f-num); color: var(--gold); letter-spacing: 0.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.so-pts b { font-size: 16px; font-weight: 800; }
/* 買える強化があるときは、金のふちと点 */
.shop-open.can { border-color: var(--gold); }
.shop-open.can::after {
  content: ""; position: absolute; top: -5px; right: -5px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 2px #0b0f15; animation: ping 1.8s ease-out infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 2px #0b0f15, 0 0 0 2px rgba(242, 194, 48, 0.55); }
  70%, 100% { box-shadow: 0 0 0 2px #0b0f15, 0 0 0 11px rgba(242, 194, 48, 0); }
}

/* 結果の帯の、入ったポイントの札 */
.bpts {
  display: inline-block; margin-right: 8px; padding: 2px 7px 1px; border-radius: 5px; vertical-align: 1px;
  background: var(--gold); color: var(--dark); font: 800 14px/1.2 var(--f-num); letter-spacing: 0.03em; white-space: nowrap;
}
.banner.save .bpts, .banner.post .bpts { background: rgba(242, 194, 48, 0.16); color: var(--gold); }

/* 結果の板：今回のポイントと「強化」 */
.pts-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.pts-gain { margin: 0; display: flex; align-items: baseline; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.pts-gain b { font: 800 30px/1 var(--f-num); color: var(--gold); font-variant-numeric: tabular-nums; }
.pts-gain small { font: 700 14px/1 var(--f-num); color: var(--gold); }
.pts-row .shop-open { height: 48px; }

/* 強化の板 */
.shop-card:focus { outline: none; }
.shop-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.shop-head h2 { margin-bottom: 0; }
.wallet { margin: 0 0 2px; display: flex; align-items: baseline; gap: 4px; color: var(--gold); white-space: nowrap; }
.wallet b { font: 800 36px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.wallet span { font: 700 16px/1 var(--f-num); }
.shop-note { margin: 8px 0 12px; font-size: 13px; white-space: pre-line; }
.upg-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.upg {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  transition: border-color 0.35s ease, background-color 0.35s ease;
}
.upg.flash { animation: upgFlash 0.9s ease-out; }
@keyframes upgFlash { 0% { border-color: var(--gold); background: rgba(242, 194, 48, 0.16); } 100% { border-color: var(--line); background: rgba(255, 255, 255, 0.04); } }
.upg.shake { animation: shake 0.32s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.upg-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.07); }
.upg-ic svg { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.upg.maxed .upg-ic svg { stroke: var(--gold); }
.upg-main { min-width: 0; }
.upg-top { margin: 0; display: flex; align-items: baseline; gap: 8px; }
.upg-name { font-size: 15px; font-weight: 900; white-space: nowrap; }
.upg-lv { font: 700 14px/1 var(--f-num); color: var(--ink-2); letter-spacing: 0.04em; white-space: nowrap; }
.upg.maxed .upg-lv { color: var(--gold); }
.upg-desc { margin: 3px 0 7px; font-size: 12px; line-height: 1.45; color: var(--ink-2); white-space: pre-line; }
.upg-meter { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.upg-bars { display: flex; gap: 3px; }
.upg-bars i { width: 15px; height: 6px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); transform-origin: left center; }
.upg-bars i.on { background: var(--gold); }
.upg-bars i.pop { animation: barIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes barIn { from { transform: scaleX(0); } }
.upg-eff { font: 700 14px/1 var(--f-num); letter-spacing: 0.02em; white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
:lang(ja) .upg-eff { font-family: var(--f-jp); font-size: 12px; }
.upg-eff .arr { margin: 0 5px; opacity: 0.6; }
.upg-eff .nxt { color: var(--gold); }
.upg.maxed .upg-eff .arr, .upg.maxed .upg-eff .nxt { display: none; }
.upg-buy {
  min-width: 72px; height: 46px; padding: 0 10px; box-sizing: border-box; border-radius: 10px;
  display: grid; place-items: center; white-space: nowrap;
  background: var(--gold); color: var(--dark); transition: transform 0.12s ease-out, background-color 0.15s, color 0.15s;
}
.upg-buy b { font: 800 19px/1 var(--f-num); font-variant-numeric: tabular-nums; }
.upg-buy small { font: 700 12px/1 var(--f-num); }
.upg-buy:active { transform: scale(0.96); }
.upg-buy.short { background: rgba(255, 255, 255, 0.1); color: var(--ink-2); }
.upg-buy.max { background: transparent; color: var(--gold); border: 1.5px solid rgba(242, 194, 48, 0.45); cursor: default; }
.upg-buy.max small { display: none; }
.upg-buy.max:active { transform: none; }
#shop .sheet-btns { grid-template-columns: 1fr 1fr; }

.toast {
  position: absolute; z-index: 10; left: 50%; bottom: calc(var(--sab) + 30px); transform: translate(-50%, 10px);
  width: max-content; max-width: calc(100% - 32px); box-sizing: border-box; text-align: center; line-height: 1.45;
  padding: 9px 16px; border-radius: 20px; background: var(--ink); color: var(--dark); font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
/* コピーの知らせは上に出す（下だと、リンクの欄にかぶる） */
.toast.top { top: calc(var(--sat) + 64px); bottom: auto; transform: translate(-50%, -10px); }
.toast.top.on { transform: translate(-50%, 0); }

.fatal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: #04070b; text-align: center; font-size: 15px; line-height: 1.7; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } }

/* ── 横長の画面（パソコン） ── */
@media (min-aspect-ratio: 1/1) and (min-height: 521px) {
  .title { justify-content: center; align-items: flex-start; padding-left: calc(var(--sal) + 7vw); background: linear-gradient(to right, rgba(4, 7, 11, 0.95) 0%, rgba(4, 7, 11, 0.82) 36%, rgba(4, 7, 11, 0) 62%); }
  .title-card { margin: 0; }
  .title h1 { font-size: 48px; }
  .sheet { align-items: center; padding-bottom: 12px; }
  .sheet-card { border-radius: 18px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
  .banner { bottom: 10%; }
  .banner-word { font-size: 92px; }
}

/* ── 横長の画面：操作は右に置く（ボールを画面の下のほうまで使えて、ゴールを大きく映せる） ── */
@media (min-aspect-ratio: 23/20) {
  #controls {
    left: auto; top: 0; width: calc(250px + var(--sar)); box-sizing: border-box; align-content: end; gap: 12px;
    padding: 0 calc(var(--sar) + 18px) calc(var(--sab) + 22px) 14px;
    background: linear-gradient(to left, rgba(4, 7, 11, 0.82) 0%, rgba(4, 7, 11, 0.45) 72%, rgba(4, 7, 11, 0) 100%);
  }
  #controls.off { transform: translateX(18px); }
  .hint { white-space: normal; text-align: center; border-radius: 14px; max-width: 218px; }
  .curve { flex-direction: column; gap: 6px; }
  .curve-btns button { width: 40px; }
  .shoot-row { grid-template-columns: 1fr 1fr; grid-template-areas: "l r" "b b"; row-gap: 10px; column-gap: 12px; }
  .readout.left { grid-area: l; }
  .readout.right { grid-area: r; }
  .shoot { grid-area: b; justify-self: center; }
}
/* 横長で背が低い（横にしたスマホ）：右の列をつめる */
@media (min-aspect-ratio: 23/20) and (max-height: 520px) {
  #controls { width: calc(230px + var(--sar)); gap: 8px; padding: 0 calc(var(--sar) + 12px) calc(var(--sab) + 10px) 12px; }
  .curve-btns button { width: 38px; height: 32px; }
  .readout b { font-size: 24px; }
  .shoot { width: 80px; height: 80px; }
  .shoot-core { inset: 11px; }
}

/* ── 横にしたスマホ（背が低い） ── */
@media (orientation: landscape) and (max-height: 520px) {
  .title { justify-content: center; padding-top: calc(var(--sat) + 12px); background: rgba(4, 7, 11, 0.86); overflow-y: auto; }
  .title-card { margin: auto; }   /* まん中に置く。入りきらないときは上から見せる */
  .title h1 { font-size: 30px; }
  .lead { display: none; }
  .how { gap: 5px; margin-bottom: 12px; }
  /* 結果の帯は横に並べて低くし、ゴールの下と「タップで次へ」にかからないように */
  .banner { bottom: calc(var(--sab) + 44px); grid-template-columns: auto auto; justify-content: center; align-items: center; column-gap: 10px; row-gap: 5px; }
  .banner-word { grid-row: 1 / span 2; font-size: 48px; padding: 8px 18px 5px 14px; }
  .banner-sub { font-size: 13px; padding: 5px 10px; justify-self: start; }
  .banner-tele { font-size: 11px; padding: 5px 10px; justify-self: start; }
  .tapnext { bottom: calc(var(--sab) + 8px); }
  .callout { top: 30%; }
  /* 結果の板は 2 列（左に点と順位とボタン、右に 5 本の一覧）にして、縦にはみ出さないように */
  #final .sheet-card { max-width: 700px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; align-content: start; padding-top: 14px; }
  #final .sheet-card > * { grid-column: 1; }
  #final .shot-list { grid-column: 2; grid-row: 1 / span 6; align-self: center; margin: 0; }
  /* リンクの欄は、右の列の下（左のボタンと同じ段）に置く */
  #final .linkbox { grid-column: 2; grid-row: 7; align-self: center; margin: 0; }
  #final .final-score { font-size: 36px; }
  #final h2 { font-size: 20px; }
  #final .note { margin-bottom: 8px; font-size: 13px; }
  #final .pts-row { margin-bottom: 8px; }
  #final .pts-row .shop-open { height: 44px; }
  #final .totals { margin-bottom: 10px; }
  #final .sheet-btns { grid-template-columns: 1fr 1fr; }
  #final .primary, #final .secondary { height: 48px; }
  /* 強化の板は、3 つを横に並べる */
  #shop .sheet-card { max-width: 760px; padding-top: 14px; }
  .shop-note { display: none; }
  .upg-list { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 10px; }
  .upg { grid-template-columns: 34px minmax(0, 1fr); align-items: start; gap: 8px 10px; padding: 10px; }
  .upg-ic { width: 34px; height: 34px; }
  .upg-ic svg { width: 22px; height: 22px; }
  .upg-desc { display: none; }
  .upg-meter { margin-top: 6px; }
  .upg-buy { grid-column: 1 / -1; width: 100%; height: 40px; }
  #shop .primary, #shop .secondary { height: 46px; }
}
/* 背の低い縦のスマホ（320×568 など）：強化の板は、ポイントのたまり方の説明を省いて、下のボタンまで 1 画面に入れる */
@media (orientation: portrait) and (max-height: 600px) {
  #shop .sheet-card { padding-top: 14px; }
  .shop-head { margin-bottom: 10px; }
  .shop-note { display: none; }
  .upg-list { gap: 6px; }
}

/* せまいスマホ：上の帯（点数とボタン）をつめて、英語でも 1 行に入れる */
@media (max-width: 370px) {
  #top { gap: 6px; padding-left: calc(var(--sal) + 8px); padding-right: calc(var(--sar) + 8px); }
  .bug { padding: 6px 7px; }
  .bug-row { gap: 6px; }
  .bug-score { font-size: 24px; }
  .top-btns { gap: 4px; }
  .icon, .chip { height: 38px; min-width: 38px; }
  .chip { padding: 0 8px; gap: 5px; }
  /* 結果の一覧：説明は切らずに折り返し、ボタンは横に並べて、板が縦にはみ出さないように */
  .shot-list li { grid-template-columns: 18px 56px minmax(0, 1fr) auto; gap: 6px; padding: 6px 0; }
  .shot-list .d { white-space: normal; line-height: 1.25; }
  .sheet-btns { grid-template-columns: 1fr 1fr; }
  /* 強化の板：1 行をつめる */
  .upg { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; padding: 10px; }
  .upg-ic { width: 34px; height: 34px; }
  .upg-ic svg { width: 22px; height: 22px; }
  .upg-buy { min-width: 62px; height: 44px; }
  .upg-bars i { width: 12px; }
  .wallet b { font-size: 32px; }
  .shop-open { min-width: 88px; padding: 0 10px; }
}
@media (max-width: 340px) {
  .title h1 { font-size: 34px; }
  .curve-btns button { width: 38px; }
  .curve-label { display: none; }
  .bug-team { font-size: 11px; }
  .pts-gain b { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .banner-word, .banner-sub, .banner-tele, #controls, .hint, .title, .sheet, .sheet-card { transition: none; animation: none; }
  .upg, .upg-bars i, .shop-open::after { animation: none !important; }
}
