:root {
  --sky-top: #bfe8ff;
  --sky-bottom: #efffd8;
  --panel: rgba(248, 255, 247, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --panel-soft: rgba(255, 255, 255, 0.54);
  --border: rgba(255, 255, 255, 0.6);
  --ink: #18334f;
  --muted: #506b84;
  --accent: #ff9b47;
  --accent-strong: #df6434;
  --shadow: rgba(72, 110, 73, 0.18);
}

* {
  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 18% 18%, rgba(255, 255, 255, 0.48), transparent 18%),
    radial-gradient(circle at 82% 18%, rgba(255, 221, 145, 0.36), transparent 18%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
}

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

button,
a {
  touch-action: manipulation;
}

button {
  appearance: none;
  border: 0;
  font: inherit;
}

.game-shell {
  width: 100%;
  max-width: 1440px;
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  margin: 0 auto;
}

.board-shell {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: clamp(720px, 92dvh, 1100px);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04)),
    rgba(228, 247, 214, 0.92);
  border: 1px solid var(--border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 28px 60px var(--shadow);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: clamp(720px, 92dvh, 1100px);
  touch-action: none;
}

.board-hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  pointer-events: none;
}

.top-strip,
.bottom-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bottom-strip {
  align-items: flex-end;
}

.chip-cluster,
.stats-strip,
.move-pad,
.dash-button,
.notes-card,
.hud-chip {
  pointer-events: auto;
}

.dash-button {
  align-self: flex-end;
  min-width: 112px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 18px;
  color: #f7fff5;
  background: linear-gradient(180deg, #4d8ce7, #2859b5);
  box-shadow: 0 12px 24px rgba(38, 79, 154, .24);
  font: 900 12px "Trebuchet MS", sans-serif;
  cursor: pointer;
  pointer-events: auto;
}

.dash-button:disabled {
  opacity: .58;
  cursor: default;
  background: rgba(55, 83, 112, .72);
  box-shadow: none;
}

.chip-cluster {
  display: flex;
  gap: 8px;
}

.hud-chip,
.overlay-button {
  min-height: 46px;
  padding: 11px 15px;
  border-radius: 16px;
  font-weight: 900;
}

.hud-link,
.hud-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: 0 10px 22px rgba(55, 93, 67, 0.14);
}

.hud-button {
  cursor: pointer;
}

.stats-strip {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 760px);
  max-width: min(760px, 100%);
  margin-left: auto;
  padding: 6px;
  border-radius: 18px;
  background: rgba(248, 255, 247, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 12px 24px rgba(55, 93, 67, 0.14);
}

.stat-chip {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.stat-label,
.notes-label,
.overlay-label {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-size: clamp(15px, 1.6vw, 22px);
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-card {
  width: min(220px, 34vw);
  padding: 10px 11px;
  border-radius: 20px;
  background: rgba(248, 255, 247, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 12px 24px rgba(55, 93, 67, 0.14);
}

.notes-copy,
.notes-status,
.overlay-copy {
  margin: 0;
  line-height: 1.42;
  color: var(--muted);
}

.notes-copy {
  margin-top: 6px;
  font-size: 12px;
}

.notes-copy-strong {
  font-size: 13px;
  font-weight: 800;
  color: #325d3c;
}

.notes-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #2a5f2f;
}

.move-pad {
  position: relative;
  width: 132px;
  height: 132px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(248, 255, 247, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.66);
}

.move-pad-ring {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  border: 2px solid rgba(122, 181, 95, 0.42);
}

.move-thumb {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7acc5d 0%, #4fa546 100%);
  box-shadow: 0 8px 18px rgba(68, 124, 62, 0.18);
}

.pause-card {
  width: min(430px, 100%);
  text-align: center;
}

.pause-card .overlay-button {
  margin-top: 18px;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(230, 248, 218, 0.44);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(560px, 100%);
  padding: 28px 24px 24px;
  border-radius: 28px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 28px 56px rgba(61, 106, 67, 0.18);
}

#startOverlay .overlay-card {
  width: min(840px, 100%);
  max-height: calc(100% - 8px);
  padding: 18px 20px 16px;
  overflow-y: auto;
}

#startOverlay .overlay-title {
  font-size: clamp(34px, 4vw, 46px);
}

#startOverlay .overlay-copy {
  margin-top: 8px;
  font-size: 15px;
}

.mutation-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mutation-roster span {
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--mutation) 58%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--mutation) 72%, #18334a);
  background: color-mix(in srgb, var(--mutation) 12%, white);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .035em;
}

.resume-run-card,
.daily-shift-card,
.neighborhood-run-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 11px;
  padding: 11px 12px;
  border: 1px solid rgba(52, 114, 83, 0.25);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(225, 250, 212, 0.94), rgba(238, 247, 255, 0.9));
}

.daily-shift-card {
  border-color: rgba(151, 91, 42, 0.3);
  background: linear-gradient(135deg, rgba(255, 239, 178, 0.96), rgba(232, 217, 255, 0.92));
}

.daily-shift-card .resume-run-copy span {
  color: #9a572c;
}

.daily-shift-card.completed {
  border-color: rgba(58, 132, 79, 0.42);
  box-shadow: inset 0 0 0 1px rgba(85, 177, 102, 0.12);
}

.neighborhood-run-card {
  border-color: rgba(62, 98, 169, 0.34);
  background: linear-gradient(135deg, rgba(214, 239, 255, 0.96), rgba(232, 218, 255, 0.92));
}

.neighborhood-run-card .resume-run-copy span {
  color: #4761a9;
}

.neighborhood-run-card.completed {
  border-color: rgba(80, 126, 194, 0.48);
  box-shadow: inset 0 0 0 1px rgba(77, 117, 200, 0.14);
}

.resume-run-card.hidden {
  display: none;
}

#discardDailyButton.hidden,
#discardNeighborhoodButton.hidden,
#continueButton.hidden {
  display: none;
}

.resume-run-copy {
  min-width: 0;
}

.resume-run-copy span {
  display: block;
  color: #347253;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.resume-run-copy strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 17px;
}

.resume-run-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.resume-run-actions {
  display: flex;
  gap: 8px;
}

.resume-run-actions .overlay-button,
.resume-run-actions .secondary-button {
  width: auto;
  min-height: 42px;
  margin: 0;
  padding: 9px 13px;
  white-space: nowrap;
}

#startOverlay .loadout-grid {
  margin-top: 12px;
}

#startOverlay .loadout-option {
  min-height: 106px;
  padding: 11px 12px;
}

#startOverlay .location-picker {
  margin-top: 11px;
}

#startOverlay .location-option {
  min-height: 102px;
  padding: 9px 11px;
}

#startOverlay .ascension-picker {
  margin-top: 11px;
  padding: 9px 12px;
}

#startOverlay .career-strip {
  margin-top: 9px;
}

#startOverlay .overlay-button {
  margin-top: 11px;
}

.loadout-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.loadout-option {
  min-height: 126px;
  padding: 14px;
  border: 2px solid transparent;
  border-radius: 18px;
  text-align: left;
  color: var(--ink);
  background: rgba(244, 255, 238, .9);
  box-shadow: 0 10px 22px rgba(71, 110, 75, .12);
  cursor: pointer;
}

.loadout-option.selected {
  border-color: #4f83d8;
  background: #eef5ff;
  box-shadow: 0 12px 26px rgba(54, 100, 174, .2);
}

.loadout-name,
.loadout-kit,
.loadout-perk,
.loadout-record {
  display: block;
}

.location-picker {
  margin-top: 16px;
}

.location-picker-label {
  margin: 0 0 8px;
  color: #315175;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

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

.location-option {
  min-height: 118px;
  padding: 12px;
  border: 2px solid transparent;
  border-radius: 16px;
  text-align: left;
  color: var(--ink);
  background: rgba(244, 255, 238, .9);
  cursor: pointer;
}

.location-option.selected {
  border-color: #e2a83d;
  background: #fff8df;
  box-shadow: 0 10px 22px rgba(141, 104, 40, .16);
}

.location-option.locked {
  opacity: .58;
  cursor: not-allowed;
}

.location-name,
.location-tag,
.location-description,
.location-record {
  display: block;
}

.location-name {
  font-size: 17px;
  font-weight: 900;
}

.location-tag {
  margin-top: 3px;
  color: #8e641f;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.location-description {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.34;
}

.location-record {
  margin-top: 7px;
  color: #347253;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.loadout-name {
  font-size: 21px;
  font-weight: 900;
}

.loadout-kit {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 900;
  color: #315175;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.loadout-perk {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.loadout-record {
  margin-top: 9px;
  color: #347253;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ascension-picker {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid rgba(67, 111, 79, .18);
  border-radius: 18px;
  background: rgba(241, 252, 237, .82);
}

.ascension-picker label {
  display: grid;
  gap: 5px;
}

.ascension-label {
  color: #315175;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

#ascensionSelect {
  width: 100%;
  min-height: 42px;
  padding: 0 38px 0 12px;
  border: 1px solid rgba(61, 105, 74, .24);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.ascension-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.career-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.career-strip strong {
  color: var(--ink);
}

.victory-card {
  width: min(680px, 100%);
}

.victory-card .overlay-title {
  color: #28643b;
}

.victory-actions {
  display: flex;
  gap: 10px;
}

.victory-actions .overlay-button {
  flex: 1;
}

.secondary-button {
  color: #214a72;
  background: #e6f2ff;
  box-shadow: none;
  border: 1px solid rgba(71, 123, 185, .22);
}

.meta-value-small {
  font-size: 19px;
  line-height: 1.35;
}

.upgrade-card {
  width: min(860px, 100%);
}

.overlay-title {
  margin: 10px 0 0;
  font-size: clamp(36px, 4.4vw, 52px);
  line-height: 0.96;
}

.overlay-copy {
  margin-top: 12px;
  font-size: 17px;
}

.overlay-button {
  margin-top: 18px;
  color: white;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 14px 28px rgba(223, 100, 52, 0.2);
  cursor: pointer;
}

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

.upgrade-option {
  display: grid;
  gap: 8px;
  min-height: 170px;
  padding: 18px 16px 16px;
  text-align: left;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 255, 238, 0.96));
  box-shadow: 0 16px 30px rgba(71, 110, 75, 0.16);
  cursor: pointer;
}

.upgrade-tag {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.upgrade-name {
  margin: 0;
  font-size: 24px;
  line-height: 1.02;
}

.upgrade-desc {
  margin: 0;
  line-height: 1.42;
  color: var(--muted);
}

.upgrade-stat-row {
  display: block;
  line-height: 1.34;
}

.upgrade-stat-row + .upgrade-stat-row {
  margin-top: 3px;
}

.upgrade-stat-row strong {
  color: #2e567a;
}

.upgrade-option:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: 0 10px 18px rgba(71, 110, 75, 0.08);
}

.meta-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.meta-chip {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(244, 255, 238, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.meta-label {
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-value {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
}

.meta-upgrade-grid {
  margin-top: 10px;
}

.meta-upgrade-grid .upgrade-option {
  min-height: 154px;
}

.meta-upgrade-meta,
.meta-upgrade-cost {
  margin: 0;
  font-weight: 800;
  color: #315175;
}

@media (max-width: 760px) {
  body {
    padding:
      calc(8px + env(safe-area-inset-top))
      calc(8px + env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      calc(8px + env(safe-area-inset-left));
  }

  .board-shell,
  #gameCanvas {
    min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
    border-radius: 24px;
  }

  .board-hud {
    padding: 8px;
  }

  .top-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .chip-cluster {
    align-self: flex-start;
  }

  .stats-strip {
    width: 100%;
    max-width: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .move-pad {
    display: flex;
    grid-row: 1 / 3;
  }

  .bottom-strip {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    align-items: end;
    gap: 8px;
  }

  .dash-button {
    grid-column: 2;
    justify-self: end;
    min-width: 104px;
    min-height: 42px;
  }

  .notes-card {
    grid-column: 2;
    width: min(170px, 100%);
    padding: 8px 9px;
  }

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

  .loadout-grid {
    grid-template-columns: 1fr;
    max-height: 42dvh;
    overflow-y: auto;
  }

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

  .location-option {
    min-height: 94px;
  }

  .loadout-option {
    min-height: 94px;
  }

  .ascension-picker {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .resume-run-card,
  .daily-shift-card,
  .neighborhood-run-card {
    grid-template-columns: 1fr;
  }

  .resume-run-actions > * {
    flex: 1;
  }

  .victory-actions {
    flex-direction: column;
  }

  .meta-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
