/* =========================================================
   旋刃纪元 · SPIN ARENA
   Design system: dark industrial arena + neon spin energy
   ========================================================= */

:root {
  --bg: #060a12;
  --bg-2: #0a1220;
  --panel: #111b2c;
  --panel-2: #0d1626;
  --panel-3: #16233a;
  --cell: #101c30;
  --line: rgba(120, 165, 225, 0.16);
  --line-strong: rgba(130, 180, 240, 0.3);
  --ink: #e9f2ff;
  --ink-2: #b9cbe4;
  --dim: #7f95b6;
  --cyan: #33e3cf;
  --cyan-soft: rgba(51, 227, 207, 0.16);
  --orange: #ff6a2a;
  --orange-2: #ff9147;
  --violet: #7b5cff;
  --blue: #3d8bff;
  --red: #ff3d5f;
  --gold: #ffc94a;
  --green: #3ddc84;
  --radius: 16px;
  --dock-h: 88px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, "Roboto Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(51, 227, 207, 0.10), transparent 60%),
    radial-gradient(90% 50% at 110% 20%, rgba(123, 92, 255, 0.12), transparent 65%),
    linear-gradient(180deg, #070d18 0%, #05080f 55%, #04070d 100%);
}

button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 8px; }

/* ---------------- App shell ---------------- */
.app {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 165, 225, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 165, 225, 0.045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(120% 80% at 50% 0%, #000 20%, transparent 78%);
  z-index: 0;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.24s;
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; }

/* ---------------- Header / HUD ---------------- */
.hud {
  position: relative;
  padding: 12px 16px 8px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 27, 44, 0.9), rgba(9, 15, 26, 0.55));
  backdrop-filter: blur(6px);
}

.hud__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }

.brand__mark {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--cyan), #0f9c97);
  color: #041018;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 0 0 1px rgba(51, 227, 207, 0.5), 0 6px 18px rgba(51, 227, 207, 0.28);
  animation: markPulse 3.4s ease-in-out infinite;
}
@keyframes markPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(51, 227, 207, 0.45), 0 6px 16px rgba(51, 227, 207, 0.2); }
  50% { box-shadow: 0 0 0 1px rgba(51, 227, 207, 0.75), 0 6px 22px rgba(51, 227, 207, 0.42); }
}

.brand__text { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.brand__title {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-style: italic;
  background: linear-gradient(180deg, #ffffff 10%, #b9cbe4 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand__sub {
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.34em;
  color: var(--cyan);
  text-transform: uppercase;
  opacity: 0.85;
}

.hud__right { text-align: right; flex: 0 0 auto; }
.rank-line { display: flex; align-items: baseline; gap: 6px; justify-content: flex-end; }
.rank-line__label { font-size: 9px; letter-spacing: 0.22em; color: var(--dim); }
.rank-line__value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}
.rank-line__value b { color: var(--cyan); font-weight: 700; }

.rank-name {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-top: 2px;
  text-transform: uppercase;
}
.rank-collect {
  font-size: 10px;
  color: var(--dim);
  margin-top: 3px;
  letter-spacing: 0.04em;
}

.stat-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-transform: uppercase;
  flex-wrap: wrap;
}
.stat-strip b {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0;
  font-weight: 700;
}
.stat-strip .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }
.stat-strip .hl b { color: var(--gold); }

.meter {
  position: relative;
  height: 7px;
  margin-top: 9px;
  border-radius: 99px;
  background: #0a1322;
  border: 1px solid var(--line);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), #59f0d9 55%, var(--violet));
  box-shadow: 0 0 14px rgba(51, 227, 207, 0.6);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.hud__icons {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
}

/* ---------------- Workshop ---------------- */
.workshop {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.workshop::-webkit-scrollbar { display: none; }

.board-panel {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  border-radius: 20px;
  padding: 10px;
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(61, 139, 255, 0.10), transparent 70%),
    linear-gradient(180deg, #101b2d, #0b1422);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 40px rgba(0, 0, 0, 0.45);
}

.board-panel::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 16px;
  border: 1px solid rgba(120, 165, 225, 0.09);
  pointer-events: none;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-height: 0;
}

.cell {
  position: relative;
  min-height: 58px;
  border-radius: 12px;
  border: 1px solid rgba(120, 165, 225, 0.12);
  background: linear-gradient(180deg, #131f33, #0f1929);
  display: grid;
  place-items: center;
  padding: 3px;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  min-width: 0;
  overflow: hidden;
}
.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 60% at 50% 40%, rgba(61, 139, 255, 0.12), transparent 70%);
  opacity: 0;
  transition: opacity 0.2s;
}
.cell.is-empty:hover::before,
.cell.is-empty:focus-visible::before { opacity: 1; }

.cell__plus {
  font-size: 17px;
  color: rgba(150, 185, 230, 0.28);
  font-weight: 300;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
}
.cell.is-empty:hover .cell__plus { color: var(--cyan); transform: rotate(90deg); }

.cell.is-filled { cursor: pointer; }
.cell.is-filled::before { opacity: 1; background: radial-gradient(65% 65% at 50% 45%, color-mix(in srgb, var(--tint, #3d8bff) 26%, transparent), transparent 72%); }

.cell__top {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}
.cell__top svg { width: 94%; height: 94%; display: block; filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.55)); }

.cell__label {
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  text-align: center;
  font-size: 7.5px;
  line-height: 1.15;
  letter-spacing: 0.02em;
  font-weight: 700;
  color: var(--tint, #cfdfff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 2;
  text-shadow: 0 1px 3px #000;
}

.cell.is-selected {
  border-color: var(--cyan);
  background: linear-gradient(180deg, #14313a, #0e2230);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 22px rgba(51, 227, 207, 0.4);
  transform: translateY(-2px);
}
.cell.is-match {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255, 201, 74, 0.4);
  animation: matchBlink 1.1s ease-in-out infinite;
}
@keyframes matchBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.62; } }

.cell.is-new .cell__top { animation: dropIn 0.42s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes dropIn {
  from { transform: scale(0.3) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.cell.is-merging .cell__top { animation: mergePop 0.46s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes mergePop {
  0% { transform: scale(0.5); opacity: 0.2; }
  60% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* Spin animation of tops */
.spin-slow { animation: spin 7s linear infinite; transform-origin: 50% 50%; }
.spin-mid { animation: spin 3.4s linear infinite; transform-origin: 50% 50%; }
.spin-fast { animation: spin 1.5s linear infinite; transform-origin: 50% 50%; }
@keyframes spin { to { transform: rotate(360deg); } }

/* particle burst on merge */
.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
.burst i {
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--gold);
  animation: burstOut 0.6s ease-out forwards;
}
@keyframes burstOut {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); opacity: 0; }
}

/* ---------------- Rank progress card ---------------- */
.rank-card {
  margin-top: 9px;
  padding: 10px 12px 11px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 31, 51, 0.85), rgba(11, 20, 33, 0.9));
  flex: 0 0 auto;
}
.rank-card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.rank-card__rank {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.rank-card__next {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.rank-bar {
  height: 6px;
  margin: 7px 0 6px;
  border-radius: 99px;
  background: #0a1322;
  border: 1px solid var(--line);
  overflow: hidden;
}
.rank-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--violet), #a98bff 60%, var(--cyan));
  box-shadow: 0 0 12px rgba(123, 92, 255, 0.55);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.rank-card__last {
  font-size: 9.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.rank-card__last b { color: var(--cyan); font-weight: 700; }
.rank-card__last b.is-bad { color: #ff8098; }
.rank-card__pts {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex: 0 0 auto;
}
.rank-card__pts b { font-family: var(--mono); font-size: 11px; color: var(--ink); }

/* ---------------- Selection / forge bar ---------------- */

.forge {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px;
  gap: 8px;
  flex: 0 0 auto;
}

.forge__card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 14px;
  background: linear-gradient(180deg, #131f33, #0d1727);
  border: 1px solid var(--line);
  min-width: 0;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}
.forge__card:hover { border-color: var(--line-strong); }

.forge__thumb {
  width: 42px; height: 42px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 11px;
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,0.07), rgba(0,0,0,0.35));
  border: 1px solid var(--line);
}
.forge__thumb svg { width: 34px; height: 34px; }
.forge__thumb--stack { position: relative; }
.forge__thumb--stack svg:last-child { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; }

.forge__body { min-width: 0; flex: 1 1 auto; }
.forge__title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forge__meta {
  margin-top: 3px;
  font-size: 10px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forge__meta b { color: var(--ink-2); font-family: var(--mono); font-weight: 600; }
.forge__price {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--orange-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.forge__price small { font-size: 9px; letter-spacing: 0.1em; color: var(--dim); margin-left: 3px; }
.forge__price.is-poor { color: #6d7f99; }

.dustbin {
  border-radius: 14px;
  border: 1px solid rgba(255, 61, 95, 0.4);
  background: linear-gradient(180deg, rgba(255, 61, 95, 0.14), rgba(255, 61, 95, 0.05));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #ff8098;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.dustbin:hover { background: rgba(255, 61, 95, 0.2); border-color: var(--red); }
.dustbin:active { transform: scale(0.96); }
.dustbin svg { width: 17px; height: 17px; }
.dustbin span { font-size: 8.5px; letter-spacing: 0.1em; font-weight: 800; text-transform: uppercase; }

/* ---------------- Dock ---------------- */
.dock {
  flex: 0 0 auto;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 84px;
  gap: 8px;
  align-items: stretch;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 17, 29, 0.72), rgba(6, 10, 18, 0.96));
  backdrop-filter: blur(8px);
}

.dock__mini {
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #131f33, #0d1727);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  min-width: 0;
  transition: transform 0.15s, border-color 0.2s;
}
.dock__mini:active { transform: scale(0.96); }
.dock__mini svg { width: 30px; height: 30px; }
.dock__mini span {
  font-size: 8.5px;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
}
.dock__mini--arena {
  border-color: rgba(123, 92, 255, 0.45);
  background: linear-gradient(180deg, #251c4d, #171034);
  box-shadow: inset 0 0 22px rgba(123, 92, 255, 0.35);
}
.dock__mini--arena span { color: #b9a6ff; }
.dock__mini--arena svg { width: 34px; height: 34px; }

.dock__spawn {
  position: relative;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--orange-2), #f4571a 55%, #cf3f0c);
  box-shadow: 0 4px 0 #8f2b06, 0 10px 26px rgba(255, 106, 42, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 8px 6px;
  overflow: hidden;
  transition: transform 0.1s, box-shadow 0.12s, filter 0.2s;
}
.dock__spawn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8f2b06, 0 4px 12px rgba(255, 106, 42, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.dock__spawn:disabled { filter: grayscale(0.55) brightness(0.75); }
.dock__spawn strong {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.14em;
  font-style: italic;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}
.dock__spawn small { font-size: 8.5px; letter-spacing: 0.05em; opacity: 0.92; white-space: nowrap; }
.dock__spawn::after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-18deg);
  animation: sheen 3.6s ease-in-out infinite;
}
@keyframes sheen { 0%, 65% { left: -60%; } 100% { left: 130%; } }

.hint-line {
  flex: 0 0 auto;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  color: rgba(127, 149, 182, 0.75);
  padding: 0 14px 6px;
  background: rgba(6, 10, 18, 0.96);
}

/* ---------------- Sub screens (dex / profile) ---------------- */
.sub {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sub__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(19, 31, 51, 0.9);
  color: var(--ink-2);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:hover { border-color: var(--line-strong); background: #16233a; }
.icon-btn svg { width: 16px; height: 16px; }

.sub__titles { min-width: 0; flex: 1 1 auto; }
.sub__title { font-size: 15px; font-weight: 800; letter-spacing: 0.06em; }
.sub__desc { font-size: 10px; color: var(--dim); margin-top: 2px; letter-spacing: 0.03em; }

.sub__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: #26364f transparent;
}
.sub__body::-webkit-scrollbar { width: 5px; }
.sub__body::-webkit-scrollbar-thumb { background: #26364f; border-radius: 9px; }

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 16px 0 8px;
}
.section-label:first-child { margin-top: 0; }
.section-label::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }

/* dex */
.dex-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.dex-card {
  position: relative;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #131f33, #0c1524);
  padding: 9px 6px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.dex-card:active { transform: scale(0.97); }
.dex-card svg { width: 54px; height: 54px; }
.dex-card__no {
  position: absolute;
  top: 5px; left: 7px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--dim);
  letter-spacing: 0.04em;
}
.dex-card__name {
  font-size: 10px;
  font-weight: 700;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.dex-card__type { font-size: 8px; color: var(--dim); letter-spacing: 0.06em; }
.dex-card.is-locked { filter: saturate(0.08); opacity: 0.5; }
.dex-card.is-locked .dex-card__name { color: var(--dim); }
.dex-card.is-owned { border-color: rgba(51, 227, 207, 0.32); }
.dex-card.is-owned::after {
  content: "已收集";
  position: absolute;
  top: 5px; right: 5px;
  font-size: 7px;
  color: var(--cyan);
  letter-spacing: 0.06em;
}
.dex-card.is-new { box-shadow: 0 0 0 1px var(--gold), 0 0 20px rgba(255, 201, 74, 0.3); }

/* profile */
.player-card {
  position: relative;
  border-radius: 18px;
  padding: 14px;
  border: 1px solid rgba(51, 227, 207, 0.24);
  background:
    radial-gradient(110% 90% at 0% 0%, rgba(51, 227, 207, 0.16), transparent 60%),
    radial-gradient(90% 80% at 100% 100%, rgba(123, 92, 255, 0.2), transparent 60%),
    linear-gradient(180deg, #122033, #0b1524);
  overflow: hidden;
}
.player-card__rank {
  font-size: 26px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff, #93e9dd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.player-card__sub { font-size: 10.5px; color: var(--cyan); letter-spacing: 0.14em; margin-top: 3px; }
.player-card__pts {
  position: absolute;
  top: 14px; right: 14px;
  text-align: right;
}
.player-card__pts b { display: block; font-family: var(--mono); font-size: 20px; font-weight: 800; }
.player-card__pts span { font-size: 8.5px; letter-spacing: 0.16em; color: var(--dim); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.stat-cell {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(19, 31, 51, 0.75);
  padding: 9px 8px;
  min-width: 0;
}
.stat-cell b {
  display: block;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.stat-cell span { font-size: 9px; color: var(--dim); letter-spacing: 0.08em; }
.stat-cell.is-win b { color: var(--cyan); }
.stat-cell.is-loss b { color: #ff8098; }
.stat-cell.is-best b { color: var(--gold); }

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(19, 31, 51, 0.7);
  font-size: 11.5px;
}
.info-row + .info-row { margin-top: 7px; }
.info-row__label { color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.info-row__value { color: var(--dim); font-family: var(--mono); font-size: 10.5px; text-align: right; }
.info-row__value.is-ok { color: var(--cyan); }
.info-row__value.is-warn { color: var(--gold); }
.dot-led { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); flex: 0 0 auto; }
.dot-led.is-warn { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.history { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(17, 27, 44, 0.6);
  min-width: 0;
}
.history-item__badge {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}
.history-item__badge.win { background: rgba(51, 227, 207, 0.14); color: var(--cyan); border: 1px solid rgba(51, 227, 207, 0.3); }
.history-item__badge.loss { background: rgba(255, 61, 95, 0.12); color: #ff8098; border: 1px solid rgba(255, 61, 95, 0.28); }
.history-item__main { min-width: 0; }
.history-item__title { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item__meta { font-size: 9px; color: var(--dim); margin-top: 2px; font-family: var(--mono); }
.history-item__pts { font-family: var(--mono); font-size: 11px; color: var(--gold); text-align: right; white-space: nowrap; }

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 20px 14px;
  text-align: center;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.7;
}

.btn-danger {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 61, 95, 0.35);
  background: rgba(255, 61, 95, 0.1);
  color: #ff8098;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.2s;
}
.btn-danger:hover { background: rgba(255, 61, 95, 0.18); }

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.06em;
}

/* ---------------- Detail sheet ---------------- */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.22s, visibility 0.22s;
}
.sheet.is-open { opacity: 1; visibility: visible; }
.sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 14, 0.72);
  backdrop-filter: blur(3px);
}
.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  background: linear-gradient(180deg, #15223a, #0b1422);
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(14px);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 86%;
  overflow-y: auto;
}
.sheet.is-open .sheet__panel { transform: none; }
.sheet__grip { width: 38px; height: 4px; border-radius: 99px; background: #2a3d58; margin: 0 auto 12px; }
.sheet__hero { display: flex; align-items: center; gap: 12px; }
.sheet__hero svg { width: 66px; height: 66px; flex: 0 0 auto; }
.sheet__name { font-size: 19px; font-weight: 800; letter-spacing: 0.01em; }
.sheet__en { font-size: 9.5px; color: var(--dim); letter-spacing: 0.16em; text-transform: uppercase; margin-top: 3px; }
.sheet__tags { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.tag {
  font-size: 9px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  letter-spacing: 0.06em;
}
.tag--type { color: var(--cyan); border-color: rgba(51, 227, 207, 0.34); background: rgba(51, 227, 207, 0.08); }
.tag--tier { color: var(--gold); border-color: rgba(255, 201, 74, 0.3); background: rgba(255, 201, 74, 0.07); }

.sheet__stats { margin-top: 14px; display: grid; gap: 9px; }
.stat-bar { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; align-items: center; gap: 9px; font-size: 10px; color: var(--dim); }
.stat-bar__track { height: 6px; border-radius: 99px; background: #0a1322; border: 1px solid var(--line); overflow: hidden; }
.stat-bar__fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--cyan), var(--blue)); }
.stat-bar b { font-family: var(--mono); font-size: 10px; color: var(--ink-2); text-align: right; font-weight: 600; }

.sheet__lore { margin-top: 13px; font-size: 11.5px; line-height: 1.75; color: var(--ink-2); }

.sheet__actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; margin-top: 16px; }
.btn-primary, .btn-ghost {
  padding: 13px 12px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  transition: transform 0.12s, filter 0.2s, background 0.2s;
}
.btn-primary {
  background: linear-gradient(180deg, var(--orange-2), #ef5418);
  color: #fff;
  box-shadow: 0 3px 0 #8f2b06, 0 8px 20px rgba(255, 106, 42, 0.28);
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #8f2b06; }
.btn-primary:disabled { filter: grayscale(0.6) brightness(0.7); box-shadow: none; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }

/* ---------------- Toast ---------------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h) + 96px);
  transform: translate(-50%, 10px);
  z-index: 60;
  max-width: calc(100% - 36px);
  text-align: center;
  padding: 9px 15px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(11, 19, 33, 0.98);
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.03em;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.24s;
  max-width: 86%;
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Battle screen ---------------- */
#screen-battle {
  background:
    radial-gradient(90% 50% at 50% 22%, rgba(123, 92, 255, 0.15), transparent 62%),
    linear-gradient(180deg, #080e1a 0%, #05080f 100%);
  z-index: 5;
}

.battle {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 0;
  overflow: hidden;
}

.battle__head { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; }
.battle__round {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.battle__round b { color: var(--ink); font-family: var(--mono); font-size: 11px; }

.spin-bars { display: grid; gap: 6px; margin-top: 9px; flex: 0 0 auto; }
.spin-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) 34px; align-items: center; gap: 8px; }
.spin-row__name {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-2);
}
.spin-track {
  height: 9px;
  border-radius: 99px;
  background: #0a1322;
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}
.spin-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.spin-fill--p { background: linear-gradient(90deg, #12a892, var(--cyan)); box-shadow: 0 0 12px rgba(51, 227, 207, 0.5); }
.spin-fill--o { background: linear-gradient(90deg, #9a2b48, var(--red)); box-shadow: 0 0 12px rgba(255, 61, 95, 0.45); }
.spin-row__val { font-family: var(--mono); font-size: 10px; color: var(--dim); text-align: right; }

.arena {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 10px 0 0;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    radial-gradient(60% 60% at 50% 45%, rgba(61, 139, 255, 0.14), transparent 74%),
    linear-gradient(180deg, #0d1830, #060c18);
  overflow: hidden;
  box-shadow: inset 0 0 44px rgba(0, 0, 0, 0.55);
  touch-action: manipulation;
}

#arenaCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.arena__tag {
  position: absolute;
  left: 50%;
  bottom: 7px;
  transform: translateX(-50%);
  font-size: 8px;
  letter-spacing: 0.16em;
  color: rgba(127, 149, 182, 0.62);
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.arena__callout {
  position: absolute;
  left: 50%;
  top: 13%;
  transform: translate(-50%, 6px);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 16px rgba(255, 210, 120, 0.9), 0 2px 8px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-out, transform 0.18s ease-out;
  white-space: nowrap;
}
.arena__callout.is-on { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
.arena__callout.is-hot { color: #ffd27a; font-size: 19px; }
.arena__callout.is-good { color: #8ff0ff; }
.arena__callout.is-bad { color: #ff8098; font-size: 12px; }

.live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid rgba(51, 227, 207, 0.3);
  background: rgba(51, 227, 207, 0.08);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  white-space: nowrap;
}
.live i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: livePulse 1.1s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.32; transform: scale(0.68); }
}

.energy { flex: 0 0 auto; margin-top: 10px; }
.energy__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}
.energy__head b { font-family: var(--mono); font-size: 10px; letter-spacing: 0; color: var(--gold); }
.energy__track {
  height: 7px;
  border-radius: 99px;
  background: #0a1322;
  border: 1px solid var(--line);
  overflow: hidden;
}
.energy__track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #ff8f3f, var(--gold));
  box-shadow: 0 0 12px rgba(255, 201, 74, 0.5);
  transition: width 0.16s linear;
}

.assists {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}
.assist {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #16253c, #0e1a2c);
  padding: 9px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--ink-2);
  transition: transform 0.1s, border-color 0.22s, box-shadow 0.25s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.assist::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 10, 20, 0.74), rgba(4, 10, 20, 0.74));
  transform-origin: bottom;
  transform: scaleY(var(--cd, 0));
  transition: transform 0.1s linear;
}
.assist:active { transform: scale(0.96); }
.assist.is-ready { border-color: rgba(51, 227, 207, 0.46); color: #eaf6ff; }
.assist.is-ready .assist__icon { color: var(--cyan); }
.assist--burst .assist__icon { color: var(--gold); }
.assist--burst.is-ready {
  border-color: rgba(255, 201, 74, 0.62);
  box-shadow: 0 0 18px rgba(255, 201, 74, 0.34);
  animation: burstGlow 1.2s ease-in-out infinite;
}
@keyframes burstGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 201, 74, 0.5), 0 0 12px rgba(255, 201, 74, 0.22); }
  50% { box-shadow: 0 0 0 1px var(--gold), 0 0 26px rgba(255, 201, 74, 0.55); }
}
.assist__icon {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--dim);
  transition: color 0.2s;
}
.assist__icon svg { width: 19px; height: 19px; }
.assist__name { position: relative; z-index: 1; font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; }
.assist__sub { position: relative; z-index: 1; font-size: 7.5px; color: var(--dim); letter-spacing: 0.04em; }

.battle__log {
  flex: 0 0 auto;
  margin-top: 9px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  min-height: 34px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--ink-2);
  text-align: center;
  letter-spacing: 0.01em;
}
.battle__log b { color: var(--cyan); }
.battle__log b.is-bad { color: #ff8098; }

/* battle result overlay */
.result {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 8, 15, 0.82);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.result.is-open { opacity: 1; visibility: visible; }
.result__card {
  width: 100%;
  max-width: 340px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(51, 227, 207, 0.16), transparent 60%),
    linear-gradient(180deg, #15223a, #0a1422);
  padding: 22px 18px 18px;
  text-align: center;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.result.is-open .result__card { transform: none; }
.result__badge {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
}
.result__card.is-loss .result__badge { color: #ff8098; }
.result__title {
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  margin-top: 5px;
  background: linear-gradient(180deg, #fff, #a8eae1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.05;
}
.result__card.is-loss .result__title { background: linear-gradient(180deg, #fff, #ffb3c1); -webkit-background-clip: text; background-clip: text; }
.result__lines { margin-top: 14px; display: grid; gap: 6px; text-align: left; }
.result__line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-2);
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
}
.result__line b { font-family: var(--mono); color: var(--gold); font-weight: 700; }
.result__line.is-new b { color: var(--cyan); }
.result__actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 8px; margin-top: 16px; }

/* dialog */
dialog.confirm {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #16243c, #0b1524);
  color: var(--ink);
  padding: 18px;
  width: min(88vw, 330px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
}
dialog.confirm::backdrop { background: rgba(3, 7, 14, 0.7); backdrop-filter: blur(4px); }
dialog.confirm h3 { font-size: 15px; letter-spacing: 0.04em; }
dialog.confirm p { font-size: 11.5px; color: var(--ink-2); line-height: 1.7; margin-top: 8px; }
.dialog__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.dialog__actions button { padding: 11px; border-radius: 11px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; }

/* ---------------- Responsive ---------------- */
@media (min-width: 520px) {
  .app {
    height: min(100dvh, 900px);
    margin-top: max(0px, calc((100dvh - 900px) / 2));
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.6);
  }
  body { display: flex; justify-content: center; }
  .cell__label { font-size: 9px; }
  .dex-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .app { max-width: 480px; }
  .board { gap: 10px; }
}

@media (max-height: 700px) {
  .brand__title { font-size: 17px; }
  .arena { min-height: 140px; }
  .assist { padding: 7px 3px 6px; }
  .assist__sub { display: none; }
  .battle__log { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}
