/* Phone screen. The view is 45% field, 35% reels, 20% team and buttons.
   Metal and one amber neon line. 404 keeps the plain column below. */
:root {
  color-scheme: dark;
  --ink: #f4efe4;
  --muted: #b7ab9a;
  --cabinet: #100e0c;
  --metal: #241c16;
  --line: #3a3128;
  --neon: #ffb703;
  --cyan: #7ee0ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--cabinet);
  color: var(--ink);
  font: 16px/1.45 "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}
button, p { font: inherit; }
button {
  color: var(--ink);
  background: var(--metal);
  border: 1px solid var(--neon);
  border-radius: 10px;
  padding: 0 8px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.2, 1.4, 0.4, 1);
}
button:active:not(:disabled) { transform: scale(0.96); }
button:disabled { opacity: 0.38; border-color: #5c5346; cursor: default; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
#loading[hidden],
#app[hidden],
#sheet[hidden],
#end[hidden],
#status[hidden],
#choices[hidden],
#raised[hidden],
#end-best[hidden] { display: none !important; }
#loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
  background: var(--cabinet);
}
#loading-text { margin: 0; letter-spacing: 0.08em; }
#loading-error, #loading-slow, #loading-detail {
  margin: 0;
  max-width: 18rem;
  color: var(--muted);
  font-size: 13px;
}
#app {
  height: 100dvh;
  max-height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 45fr) minmax(0, 35fr) minmax(0, 20fr);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
#stage {
  grid-row: 1 / 3;
  grid-column: 1;
  position: relative;
  min-height: 0;
  background: #100e0c;
}
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#seam {
  position: absolute;
  left: 0;
  right: 0;
  top: 56.25%;
  height: 2px;
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
  pointer-events: none;
  z-index: 2;
}
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 8px;
  pointer-events: none;
  font-size: 12px;
  line-height: 1;
  text-shadow: 0 1px 2px #000;
}
#hud p { margin: 0; white-space: nowrap; }
#counter { display: flex; align-items: center; gap: 4px; }
#pips { display: flex; gap: 2px; }
.pip {
  width: 6px;
  height: 10px;
  border: 1px solid #e7c27a;
  background: #4a2424;
  display: block;
}
.pip.on { background: var(--neon); box-shadow: 0 0 4px var(--neon); }
#floaters { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute;
  margin: 0;
  transform: translate(-50%, 0);
  animation: rise 0.7s ease-out forwards;
  font-size: 15px;
  font-weight: 700;
  color: #fff8ea;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}
.floater.crit { font-size: 28px; color: #ffd56a; text-shadow: 0 0 8px #ffb703, 0 1px 2px #000; }
.floater.heal { color: #b6f2c0; }
.floater.gold { font-size: 18px; color: #ffd56a; }
@keyframes rise {
  to { transform: translate(-50%, -28px); opacity: 0; }
}
#dock {
  grid-row: 3;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(#1a1612, #120f0c);
  border-top: 1px solid var(--line);
}
#status {
  margin: 0;
  height: 16px;
  line-height: 16px;
  font-size: 12px;
  color: var(--neon);
  white-space: nowrap;
  overflow: hidden;
}
#team {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  gap: 3px;
  touch-action: none;
}
.unit {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(var(--ink, #2a241c), #1a140f 70%);
  overflow: hidden;
  touch-action: none;
}
.unit img {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  bottom: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  object-fit: contain;
  pointer-events: none;
}
.unit .name {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  line-height: 14px;
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
}
.unit .foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.55);
}
.unit .lv, .unit .row {
  font-size: 9px;
  line-height: 14px;
  white-space: nowrap;
  color: var(--muted);
}
.unit.crowd .lv { font-size: 8px; letter-spacing: 0; }
.stars { display: flex; gap: 0; height: 8px; }
.star { width: 8px; height: 8px; stroke: var(--neon); stroke-width: 1; fill: none; }
.star.on { fill: var(--neon); }
.row-icon { width: 10px; height: 10px; stroke: var(--muted); stroke-width: 1.4; fill: none; }
.unit.selected { border-color: var(--cyan); }
.unit.golden { border-color: #ffd56a; box-shadow: inset 0 0 0 1px #ffd56a; }
#team[data-count="0"] { min-height: 8px; }
#actions { flex: 0 0 36px; display: flex; gap: 6px; }
#actions button { height: 36px; font-size: 15px; white-space: nowrap; }
#spin, #fight { flex: 1 1 auto; min-width: 0; }
#speed { flex: 0 0 46px; letter-spacing: 0; padding: 0 4px; }
#sound-play { flex: 0 0 68px; font-size: 13px; letter-spacing: 0; padding: 0 4px; }
#flash {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 58%, rgba(255, 220, 140, 0.92), rgba(255, 160, 40, 0.25) 46%, rgba(255, 140, 20, 0) 70%);
}
#sheet {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 196, 90, 0.16), transparent 34%),
    rgba(6, 4, 3, 0.82);
  overflow: auto;
}
#sheet[data-spot="1"] {
  background:
    radial-gradient(ellipse at 50% 16%, rgba(255, 246, 220, 0.92) 0%, rgba(255, 186, 70, 0.28) 14%, rgba(0, 0, 0, 0.72) 42%, rgba(0, 0, 0, 0.92) 70%);
}
#raised { align-self: center; text-align: center; }
#raised img {
  width: 112px;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.55));
}
#raised.flash img {
  filter: brightness(2.8) drop-shadow(0 0 18px #fff6d0);
}
#raised-name, #sheet-title { margin: 0; text-align: center; }
#sheet-title { color: var(--neon); letter-spacing: 0.12em; font-size: 14px; }
#raised-name { font-size: 13px; color: var(--muted); }
#choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 72px;
  padding: 8px;
  text-align: left;
  background: #221c16;
  border-radius: 12px;
}
.choice.no-art { grid-template-columns: 1fr; }
.choice img { width: 64px; height: 64px; object-fit: contain; }
.choice .copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice .name { font-size: 16px; line-height: 1.2; }
.choice .text { font-size: 13px; line-height: 1.35; color: var(--muted); }
.choice.rare { border-color: var(--cyan); }
#end {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 6, 4, 0.78);
}
#end .panel {
  width: min(280px, 100%);
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 18px 16px 16px;
  background: #1c1712;
  border: 1px solid var(--neon);
  border-radius: 14px;
  text-align: center;
}
#end p { margin: 0; }
#again { height: 40px; min-width: 0; }
#shell[hidden],
#home[hidden],
#prizes[hidden],
#guide[hidden],
#board[hidden],
#share[hidden],
#go-resume[hidden],
#hard-lock[hidden],
#end-art[hidden],
#end-cards[hidden],
#end-level[hidden],
#end-rank[hidden],
#share-send[hidden],
#share-save[hidden],
#share-copy[hidden],
#board-note[hidden],
#board-me[hidden] { display: none !important; }
#shell {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  padding: 16px 14px calc(12px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 183, 3, 0.16), transparent 42%),
    var(--cabinet);
  overflow: hidden;
}
#shell h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
}
#home h1 {
  font-size: 40px;
  letter-spacing: 0.22em;
  color: #f6f1e4;
  text-shadow:
    0 0 10px #ffb703,
    0 0 2px #ffe7a8,
    0 2px 0 #6a5b48,
    0 -1px 0 #fff6df;
}
body[data-screen="home"] #app { display: block; height: 100dvh; }
body[data-screen="home"] #stage { position: fixed; inset: 0; z-index: 0; }
body[data-screen="home"] #dock,
body[data-screen="home"] #hud,
body[data-screen="home"] #seam,
body[data-screen="home"] #flash,
body[data-screen="home"] #floaters { display: none; }
body[data-screen="home"] #shell {
  background: linear-gradient(to bottom, rgba(8, 6, 4, 0.72) 0%, rgba(8, 6, 4, 0.05) 24%, rgba(8, 6, 4, 0) 46%, rgba(8, 6, 4, 0.78) 100%);
  pointer-events: none;
}
body[data-screen="home"] #home { justify-content: space-between; pointer-events: none; }
body[data-screen="home"] #home-top,
body[data-screen="home"] #home-actions { pointer-events: auto; }
body[data-screen="home"] #home-records,
body[data-screen="home"] #hard-lock,
body[data-screen="home"] #home-meta,
body[data-screen="home"] #home h1 {
  text-shadow:
    0 0 10px #ffb703,
    0 1px 2px #000,
    0 2px 0 #3a3128;
}
#home, #prizes, #guide, #board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#home-meta {
  margin: 0;
  display: flex;
  justify-content: space-between;
  color: var(--neon);
}
#xp {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  overflow: hidden;
  background: #1a140f;
}
#xp-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
}
#home-records, #hard-lock, #board-note, #board-me, #share-text, #end-cards, #end-gain, #end-level, #end-rank {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}
#home-actions { display: flex; flex-direction: column; gap: 8px; }
#home-actions > button, #guide-back, #prize-back, #board-back, #sound-end {
  height: 42px;
  font-size: 16px;
}
#sound-end { width: 100%; }
#home-nav, .tabs, .screen-head, #end-actions, #share-actions {
  display: flex;
  gap: 6px;
}
#end-actions button, #share-actions button {
  flex: 1 1 auto;
  height: 40px;
  white-space: nowrap;
  padding: 0 4px;
  letter-spacing: 0;
  font-size: 15px;
}
.screen-head { align-items: center; }
.screen-head p { margin: 0; flex: 1; text-align: right; color: var(--neon); }
.screen-head button { flex: 0 0 88px; height: 40px; font-size: 16px; }
#prize-slots { display: flex; flex-wrap: wrap; gap: 6px; }
#prize-slots button {
  flex: 1 1 30%;
  height: 36px;
  font-size: 16px;
}
#prize-slots button.on { border-color: var(--cyan); color: var(--cyan); }
#prize-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.prize {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1c1712;
}
.prize .swatch { width: 72px; height: 72px; display: grid; place-items: center; }
.prize img, .prize canvas { width: 72px; height: 72px; object-fit: contain; }
.prize-name, .prize-price { margin: 0; line-height: 1.2; }
.prize-price { color: var(--muted); font-size: 13px; }
.prize button { width: 100%; height: 36px; font-size: 15px; }
#guide .body { overflow: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#guide .body p { margin: 0; }
#guide-back { margin-top: auto; }
.tabs button[aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }
#nick-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
}
#nick {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  font-size: 16px;
  color: var(--ink);
  background: #1c1712;
  border: 1px solid var(--line);
  border-radius: 10px;
}
#board-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  min-height: 0;
  flex: 1;
}
#board-rows li {
  display: flex;
  gap: 8px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
#board-rows li.mine { color: var(--neon); }
#end .panel {
  width: min(360px, 100%);
  max-height: 100%;
  align-items: stretch;
  text-align: left;
  overflow: auto;
}
#end-waves, #end-score { text-align: center; }
#end-figure {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  align-items: center;
}
#end-art { width: 84px; height: 84px; object-fit: contain; }
#end-name, #end-meta { margin: 0; }
#end-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#home-nav button, .tabs button {
  flex: 1 1 0;
  min-width: 0;
  height: 42px;
  font-size: 16px;
}
#end-actions, #share-actions { align-items: stretch; }
#end-best { text-align: center; color: var(--neon); font-size: 13px; white-space: nowrap; }
#share {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(8, 6, 4, 0.94);
}
#share-card {
  width: min(210px, 62vw);
  height: auto;
  flex: 0 1 auto;
  min-height: 0;
  background: #100e0c;
  border: 1px solid var(--neon);
}
#share-text {
  margin: 0;
  text-align: center;
  white-space: pre-line;
  word-break: break-all;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.35;
}
#share-actions { width: min(360px, 100%); }
.unit.halo-ring { box-shadow: inset 0 0 0 1px #7ee0ff, 0 0 8px rgba(126, 224, 255, 0.45); }
.unit.halo-sparkle { box-shadow: inset 0 0 0 1px var(--neon), 0 0 10px rgba(255, 183, 3, 0.55); }
#end-art.halo-ring { filter: drop-shadow(0 0 8px #7ee0ff); }
#end-art.halo-sparkle { filter: drop-shadow(0 0 8px #ffb703); }
@media (max-height: 600px) {
  #raised img { width: 88px; height: 88px; }
  .choice { min-height: 64px; padding: 6px; }
  .choice img { width: 52px; height: 52px; }
  #sheet { gap: 6px; padding-top: 8px; }
}
main {
  max-width: 28rem;
  margin: 12vh auto;
  padding: 0 24px;
}
main h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: 0.04em; }
main p { color: var(--muted); }
main a { color: var(--neon); }
