:root {
  --bg: #07101c;
  --panel: rgba(14, 22, 38, 0.94);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eaf0ff;
  --muted: #93a0c2;
  --accent: #22d3ee;
  --gold: #fbbf24;
  --fruit: #a855f7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.back {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  z-index: 6;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
}

/* ---- in-match buttons ---- */

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.hud button { pointer-events: auto; touch-action: none; }

.super {
  position: absolute;
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font: 800 13px system-ui, sans-serif;
  letter-spacing: 0.06em;
  background: conic-gradient(#facc15 var(--charge, 0%), rgba(0, 0, 0, 0.55) 0);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
}
.super span {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(10, 16, 30, 0.88);
}
.super.ready { animation: pulse 0.9s ease-in-out infinite; border-color: #fde047; }
.super.ready span { background: #b45309; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.quit {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font: inherit;
  font-size: 13px;
}

.toast {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 10px 22px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 26px;
  font-weight: 800;
  pointer-events: none;
  text-align: center;
}

/* ---- screens ---- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: auto;
  background: radial-gradient(1000px 600px at 50% 0%, rgba(34, 211, 238, 0.12), transparent 60%), rgba(4, 8, 16, 0.78);
}

.panel {
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}
.panel.wide { width: min(760px, 100%); }
.panel h1 { margin: 0; font-size: 34px; letter-spacing: 0.03em; }
.panel h2 { margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tag { margin: 4px 0 12px; color: var(--muted); }
.muted { color: var(--muted); margin: 2px 0; }
.note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.hero { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 6px 0 10px; text-align: left; }
.hero canvas { width: 130px; height: 130px; flex: none; }
.blurb { margin: 6px 0 0; font-size: 13.5px; color: #cdd6f0; }

.stats { display: flex; gap: 10px; justify-content: center; margin: 8px 0 12px; }
.stats > div { flex: 1; padding: 8px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); display: grid; }
.stats.single > div { max-width: 220px; margin: 0 auto; }
.label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: #aab3d0; }
.big { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gold { color: var(--gold); }

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.btn {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 20px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-big { font-size: 18px; font-weight: 800; padding: 12px 34px; }
.btn-primary { background: var(--accent); color: #032a33; border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: #67e8f9; }
.btn-fruit { background: linear-gradient(135deg, #a855f7, #ec4899); border-color: transparent; color: #fff; font-weight: 700; }
.btn-fruit:hover:not(:disabled) { filter: brightness(1.12); background: linear-gradient(135deg, #a855f7, #ec4899); }

.controls { display: grid; gap: 4px; margin: 14px auto 0; max-width: 420px; text-align: left; font-size: 13px; }
.controls div { display: flex; justify-content: space-between; gap: 14px; }
.controls dd { margin: 0; color: var(--muted); text-align: right; }
kbd { font: 11.5px ui-monospace, Menlo, monospace; padding: 1px 5px; margin-right: 2px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line); }

/* ---- crew ---- */

.crew-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 12px; }
@media (max-width: 560px) { .crew-grid { grid-template-columns: repeat(2, 1fr); } }
.card {
  position: relative;
  padding: 8px 6px 10px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  text-align: center;
}
.card canvas { width: 76px; height: 76px; display: block; margin: 0 auto; }
.card .name { font-weight: 700; font-size: 13px; }
.card .lvl { font-size: 11px; color: var(--gold); }
.card.sel { border-color: var(--accent); background: rgba(34, 211, 238, 0.12); }
.card.locked { opacity: 0.55; filter: grayscale(0.8); }
.card.view { border-color: rgba(255, 255, 255, 0.4); }
.detail { text-align: left; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); min-height: 110px; font-size: 13.5px; }
.detail h3 { margin: 0 0 4px; }
.detail .row { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0; color: #cdd6f0; }
.detail .row b { color: #fff; }

/* ---- shop ---- */

#fruit { display: block; width: min(320px, 100%); height: auto; margin: 6px auto; }
.shop-result { margin: 6px 0; padding: 10px 12px; border-radius: 14px; background: rgba(168, 85, 247, 0.16); border: 1px solid rgba(168, 85, 247, 0.5); }
.shop-result h3 { margin: 0 0 2px; font-size: 20px; }

/* ---- brawler strip on the home screen ---- */

.strip-label { margin: 10px 0 4px; }
.strip { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 6px; }
@media (max-width: 560px) { .strip { grid-template-columns: repeat(4, 1fr); } }
.chip {
  position: relative;
  padding: 4px 2px 5px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  text-align: center;
}
.chip canvas { width: 100%; max-width: 54px; aspect-ratio: 1; display: block; margin: 0 auto; }
.chip .nm { font-size: 10.5px; line-height: 1.1; color: #cdd6f0; }
.chip.sel { border-color: var(--accent); background: rgba(34, 211, 238, 0.14); }
.chip.locked { opacity: 0.45; cursor: default; filter: grayscale(0.7); }
.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; margin-top: 8px; }
.link:hover { color: #fff; }

/* ---- starters ---- */

.starter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
@media (max-width: 640px) { .starter-grid { grid-template-columns: 1fr; } }
.starter {
  padding: 12px 10px 14px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  text-align: center;
}
.starter:hover { border-color: var(--accent); background: rgba(34, 211, 238, 0.1); }
.starter canvas { width: 120px; height: 120px; display: block; margin: 0 auto; }
.starter h3 { margin: 4px 0 0; }
.starter p { margin: 4px 0 0; font-size: 12.5px; color: #cdd6f0; }

/* ---- shop ---- */

.shop-main { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.shop-side { flex: 1 1 200px; min-width: 190px; text-align: center; }
.shop-side h3 { margin: 8px 0 2px; font-size: 20px; }
.fruit-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
@media (max-width: 640px) { .fruit-list { grid-template-columns: repeat(2, 1fr); } }
.fruit-card {
  padding: 8px 4px 9px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  text-align: center;
}
.fruit-card canvas { width: 62px; height: 62px; display: block; margin: 0 auto; }
.fruit-card .fn { font-weight: 700; font-size: 12.5px; }
.fruit-card .fp { font-size: 12px; color: var(--gold); font-weight: 700; }
.fruit-card .fs { font-size: 11px; color: var(--muted); }
.fruit-card.sel { border-color: #c084fc; background: rgba(168, 85, 247, 0.16); }
.fruit-card.poor .fp { color: #f87171; }
.fruit-card.maxed { opacity: 0.55; }

/* the flat layer (health bars, numbers, score) sits over the 3D scene */
.overlay2d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* ---- modes, arenas, trophies ---- */
.strip.modes, .strip.maps { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 4px 0; }
.opt { padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,0.07); border: 2px solid transparent; cursor: pointer; font-weight: 700; font-size: 13px; text-align: center; min-width: 92px; }
.opt small { display: block; font-weight: 500; opacity: 0.7; font-size: 11px; }
.opt:hover { background: rgba(255,255,255,0.14); }
.opt.sel { border-color: var(--accent); background: rgba(34,211,238,0.14); }
.mode-blurb { margin: 2px 0 6px; min-height: 1.3em; }
.stats .red, .red { color: #f87171; }
.xpbar { height: 7px; border-radius: 99px; background: rgba(255,255,255,0.1); overflow: hidden; margin: 0 auto 8px; max-width: 420px; }
.xpbar #xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #22d3ee, #a855f7); }
#chest-canvas { display: block; margin: 8px auto; }
.chip .tro { font-size: 10px; opacity: 0.8; }
