:root {
  --page-top: #69b7ff;
  --page-bottom: #e8f6df;
  --card: rgba(255, 255, 255, 0.9);
  --card-border: rgba(255, 255, 255, 0.72);
  --ink: #314059;
  --muted: #5f7386;
  --accent: #4a43d0;
  --accent-dark: #2b2f98;
  --progress-shell: rgba(248, 243, 255, 0.3);
  --progress-track: rgba(61, 58, 207, 0.46);
  --shadow: rgba(72, 104, 145, 0.18);
  --overlay: rgba(106, 171, 215, 0.22);
}

* {
  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% 22%, rgba(255, 255, 255, 0.56), transparent 22%),
    radial-gradient(circle at 85% 70%, rgba(216, 255, 176, 0.32), transparent 18%),
    linear-gradient(180deg, var(--page-top) 0%, #b7ecff 28%, var(--page-bottom) 100%);
}

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;
}

.mini-games-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  color: rgba(44, 57, 104, 0.96);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 24px rgba(72, 104, 145, 0.12);
  pointer-events: auto;
}

.mini-games-link:focus-visible,
.mini-games-link:hover {
  background: rgba(255, 255, 255, 0.88);
}

.arena-frame {
  position: relative;
  min-height: calc(100vh - 28px);
  min-height: calc(100dvh - 28px);
  padding: 18px;
  border-radius: 34px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.42), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.02)),
    rgba(232, 253, 240, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 24px 46px var(--shadow);
  overflow: hidden;
}

.arena-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 14% 18%, rgba(201, 255, 214, 0.6), transparent 16%),
    radial-gradient(circle at 84% 80%, rgba(207, 243, 124, 0.5), transparent 14%),
    linear-gradient(164deg, transparent 0 12%, rgba(82, 205, 239, 0.24) 12% 17%, transparent 17% 20%, rgba(56, 180, 229, 0.26) 20% 23%, transparent 23%);
  pointer-events: none;
}

#gameCanvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  min-height: 560px;
  border-radius: 24px;
  touch-action: none;
}

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

.progress-shell {
  position: absolute;
  top: 10px;
  left: 104px;
  right: 10px;
  min-height: 62px;
  border-radius: 28px;
  padding: 7px;
  background: var(--progress-shell);
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 8px 22px rgba(57, 75, 176, 0.08);
  overflow: hidden;
  backdrop-filter: blur(5px);
}

.progress-shell.compact {
  max-width: min(620px, calc(100% - 114px));
}

.progress-fill {
  position: absolute;
  inset: 7px auto 7px 7px;
  width: 0;
  max-width: calc(100% - 14px);
  border-radius: 22px;
  background: linear-gradient(90deg, #ffc7ee 0%, #ff8ac8 100%);
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.35);
  transition: width 180ms ease;
}

.progress-shell::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 22px;
  background: var(--progress-track);
  z-index: 0;
}

.progress-content {
  position: relative;
  z-index: 1;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}

.progress-percent {
  color: white;
  font-size: 22px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(29, 30, 112, 0.35);
}

.progress-title {
  justify-self: end;
  color: #efeefe;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-right: 2px;
}

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

.status-panel {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: min(420px, calc(100% - 20px));
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(5px);
}

.minimap-panel {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 174px;
  height: 132px;
  padding: 7px 7px 20px;
  border-radius: 18px;
  background: rgba(39, 31, 47, .9);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 10px 28px rgba(22, 15, 28, .3);
  backdrop-filter: blur(8px);
}

#minimapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 11px;
}

.minimap-panel span {
  position: absolute;
  right: 10px;
  bottom: 5px;
  color: rgba(255, 248, 237, .68);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

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

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

.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: rgba(39, 52, 89, 0.98);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 10px rgba(255, 255, 255, 0.9);
}

.row-score {
  font-size: 13px;
  font-weight: 800;
  color: rgba(54, 68, 103, 0.95);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.86),
    0 1px 10px rgba(255, 255, 255, 0.86);
}

.status-text {
  margin: 0;
  color: rgba(39, 52, 89, 0.96);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.84),
    0 1px 8px rgba(255, 255, 255, 0.82);
}

.power-status {
  display: inline-flex;
  margin: 0 0 6px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff8ed;
  background: linear-gradient(90deg, rgba(243, 154, 69, .9), rgba(67, 191, 229, .9));
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(35, 26, 48, .2);
}


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

.hidden {
  display: none !important;
}

.modal-card {
  width: min(400px, calc(100% - 32px));
  padding: 26px 24px 22px;
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px rgba(71, 95, 151, 0.24);
}

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

.start-title,
.win-title {
  margin: 0;
  line-height: 1.05;
  color: #3944b7;
}

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

.win-title {
  font-size: 30px;
}

.intro,
.controls-copy,
.win-message {
  line-height: 1.45;
  color: var(--muted);
}

.intro {
  margin: 10px 0 16px;
}

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

.passport-card {
  margin-top: 4px;
  padding: 11px 12px;
  border: 1px solid rgba(93, 60, 145, .16);
  border-radius: 15px;
  color: var(--muted);
  background: linear-gradient(135deg, rgba(246, 239, 255, .94), rgba(255, 242, 231, .94));
}

.passport-heading,
.passport-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.passport-heading {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.passport-heading strong {
  color: #d14d82;
  letter-spacing: 0;
}

.passport-totals {
  margin-top: 7px;
  font-size: 12px;
  flex-wrap: wrap;
}

.passport-totals strong {
  color: var(--ink);
}

.passport-selected {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(93, 60, 145, .12);
  color: #5d3c91;
  font-size: 12px;
  font-weight: 800;
}

.passport-contract-total {
  margin-top: 8px;
  color: #d14d82;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.passport-missions {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.passport-mission {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 5px;
  color: #776c7d;
  font-size: 11px;
}

.passport-mission span {
  color: #b28ac9;
  font-weight: 900;
}

.passport-mission.complete,
.passport-mission.complete span {
  color: #2f956f;
}

.passport-lab-copy {
  color: #877d8c;
  font-size: 11px;
  font-weight: 700;
}

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(84, 112, 148, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

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

button {
  border: 0;
  padding: 12px 14px;
  color: white;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(180deg, #6760ff 0%, #3f3aca 100%);
  box-shadow: 0 10px 18px rgba(69, 64, 196, 0.24);
}

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

.win-message {
  margin: 10px 0 18px;
}

.win-button {
  width: 100%;
}

.win-button + .win-button {
  margin-top: 10px;
}

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

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

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

  .hud-layer,
  .modal-overlay {
    inset: 0;
  }

  .progress-shell.compact {
    left: 92px;
    right: 12px;
    max-width: none;
  }

  .mini-games-link {
    top: 12px;
    left: 12px;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 11px;
  }

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

  .status-panel {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: 12px;
  }

  .minimap-panel {
    right: 12px;
    bottom: 82px;
    width: 130px;
    height: 104px;
  }

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

/* Paper Arena refresh */
:root {
  --page-top: #17131f;
  --page-bottom: #2b2034;
  --ink: #322b3a;
  --muted: #6f6577;
  --accent: #e84f88;
  --accent-dark: #5d3c91;
  --shadow: rgba(15, 10, 21, 0.38);
  --overlay: rgba(26, 18, 34, 0.46);
}

html,
body {
  background:
    radial-gradient(circle at 18% 14%, rgba(232, 79, 136, 0.2), transparent 25%),
    radial-gradient(circle at 84% 75%, rgba(112, 86, 239, 0.22), transparent 27%),
    linear-gradient(145deg, var(--page-top), var(--page-bottom));
}

.arena-frame {
  background: #e8ddc9;
  border: 1px solid rgba(255, 247, 231, 0.5);
  box-shadow:
    inset 0 0 0 7px rgba(58, 45, 66, 0.15),
    0 28px 80px var(--shadow);
}

.arena-frame::before {
  background:
    linear-gradient(110deg, transparent 48%, rgba(82, 61, 43, 0.08) 49%, transparent 50%),
    repeating-linear-gradient(0deg, rgba(87, 68, 44, 0.025) 0 1px, transparent 1px 5px);
}

.mini-games-link,
.arena-badge,
.circuit-panel,
.contract-panel,
.leaderboard-row,
.status-panel {
  background: rgba(39, 31, 47, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff8ed;
  box-shadow: 0 8px 24px rgba(31, 21, 39, 0.2);
  backdrop-filter: blur(10px);
}

.mini-games-link {
  color: #fff8ed;
}

.mini-games-link:hover,
.mini-games-link:focus-visible {
  background: rgba(69, 52, 80, 0.96);
}

.progress-shell {
  background: rgba(39, 31, 47, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(31, 21, 39, 0.2);
}

.progress-shell.compact {
  max-width: min(470px, calc(100% - 114px));
}

.progress-shell::after {
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  background: linear-gradient(90deg, #e84f88, #ff9f68);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.45), 0 0 24px rgba(232, 79, 136, 0.36);
}

.progress-title,
.progress-percent {
  color: #fff8ed;
}

.arena-badge {
  position: absolute;
  top: 82px;
  left: 10px;
  display: grid;
  min-width: 138px;
  gap: 2px;
  padding: 9px 13px;
  border-radius: 14px;
  text-transform: uppercase;
}

.arena-badge span {
  color: #ff9ab9;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.arena-badge strong {
  color: #fff8ed;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.circuit-panel {
  position: absolute;
  top: 142px;
  left: 10px;
  display: grid;
  width: min(248px, 35vw);
  gap: 2px;
  padding: 10px 13px;
  border-radius: 14px;
}

.circuit-panel span,
.circuit-panel strong,
.circuit-panel small {
  display: block;
}

.circuit-panel span {
  color: #ffd06c;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.circuit-panel strong {
  color: #fff8ed;
  font-size: 12px;
}

.circuit-panel small {
  color: rgba(255, 248, 237, .72);
  font-size: 10px;
  font-weight: 800;
}

.circuit-panel small b {
  color: #ffd06c;
}

.circuit-active .contract-panel {
  top: 218px;
}

.contract-panel {
  position: absolute;
  top: 142px;
  left: 10px;
  display: grid;
  width: min(248px, 35vw);
  gap: 2px;
  padding: 10px 13px;
  border-radius: 14px;
}

.contract-panel span {
  color: #ff9ab9;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.contract-panel strong {
  overflow: hidden;
  color: #fff8ed;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-panel small {
  color: rgba(255, 248, 237, .72);
  font-size: 10px;
  font-weight: 800;
}

.leaderboard-panel {
  top: 78px;
}

.leaderboard-row {
  padding: 6px 9px;
}

.row-name,
.row-score,
.status-text {
  color: #fff8ed;
  text-shadow: none;
}

.status-panel {
  width: min(460px, calc(100% - 20px));
}

.modal-overlay {
  background: rgba(27, 19, 35, 0.5);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  text-align: left;
  background:
    repeating-linear-gradient(0deg, rgba(96, 73, 48, 0.025) 0 1px, transparent 1px 5px),
    #fff9ed;
  border: 1px solid #fff;
  box-shadow: 0 24px 70px rgba(21, 13, 29, 0.44);
}

.modal-card.start-card {
  width: min(680px, calc(100% - 32px));
}

.setup-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 12px;
}

.control-field {
  display: grid;
  gap: 5px;
}

.setup-field-wide {
  grid-column: 1 / -1;
}

.circuit-summary {
  display: grid;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid rgba(67, 48, 78, 0.14);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 211, 112, .18), rgba(123, 85, 220, .08));
}

.daily-border-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid rgba(225, 97, 124, 0.24);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 210, 108, .24), rgba(232, 79, 136, .11), rgba(123, 85, 220, .1));
}

.daily-border-card > div:first-child > span {
  display: block;
  color: #e84f88;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.daily-border-card strong {
  display: block;
  margin-top: 3px;
  color: #352b3e;
  font-size: 15px;
}

.daily-border-card p {
  margin: 3px 0 0;
  color: #74667b;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
}

.daily-border-card.completed {
  border-color: rgba(66, 146, 91, .38);
  box-shadow: inset 0 0 0 1px rgba(78, 170, 99, .1);
}

.daily-border-actions {
  display: flex;
  gap: 7px;
}

.daily-border-actions button {
  width: auto;
  margin: 0;
  padding: 9px 11px;
  white-space: nowrap;
}

.circuit-summary > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.circuit-summary > div:first-child span {
  color: #e84f88;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.circuit-summary > div:first-child strong {
  color: #55465f;
  font-size: 12px;
  text-align: right;
}

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

.circuit-records span {
  display: grid;
  gap: 2px;
  color: #7a6c80;
  font-size: 10px;
  font-weight: 800;
}

.circuit-records strong {
  color: #352b3e;
  font-size: 16px;
}

button.compact-button {
  width: auto;
  justify-self: start;
  margin: 0;
  padding: 8px 11px;
  font-size: 11px;
}

.start-title,
.win-title {
  color: #31273b;
}

.start-title {
  font-size: clamp(36px, 8vw, 52px);
  letter-spacing: -0.055em;
}

.win-label {
  color: #e84f88;
}

input,
select {
  border: 1px solid rgba(67, 48, 78, 0.18);
  background: rgba(255, 255, 255, 0.78);
}

button {
  background: linear-gradient(135deg, #e84f88, #7b55dc);
  box-shadow: 0 10px 24px rgba(111, 65, 145, 0.24);
}

button.secondary {
  margin-top: 10px;
  color: #4d3f58;
  background: #eee5d7;
  box-shadow: none;
}

.pause-card {
  text-align: center;
}

@media (max-width: 900px) {
  .arena-frame {
    box-shadow: none;
  }

  .progress-shell.compact {
    max-width: calc(100% - 104px);
  }

  .arena-badge {
    top: 82px;
    left: 12px;
  }

  .circuit-panel {
    top: 140px;
    left: 12px;
    width: min(230px, calc(100% - 24px));
  }

  .contract-panel {
    top: 140px;
    left: 12px;
    width: min(230px, calc(100% - 24px));
  }

  .circuit-active .contract-panel {
    top: 216px;
  }

  .leaderboard-panel {
    top: 126px;
  }
}

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

  .daily-border-actions button {
    flex: 1;
  }
}

@media (max-width: 620px) {
  .setup-fields {
    grid-template-columns: 1fr;
  }

  .setup-field-wide {
    grid-column: auto;
  }

  .contract-panel {
    width: calc(100% - 24px);
  }

  .circuit-panel {
    width: calc(100% - 24px);
  }

  .circuit-records {
    grid-template-columns: 1fr;
  }

  .leaderboard-panel {
    top: 210px;
  }

  .circuit-active .leaderboard-panel {
    top: 286px;
  }
}
