:root {
  --page-top: #070a20;
  --page-bottom: #120d2d;
  --ink: #eef4ff;
  --muted: #a7b4d7;
  --accent: #66f7d4;
  --accent-dark: #4b5fff;
  --glass: rgba(12, 18, 48, 0.7);
  --glass-strong: rgba(13, 18, 46, 0.96);
  --shadow: rgba(0, 0, 0, 0.42);
  --overlay: rgba(4, 7, 23, 0.52);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  background:
    radial-gradient(circle at 15% 18%, rgba(51, 96, 255, 0.3), transparent 26%),
    radial-gradient(circle at 84% 78%, rgba(235, 66, 255, 0.18), transparent 24%),
    linear-gradient(180deg, var(--page-top), var(--page-bottom));
}

body {
  padding:
    calc(14px + env(safe-area-inset-top))
    calc(14px + env(safe-area-inset-right))
    calc(14px + env(safe-area-inset-bottom))
    calc(14px + env(safe-area-inset-left));
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.arena-frame {
  position: relative;
  min-height: calc(100vh - 28px);
  min-height: calc(100dvh - 28px);
  padding: 18px;
  border-radius: 34px;
  background:
    linear-gradient(155deg, rgba(101, 120, 255, 0.16), transparent 30%),
    rgba(6, 9, 29, 0.88);
  border: 1px solid rgba(130, 157, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 26px 60px var(--shadow), 0 0 80px rgba(68, 83, 255, 0.12);
  overflow: hidden;
}

.arena-stage {
  position: relative;
  z-index: 1;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  min-height: 560px;
  border-radius: 24px;
  overflow: hidden;
}

.arena-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 14% 18%, rgba(52, 248, 215, 0.12), transparent 16%),
    radial-gradient(circle at 84% 80%, rgba(235, 86, 255, 0.12), transparent 14%);
  pointer-events: none;
}

#gameCanvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
}

.hud-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.top-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  pointer-events: auto;
}

.top-chip {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid rgba(127, 151, 255, 0.24);
  backdrop-filter: blur(14px);
}

.hud-chip-button {
  display: inline-flex;
  width: auto;
  flex: 0 0 auto;
  max-width: max-content;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgba(127, 151, 255, 0.24);
  border-radius: 999px;
  color: #eaf0ff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: var(--glass);
  backdrop-filter: blur(14px);
  box-shadow: none;
  white-space: nowrap;
}

.hud-chip-button:hover,
.hud-chip-button:focus-visible {
  background: rgba(255, 255, 255, 0.34);
}

.top-chip-right {
  position: absolute;
  top: 10px;
  left: auto;
  right: 10px;
}

.hud-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8fa0cf;
}

.hud-value {
  font-size: 17px;
  font-weight: 900;
  color: #f6f8ff;
}

.hud-value-small { font-size: 13px; color: #66f7d4; }

.compare-button { color: #66f7d4 !important; }

.surge-panel {
  position: absolute;
  top: 62px;
  left: 12px;
  width: min(250px, 36vw);
  padding: 10px 12px;
  border: 1px solid rgba(127, 151, 255, 0.22);
  border-radius: 16px;
  background: rgba(8, 12, 36, 0.66);
  backdrop-filter: blur(12px);
}

.surge-copy { display: flex; justify-content: space-between; gap: 12px; color: #cbd5f3; font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.boost-track { height: 5px; margin-top: 7px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.1); }
.boost-track span { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #54e8ff, #66f7d4 60%, #fff487); box-shadow: 0 0 12px #66f7d4; transition: width .08s linear; }

.leaderboard-panel {
  position: absolute;
  top: 58px;
  right: 10px;
  width: min(260px, 36vw);
  padding: 6px 4px;
}

.minimap-panel {
  position: absolute;
  left: 10px;
  bottom: 12px;
  width: min(170px, 26vw);
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 24px;
  background: rgba(7, 11, 32, 0.7);
  border: 1px solid rgba(127, 151, 255, 0.22);
  backdrop-filter: blur(6px);
}

.minimap-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 18px;
}

.leaderboard {
  display: grid;
  gap: 8px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(7, 11, 32, 0.6);
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.row-name {
  font-size: 14px;
  font-weight: 900;
  color: #eef3ff;
  text-shadow: 0 0 12px rgba(91, 239, 255, .28);
}

.row-score {
  font-size: 13px;
  font-weight: 800;
  color: #9eb0dc;
  text-shadow: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: var(--overlay);
  backdrop-filter: blur(4px);
}

.hidden {
  display: none;
}

.pause-overlay {
  z-index: 4;
  background: rgba(3, 5, 18, .46);
  pointer-events: none;
}

.pause-card {
  width: min(390px, calc(100% - 32px));
  padding: 28px 24px;
  border: 1px solid rgba(102, 247, 212, .3);
  border-radius: 26px;
  text-align: center;
  background: rgba(7, 11, 34, .92);
  box-shadow: 0 26px 70px rgba(0,0,0,.5), 0 0 60px rgba(102,247,212,.12);
}

kbd {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid rgba(255,255,255,.24);
  border-bottom-width: 3px;
  border-radius: 7px;
  color: #eef4ff;
  background: rgba(255,255,255,.08);
  font: 800 12px/1.2 inherit;
}

.modal-card {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 26px 24px 22px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(160deg, rgba(20, 27, 69, .98), rgba(8, 12, 35, .98));
  border: 1px solid rgba(126, 154, 255, .32);
  box-shadow: 0 26px 70px rgba(0,0,0,.5), 0 0 60px rgba(73, 91, 255, .16);
}

#startOverlay .modal-card {
  width: min(580px, calc(100% - 32px));
}

.modal-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-title,
.modal-subtitle {
  margin: 0;
  line-height: 1.05;
  color: #f4f6ff;
}

.modal-title span { color: #66f7d4; text-shadow: 0 0 26px rgba(102,247,212,.36); }

.modal-title {
  font-size: 34px;
}

.modal-subtitle {
  font-size: 30px;
}

.modal-copy {
  margin: 10px 0 16px;
  line-height: 1.45;
  color: var(--muted);
}

.career-summary,
.arena-record,
.tour-record,
.win-stats {
  display: grid;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid rgba(126, 154, 255, .18);
  border-radius: 15px;
  color: var(--muted);
  background: rgba(5, 9, 29, .56);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
}

.career-summary {
  grid-template-columns: repeat(4, 1fr);
  margin: 14px 0 12px;
}

.daily-gauntlet-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px 13px;
  border: 1px solid rgba(102, 247, 212, .28);
  border-radius: 17px;
  background:
    radial-gradient(circle at 90% 10%, rgba(232, 154, 255, .2), transparent 42%),
    linear-gradient(135deg, rgba(23, 69, 80, .8), rgba(12, 18, 48, .88));
  text-align: left;
}

.daily-gauntlet-card.completed {
  border-color: rgba(255, 226, 107, .38);
}

.daily-gauntlet-copy {
  min-width: 0;
}

.daily-gauntlet-copy span {
  display: block;
  color: #66f7d4;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.daily-gauntlet-copy strong {
  display: block;
  margin-top: 3px;
  color: #f5f7ff;
  font-size: 15px;
}

.daily-gauntlet-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
}

.daily-gauntlet-card button {
  width: auto;
  min-width: 120px;
  white-space: nowrap;
}

.career-stat strong,
.arena-record strong,
.win-stat strong {
  display: block;
  color: #f5f7ff;
  font-size: 17px;
}

.arena-record {
  grid-column: 1 / -1;
  grid-template-columns: 1fr auto;
  margin-top: 1px;
}

.arena-rule {
  grid-column: 1 / -1;
  display: grid;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(126, 154, 255, .14);
}

.arena-rule strong { font-size: 13px; }

.tour-record {
  grid-column: 1 / -1;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 1px;
}

.tour-record strong { display: block; color: #f5f7ff; font-size: 15px; }
.tour-medals { color: #ffe26b; font-size: 16px; letter-spacing: .08em; text-align: right; }
.tour-record.single { display: none; }

.arena-mastery {
  color: #66f7d4;
  letter-spacing: .08em;
  text-align: right;
}

.mutation-card {
  width: min(760px, calc(100% - 32px));
}

.mutation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mutation-option {
  min-height: 166px;
  padding: 17px 14px;
  border: 1px solid rgba(126, 154, 255, .22);
  border-radius: 19px;
  color: #f5f7ff;
  background:
    radial-gradient(circle at 86% 8%, var(--mutation-glow, rgba(102,247,212,.22)), transparent 42%),
    rgba(10, 16, 45, .9);
  box-shadow: 0 14px 28px rgba(0,0,0,.24);
  text-align: left;
}

.mutation-option:hover {
  transform: translateY(-3px);
}

.mutation-icon,
.mutation-name,
.mutation-description {
  display: block;
}

.mutation-icon {
  margin-bottom: 10px;
  color: #66f7d4;
  font-size: 28px;
}

.mutation-name {
  margin-bottom: 6px;
  color: #eef4ff;
  font-size: 17px;
  font-weight: 950;
}

.mutation-description {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
}

.win-stats {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 13px;
  text-align: center;
}

.win-stats.tour-round { grid-template-columns: repeat(4, 1fr); }
.win-stats.tour-stats { grid-template-columns: repeat(4,1fr); }

.standings-table {
  overflow: hidden;
  margin: 0 0 14px;
  border: 1px solid rgba(126,154,255,.2);
  border-radius: 16px;
  background: rgba(7,12,38,.72);
  text-align: left;
}

.standings-heading,
.standings-row {
  display: grid;
  grid-template-columns: 34px minmax(0,1fr) 54px 54px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
}

.standings-heading {
  color: #8493bd;
  background: rgba(90,106,205,.12);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.standings-row {
  border-top: 1px solid rgba(126,154,255,.1);
  color: #c3ccef;
  font-size: 11px;
  font-weight: 800;
}

.standings-row.is-player {
  color: #fff;
  background: linear-gradient(90deg,rgba(102,247,212,.14),rgba(102,247,212,.02));
}

.standings-rank { color: #ffe26b; font-weight: 950; }
.standings-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings-points { color: #66f7d4; font-weight: 950; text-align: right; }
.standings-wins { text-align: right; }
.final-standings { margin-top: 2px; }

.arena-locked {
  color: #7f89aa;
}

.form-grid {
  display: grid;
  gap: 8px;
  text-align: left;
}

label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-dark);
}

input,
select,
button {
  width: 100%;
  border-radius: 14px;
  font: inherit;
}

input,
select {
  padding: 12px 14px;
  border: 1px solid rgba(126, 154, 255, .24);
  background: rgba(5, 9, 29, .74);
  color: #eef3ff;
}

.control-note { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; margin: 4px 0; padding: 10px 12px; border-radius: 13px; color: #91a2cc; background: rgba(102,247,212,.06); font-size: 11px; }
.power-value { margin-top: 5px; color: #ffe26b; font-size: 10px; font-weight: 900; letter-spacing: .04em; text-align: center; }
.mutation-value { margin-top: 6px; color: #66f7d4; font-size: 10px; font-weight: 900; letter-spacing: .06em; text-align: center; text-transform: uppercase; }
.arena-event-value { margin-top: 5px; color: #e89aff; font-size: 10px; font-weight: 950; letter-spacing: .04em; text-align: center; }
.tour-value { margin-top: 5px; color: #ffe26b; font-size: 10px; font-weight: 950; letter-spacing: .06em; text-align: center; text-transform: uppercase; }
.control-note b { color: #66f7d4; }

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
}

.actions-split {
  grid-template-columns: 1fr 1fr;
}

button {
  border: 0;
  padding: 12px 14px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #5368ff, #7a48f5);
  box-shadow: 0 12px 28px rgba(64, 79, 244, 0.3);
}

button.secondary {
  background: linear-gradient(180deg, #ffb8db 0%, #f47cbc 100%);
}

a.hud-chip-button,
button.hud-chip-button {
  width: auto !important;
  flex: 0 0 auto !important;
  max-width: max-content;
  padding: 8px 14px !important;
  border-radius: 999px !important;
  color: #eaf0ff !important;
  background: var(--glass) !important;
  border: 1px solid rgba(127, 151, 255, 0.24) !important;
  box-shadow: none !important;
  text-decoration: none;
}

a.hud-chip-button:hover,
a.hud-chip-button:focus-visible,
button.hud-chip-button:hover,
button.hud-chip-button:focus-visible {
  background: rgba(255, 255, 255, 0.34) !important;
}

@media (max-width: 900px) {
  body {
    padding: 0;
  }

  .arena-frame {
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    padding: 0;
    border: 0;
  }

  .arena-stage {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
  }

  #gameCanvas {
    height: 100%;
    min-height: 0;
    border-radius: 0;
  }

  .top-chip {
    padding: 7px 11px;
  }

  .top-controls {
    top: 12px;
    left: 12px;
    gap: 6px;
    max-width: calc(100% - 100px);
  }

  .hud-chip-button {
    min-height: 36px;
    padding: 7px 11px;
    font-size: 12px;
  }

  a.hud-chip-button,
  button.hud-chip-button {
    padding: 7px 11px !important;
  }

  .leaderboard-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    width: min(220px, calc(100% - 24px));
    max-height: 28dvh;
    overflow: auto;
  }

  .desktop-chip { display: none; }
  .surge-panel { top: 58px; width: min(240px, calc(100% - 130px)); }

  .minimap-panel {
    left: 12px;
    bottom: 12px;
    width: min(128px, 30vw);
    border-radius: 20px;
  }

  .modal-card {
    width: min(420px, calc(100% - 24px));
  }

  .mutation-grid {
    grid-template-columns: 1fr;
  }

  .mutation-option {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .daily-gauntlet-card {
    grid-template-columns: 1fr;
  }

  .daily-gauntlet-card button {
    width: 100%;
  }

  .win-stats.tour-round { grid-template-columns: repeat(2, 1fr); }
  .win-stats.tour-stats { grid-template-columns: repeat(2,1fr); }
  .modal-card {
    padding: 20px 16px 16px;
  }

  .modal-copy {
    margin: 8px 0 11px;
  }

  .career-summary {
    grid-template-columns: repeat(2, 1fr);
    margin: 10px 0;
    padding: 9px 10px;
  }

  .form-grid {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 6px 8px;
    align-items: center;
  }

  .form-grid label {
    font-size: 10px;
  }

  .form-grid input,
  .form-grid select {
    min-width: 0;
    padding: 9px 11px;
  }

  .form-grid .arena-record,
  .form-grid .tour-record,
  .form-grid .control-note,
  .form-grid .actions {
    grid-column: 1 / -1;
  }

  .control-note {
    padding: 7px 9px;
  }
}
