:root {
  --sky-top: #f3c98b;
  --sky-mid: #f7e6bf;
  --sky-bottom: #f2f4d6;
  --field-light: #c6df8f;
  --field-dark: #8eaf61;
  --grave-light: #d89d77;
  --grave-dark: #8f5339;
  --ink: #1a2218;
  --muted: #57644f;
  --line: rgba(26, 34, 24, 0.12);
  --line-strong: rgba(26, 34, 24, 0.24);
  --plant: #2d7b34;
  --plant-deep: #1f5822;
  --plant-soft: #e4f5c6;
  --zombie: #9f542f;
  --zombie-deep: #69311a;
  --zombie-soft: #ffd8bf;
  --timer: #244f73;
  --timer-soft: #d8eef9;
  --card: rgba(255, 250, 242, 0.78);
  --card-strong: rgba(255, 252, 248, 0.94);
  --shadow-lg: 0 28px 60px rgba(56, 45, 22, 0.18);
  --shadow-md: 0 16px 30px rgba(56, 45, 22, 0.12);
  --radius-xl: 34px;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --cell-width: 84px;
  --lane-height: 92px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  height: 100%;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Gill Sans", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(255, 255, 255, 0.7), transparent 24%),
    radial-gradient(circle at 90% 12%, rgba(255, 255, 255, 0.42), transparent 18%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 34%, var(--sky-bottom) 52%, #c9df96 52%, #97b765 100%);
}

body.is-gated {
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body::before {
  left: -12vw;
  bottom: 10vh;
  width: 42vw;
  height: 42vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 242, 210, 0.36), rgba(255, 242, 210, 0));
  filter: blur(10px);
}

body::after {
  right: -10vw;
  top: 8vh;
  width: 34vw;
  height: 34vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(181, 120, 80, 0.16), rgba(181, 120, 80, 0));
  filter: blur(18px);
}

button {
  font: inherit;
}

.welcome-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(243, 201, 139, 0.56), rgba(242, 244, 214, 0.74)),
    rgba(255, 250, 242, 0.6);
  backdrop-filter: blur(12px);
}

.welcome-gate.is-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.welcome-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgba(26, 34, 24, 0.1);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 246, 234, 0.92));
  box-shadow: var(--shadow-lg);
}

.welcome-kicker {
  margin: 0 0 8px;
  color: #5d6448;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.welcome-card h2 {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1;
}

.welcome-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.welcome-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.welcome-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: #445141;
}

.welcome-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(26, 34, 24, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.welcome-input:focus {
  border-color: rgba(36, 79, 115, 0.4);
  box-shadow: 0 0 0 4px rgba(196, 229, 248, 0.72);
}

.welcome-button {
  border: 0;
  padding: 14px 18px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #2d7b34, #1f5822);
  box-shadow: 0 14px 24px rgba(31, 88, 34, 0.2);
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

.welcome-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.04);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 26px;
  animation: rise-in 700ms ease-out both;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: stretch;
  padding: 30px 32px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 38px;
  background:
    linear-gradient(115deg, rgba(255, 253, 246, 0.92), rgba(253, 244, 228, 0.74)),
    rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.hero::before {
  width: 280px;
  height: 280px;
  right: -90px;
  top: -110px;
  background: radial-gradient(circle, rgba(250, 221, 141, 0.6), rgba(250, 221, 141, 0));
}

.hero::after {
  width: 240px;
  height: 240px;
  left: -80px;
  bottom: -120px;
  background: radial-gradient(circle, rgba(136, 184, 84, 0.22), rgba(136, 184, 84, 0));
}

.hero-copy,
.hero-stats {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: #5e644a;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  font-weight: 800;
}

.hero h1,
.panel-heading h2,
.controls-card h3,
.status-block strong {
  margin: 0;
  font-family: Georgia, "Palatino Linotype", serif;
}

.hero h1 {
  font-size: clamp(2.8rem, 5vw, 5rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.subtitle {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 1.04rem;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.hero-tags span,
.footer-notes span {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(26, 34, 24, 0.1);
  background: rgba(255, 255, 255, 0.5);
  color: #485446;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hero-admin-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(26, 34, 24, 0.1);
  background: rgba(36, 79, 115, 0.12);
  color: #244f73;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}
.stat-label,
.status-label {
  display: block;
  color: #fff;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(255px, 290px) minmax(680px, 1fr) minmax(255px, 290px);
  gap: 22px;
  margin-top: 22px;
}

.side-panel,
.arena-panel,
.footer-strip {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.side-panel {
  padding: 24px 20px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.78), rgba(255, 246, 236, 0.78)),
    rgba(255, 255, 255, 0.58);
}

.side-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 8px;
}

.side-panel-plant::before {
  background: linear-gradient(90deg, #6cb54c, #2d7b34);
}

.side-panel-zombie::before {
  background: linear-gradient(90deg, #cb7a4e, #87462a);
}

.panel-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.panel-heading h2 {
  font-size: 2rem;
  line-height: 1;
}

.team-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.team-badge-plant {
  color: var(--plant-deep);
  background: rgba(219, 242, 189, 0.95);
}

.team-badge-zombie {
  color: var(--zombie-deep);
  background: rgba(253, 216, 191, 0.95);
}

.panel-copy {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.roster {
  display: grid;
  gap: 14px;
}

.unit-card {
  position: relative;
  width: 100%;
  padding: 16px 16px 17px;
  border: 1px solid rgba(26, 34, 24, 0.08);
  border-radius: 22px;
  background: rgba(255, 252, 248, 0.9);
  text-align: left;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.unit-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
  opacity: 0.7;
  pointer-events: none;
}

.unit-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.unit-card.is-selected {
  border-color: currentColor;
  transform: translateY(-2px);
}

.unit-card-plant.is-selected {
  color: var(--plant-deep);
  background: linear-gradient(180deg, #f8ffe8, #e3f5c7);
  box-shadow: 0 16px 28px rgba(59, 106, 33, 0.18);
}

.unit-card-zombie.is-selected {
  color: var(--zombie-deep);
  background: linear-gradient(180deg, #fff0e6, #ffd8c2);
  box-shadow: 0 16px 28px rgba(134, 68, 34, 0.18);
}

.unit-card-name,
.unit-card-meta {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.unit-card-name strong {
  font-size: 1.05rem;
}

.unit-card-name span {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.unit-card p {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.42;
  font-size: 0.92rem;
}

.unit-card-meta {
  margin-top: 12px;
  color: #5b6653;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.controls-card {
  margin-top: 18px;
  padding: 18px 16px 14px;
  border-radius: 22px;
  border: 1px dashed rgba(26, 34, 24, 0.12);
  background: rgba(255, 255, 255, 0.48);
}

.controls-card h3 {
  font-size: 1.1rem;
}

.controls-card p {
  margin: 11px 0 0;
  color: var(--muted);
}

.shortcut-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.shortcut-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0;
}

.shortcut-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(26, 34, 24, 0.08);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.shortcut-keys {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.controls-card kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(26, 34, 24, 0.15);
  border-radius: 10px;
  background: linear-gradient(180deg, #fffefb, #ece3d6);
  box-shadow:
    inset 0 -2px 0 rgba(95, 84, 60, 0.12),
    0 4px 10px rgba(56, 45, 22, 0.08);
  color: #2e3528;
  font-family: "Courier New", monospace;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.controls-card .shortcut-key-wide {
  min-width: 58px;
}

.arena-panel {
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.72), rgba(255, 246, 232, 0.6)),
    rgba(255, 255, 255, 0.55);
}

.arena-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.6), transparent 32%),
    linear-gradient(90deg, rgba(108, 181, 76, 0.06), transparent 24%, transparent 76%, rgba(169, 98, 57, 0.08));
  pointer-events: none;
}

.status-strip {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 8px 8px 18px;
}

.status-block strong {
  display: block;
  margin-top: 6px;
  font-size: 1.32rem;
}

.status-primary {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.status-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-metric {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(26, 34, 24, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: #22301f;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 8px 18px rgba(56, 45, 22, 0.08);
}

.status-metric strong {
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 1.35rem;
  line-height: 1;
  color: #162014;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.status-metric-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.status-metric-icon-wrap {
  width: 38px;
  height: 38px;
}

.status-metric-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.status-metric-plant {
  background: linear-gradient(180deg, #edf8d5, #dff1ba);
}

.status-metric-timer {
  background: linear-gradient(180deg, #e4f4fd, #d7edf8);
  justify-content: center;
}

.status-metric-zombie {
  background: linear-gradient(180deg, #ffe4d0, #f7d1ba);
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.action-buttons {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.legend-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend-pill-plant {
  color: var(--plant-deep);
  background: rgba(223, 242, 194, 0.95);
}

.legend-pill-zombie {
  color: var(--zombie-deep);
  background: rgba(253, 219, 198, 0.95);
}

.restart-button,
.ai-toggle-button,
.fullscreen-button,
.spawn-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    filter 160ms ease;
}

.restart-button {
  padding: 13px 20px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, #284f70, #162f44);
  box-shadow: 0 14px 24px rgba(22, 47, 68, 0.25);
}

.ai-toggle-button {
  padding: 10px 14px;
  border-radius: 999px;
  color: #fffdf8;
  background: linear-gradient(135deg, #5f4f2d, #3d331b);
  box-shadow: 0 14px 24px rgba(61, 51, 27, 0.22);
  font-weight: 800;
  font-size: 0.83rem;
  letter-spacing: 0.02em;
  line-height: 1;
}

.ai-toggle-button.is-on {
  background: linear-gradient(135deg, #9f542f, #69311a);
  box-shadow: 0 14px 24px rgba(105, 49, 26, 0.24);
}

.ai-toggle-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.fullscreen-button {
  width: 50px;
  min-width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #4b6d87, #254257);
  box-shadow: 0 14px 24px rgba(37, 66, 87, 0.22);
}

.fullscreen-button-icon {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
}

.fullscreen-button-icon::before,
.fullscreen-button-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
}

.fullscreen-button-icon::before {
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translate(2px, -2px);
}

.fullscreen-button-icon::after {
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: translate(-2px, 2px);
}

body.is-fullscreen .fullscreen-button-icon::before {
  inset: 2px 2px auto auto;
  width: 8px;
  height: 8px;
  transform: none;
}

body.is-fullscreen .fullscreen-button-icon::after {
  inset: auto auto 2px 2px;
  width: 8px;
  height: 8px;
  transform: none;
}

.restart-button:hover,
.fullscreen-button:hover,
.spawn-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.04);
}

body.is-fullscreen {
  overflow: hidden;
  background: url('../assets/backgrounds/fullscreen-background.png') left center/105% no-repeat fixed;
}

body.is-fullscreen::before,
body.is-fullscreen::after {
  display: none;
}

body.is-fullscreen .app-shell {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 8px;
  display: grid;
  grid-template-rows: 1fr;
  gap: 8px;
}

body.is-fullscreen .hero {
  display: none;
}

body.is-fullscreen .main-layout {
  min-height: 0;
  margin-top: 0;
  grid-template-columns: minmax(165px, 180px) minmax(0, 1fr) minmax(165px, 180px);
  gap: 8px;
}

body.is-fullscreen .side-panel,
body.is-fullscreen .arena-panel {
  min-height: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

body.is-fullscreen .side-panel::before,
body.is-fullscreen .arena-panel::before {
  display: none;
}

body.is-fullscreen .side-panel {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
}

body.is-fullscreen .panel-heading {
  gap: 2px;
  margin-bottom: 6px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

body.is-fullscreen .panel-heading .eyebrow,
body.is-fullscreen .team-badge {
  display: none;
}

body.is-fullscreen .panel-heading h2 {
  font-size: 1.3rem;
}

body.is-fullscreen .panel-copy,
body.is-fullscreen .controls-card {
  display: none;
}

body.is-fullscreen .roster {
  flex: 1;
  align-content: start;
  gap: 8px;
}

body.is-fullscreen .unit-card {
  padding: 10px;
  border-radius: 14px;
}

body.is-fullscreen .unit-card-name {
  gap: 8px;
}

body.is-fullscreen .unit-card-name strong {
  font-size: 0.86rem;
  line-height: 1.15;
}

body.is-fullscreen .unit-card-name span {
  width: 26px;
  height: 26px;
  font-size: 0.7rem;
}

body.is-fullscreen .unit-card p {
  display: none;
}

body.is-fullscreen .unit-card-meta {
  margin-top: 6px;
  font-size: 0.64rem;
}

body.is-fullscreen .unit-card-meta span:last-child {
  display: none;
}

body.is-fullscreen .arena-panel {
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: transparent;
}

body.is-fullscreen .status-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 2px 6px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

body.is-fullscreen .status-primary {
  display: contents;
}

body.is-fullscreen .status-block {
  grid-column: 1;
  justify-self: start;
}

body.is-fullscreen .status-block .status-label {
  font-size: 0.62rem;
}

body.is-fullscreen .status-block strong {
  margin-top: 4px;
  font-size: 0.98rem;
}

body.is-fullscreen .status-metrics {
  grid-column: 2;
  justify-self: center;
  gap: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

body.is-fullscreen .status-metric-plant {
  justify-self: end;
}

body.is-fullscreen .status-metric-zombie {
  justify-self: start;
}

body.is-fullscreen .status-metric {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(9, 15, 16, 0.32);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

body.is-fullscreen .status-metric-plant,
body.is-fullscreen .status-metric-timer,
body.is-fullscreen .status-metric-zombie {
  background: rgba(9, 15, 16, 0.32);
}

body.is-fullscreen .status-metric strong {
  display: inline-block;
  min-width: 3ch;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 1.02rem;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

body.is-fullscreen .status-metric-timer strong {
  min-width: 4.5ch;
  text-align: center;
}

body.is-fullscreen .status-metric-label {
  font-size: 1.28rem;
}

body.is-fullscreen .status-metric-icon-wrap,
body.is-fullscreen .status-metric-icon {
  width: 38px;
  height: 38px;
}

body.is-fullscreen .status-actions {
  grid-column: 3;
  justify-self: end;
  justify-content: flex-end;
  align-items: center;
}

body.is-fullscreen .legend-strip {
  display: none;
}

body.is-fullscreen .action-buttons {
  margin-left: auto;
}

body.is-fullscreen .board-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: transparent;
  border: none;
  box-shadow: none;
}

body.is-fullscreen .board-frame::before {
  display: none;
}

body.is-fullscreen .board-header {
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

body.is-fullscreen .board-rows {
  flex: 1;
  min-height: 0;
  gap: 8px;
}

body.is-fullscreen .lane-row {
  grid-template-columns: 1fr;
  gap: 0;
}

body.is-fullscreen .lane-base {
  display: none;
}

body.is-fullscreen .lane-battlefield {
  height: 100%;
  min-height: var(--lane-height);
}

body.is-fullscreen .lane-battlefield {
  background: none;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

body.is-fullscreen .lane-battlefield::before {
  display: none;
}

body.is-fullscreen .footer-strip {
  display: none;
}

body.is-fullscreen .unit-zombie-sprite {
  width: calc(var(--cell-width) * 0.95);
  height: calc(var(--cell-width) * 0.95);
}

body.is-fullscreen .unit-zombie-sprite .unit-sprite-image {
  width: calc(var(--cell-width) * 0.88);
  height: calc(var(--cell-width) * 0.88);
}

body.is-fullscreen .unit-runner .unit-sprite-image {
  width: calc(var(--cell-width) * 0.80);
  height: calc(var(--cell-width) * 0.80);
}

body.is-fullscreen .unit-brute .unit-sprite-image {
  width: calc(var(--cell-width) * 0.98);
  height: calc(var(--cell-width) * 0.98);
}

body.is-fullscreen .unit-zombie-sprite .health-bar {
  left: 50%;
  transform: translateX(-50%);
  width: calc(var(--cell-width) * 0.65);
}

.board-frame {
  position: relative;
  z-index: 1;
  padding: 12px;
  border-radius: 28px;
  border: 1px solid rgba(26, 34, 24, 0.14);
  background:
    linear-gradient(180deg, rgba(243, 247, 224, 0.12), rgba(220, 233, 184, 0.12)),
    url('../assets/backgrounds/arena-background.png') center / cover no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 -10px 24px rgba(82, 111, 43, 0.08);
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 20px;
  border: 1px dashed rgba(26, 34, 24, 0.12);
  pointer-events: none;
}

.board-header {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
  color: #57644f;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
}

.board-rows {
  display: grid;
  gap: 14px;
}

.lane-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  opacity: 0;
  animation: lane-in 500ms ease forwards;
}

.lane-row:nth-child(1) {
  animation-delay: 70ms;
}

.lane-row:nth-child(2) {
  animation-delay: 140ms;
}

.lane-row:nth-child(3) {
  animation-delay: 210ms;
}

.lane-row:nth-child(4) {
  animation-delay: 280ms;
}

.lane-row:nth-child(5) {
  animation-delay: 350ms;
}

.lane-base {
  position: relative;
  height: var(--lane-height);
  padding: 10px 6px;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #386f41, #234e2b);
  color: rgba(255, 255, 255, 0.96);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 12px 20px rgba(35, 78, 43, 0.18);
}

.lane-base::after {
  content: "";
  position: absolute;
  inset: auto -18px -18px auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(163, 228, 95, 0.28), rgba(163, 228, 95, 0));
}

.lane-base strong {
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.lane-base span {
  position: relative;
  z-index: 1;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lane-battlefield {
  position: relative;
  height: var(--lane-height);
  border: 1px solid rgba(26, 34, 24, 0.14);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 16%, transparent 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0, rgba(255, 255, 255, 0.18) 3px, transparent 3px, transparent calc(var(--cell-width))),
    url('../assets/backgrounds/arena-background.png') -70px 0px / 740px 460px no-repeat;
}

/* Align each lane with the corresponding row of the background image */
.lane-row:nth-child(1) .lane-battlefield { background-position: 0 0, 0 0, -70px 0px; }
.lane-row:nth-child(2) .lane-battlefield { background-position: 0 0, 0 0, -70px -92px; }
.lane-row:nth-child(3) .lane-battlefield { background-position: 0 0, 0 0, -70px -184px; }
.lane-row:nth-child(4) .lane-battlefield { background-position: 0 0, 0 0, -70px -276px; }
.lane-row:nth-child(5) .lane-battlefield { background-position: 0 0, 0 0, -70px -368px; }

.lane-battlefield::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(107, 170, 72, 0.16) 0 100%);
  pointer-events: none;
}

.cell-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(8, var(--cell-width));
  height: 100%;
}

.cell-button {
  border: 0;
  margin: 0;
  padding: 0;
  height: 100%;
  cursor: pointer;
  border-right: 1px solid rgba(26, 34, 24, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  transition: background 140ms ease, box-shadow 140ms ease;
}

.cell-button {
  cursor: pointer;
}

.cell-button.is-occupied {
  background: linear-gradient(180deg, rgba(55, 103, 44, 0.18), rgba(255, 255, 255, 0.06));
}

.cell-button.is-plant-cursor {
  background: linear-gradient(180deg, rgba(102, 220, 92, 0.68), rgba(46, 158, 44, 0.48));
  box-shadow:
    inset 0 0 0 3px rgba(30, 110, 28, 0.95),
    0 0 12px rgba(72, 200, 70, 0.55);
}

.cell-button.is-zombie-cursor {
  background: linear-gradient(180deg, rgba(240, 72, 52, 0.6), rgba(170, 40, 20, 0.4));
  box-shadow:
    inset 0 0 0 3px rgba(150, 30, 15, 0.95),
    0 0 12px rgba(230, 70, 50, 0.55);
}

.cell-button.is-plant-cursor.is-zombie-cursor {
  background: linear-gradient(135deg, rgba(102, 220, 92, 0.65), rgba(240, 72, 52, 0.65));
  box-shadow:
    inset 0 0 0 3px rgba(30, 110, 28, 0.95),
    inset 0 0 0 6px rgba(170, 40, 20, 0.8);
}

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

.unit {
  position: absolute;
  top: 50%;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 14px 22px rgba(27, 35, 22, 0.18);
}

.unit::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
}

.unit-plant {
  background: linear-gradient(180deg, #56b84a, #2e7627);
}

.unit-zombie {
  background: linear-gradient(180deg, #cb7b4f, #824025);
}

.unit-sprite {
  width: 74px;
  height: 76px;
  background: transparent;
  box-shadow: none;
}

.unit-sprite::before {
  display: none;
}

.unit-sprite-image {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 64px;
  height: 64px;
  transform: translateX(-50%);
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.34));
}

.unit-no-sprite {
  width: 46px;
  height: 24px;
  border-radius: 999px;
}

.unit-hidden-trap {
  transform: translate(-50%, -28%);
  background: transparent;
  box-shadow: none;
}

.unit-hidden-trap::before {
  display: none;
}

.unit-hidden-trap .unit-sprite-image {
  width: 68px;
  height: 50px;
  bottom: 12px;
  image-rendering: auto;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.26));
}

.unit-fallback-glyph {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -52%);
  color: rgba(255, 236, 177, 0.92);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.unit-upgrade-badge {
  position: absolute;
  top: 2px;
  right: 3px;
  z-index: 2;
  min-width: 32px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 244, 172, 0.95);
  color: #5d4200;
  font-size: 0.5rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(55, 42, 0, 0.18);
}

.unit-hidden-trap .health-bar {
  left: 0;
  bottom: -11px;
  width: 46px;
}

.unit-hidden-trap .unit-upgrade-badge {
  top: -8px;
  right: -6px;
}

.unit-hidden-trap .unit-fallback-glyph {
  opacity: 0.75;
}

.unit-runner .unit-sprite-image {
  width: 60px;
  height: 60px;
  bottom: 10px;
}

.unit-brute .unit-sprite-image {
  width: 70px;
  height: 70px;
  bottom: 4px;
}

.unit-peashooter .unit-sprite-image {
  width: 70px;
  height: 70px;
  bottom: 3px;
}

.unit-sunflower .unit-sprite-image {
  width: 68px;
  height: 68px;
  bottom: 4px;
}

.unit-wallnut .unit-sprite-image {
  width: 58px;
  height: 58px;
  bottom: 6px;
}

.unit-label {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.health-bar {
  position: absolute;
  bottom: -11px;
  left: 6px;
  width: 46px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.36);
}

.unit-sprite .health-bar {
  left: 14px;
  bottom: -10px;
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, #f8ea87, #81ea67);
}

.unit-zombie-sprite .health-fill {
  background: linear-gradient(90deg, #f8a087, #ea4f4f);
}

.projectile {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 35%, #fffad7, #f2d04e 58%, #bd8e15 100%);
  box-shadow:
    0 0 0 3px rgba(255, 247, 195, 0.18),
    0 0 18px rgba(242, 208, 78, 0.55);
}

.blast-effect {
  position: absolute;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: blast-pop 500ms ease-out both;
}

.blast-effect-bomb {
  background:
    radial-gradient(circle, rgba(255, 241, 176, 0.92) 0%, rgba(255, 154, 66, 0.72) 42%, rgba(186, 58, 26, 0.1) 100%);
  box-shadow:
    0 0 0 6px rgba(255, 215, 132, 0.16),
    0 0 28px rgba(255, 146, 54, 0.5);
}

.blast-effect-mine {
  background:
    radial-gradient(circle, rgba(255, 246, 194, 0.9) 0%, rgba(196, 141, 70, 0.7) 45%, rgba(91, 56, 27, 0.1) 100%);
  box-shadow:
    0 0 0 5px rgba(227, 181, 120, 0.14),
    0 0 22px rgba(184, 121, 51, 0.42);
}

@keyframes blast-pop {
  from {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(0.35);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

.spawn-button {
  position: relative;
  height: var(--lane-height);
  padding: 0 16px;
  overflow: hidden;
  border-radius: 24px;
  color: white;
  text-align: left;
  background: linear-gradient(180deg, #b4673f, #7c3b1e);
  box-shadow: 0 14px 24px rgba(124, 59, 30, 0.22);
}

.spawn-button::before {
  content: "";
  position: absolute;
  inset: auto -20px -24px auto;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 186, 0.3), rgba(255, 214, 186, 0));
}

.spawn-button span {
  position: relative;
  z-index: 1;
  display: block;
}

.spawn-button .spawn-meta {
  margin-top: 6px;
  font-size: 0.76rem;
  opacity: 0.84;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spawn-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.footer-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: 18px;
  padding: 16px 20px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.82), rgba(255, 246, 236, 0.82)),
    rgba(255, 255, 255, 0.5);
}

.footer-strip p {
  margin: 0;
  color: var(--muted);
}

.footer-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Countdown overlay ── */

.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
}

.countdown-overlay[hidden] {
  display: none;
}

.countdown-overlay.is-hidden {
  display: none;
}

.countdown-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 40px 48px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 42, 28, 0.92), rgba(18, 26, 16, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90vw;
}

.countdown-number {
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: countdown-pop 0.6s ease-out;
  min-height: 1.2em;
  text-align: center;
}

@keyframes countdown-pop {
  0% {
    transform: scale(1.6);
    opacity: 0.3;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.start-overlay {
  display: none;
}

.start-overlay[hidden] {
  display: none;
}

.start-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.start-overlay-card {
  max-width: 440px;
  padding: 36px 44px 40px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, #fbffe8, #dbeab0);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.start-overlay-card .eyebrow {
  margin: 0 0 10px;
}

.start-overlay-card h2 {
  margin: 0 0 14px;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.start-overlay-copy {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.start-button {
  padding: 14px 34px;
  border: 0;
  border-radius: 999px;
  color: white;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  background: linear-gradient(135deg, #4caf52, #1f5822);
  box-shadow: 0 18px 30px rgba(31, 88, 34, 0.38);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.start-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
  box-shadow: 0 22px 36px rgba(31, 88, 34, 0.42);
}

.end-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 34, 24, 0.62);
  backdrop-filter: blur(8px);
  transition: opacity 260ms ease;
  animation: end-rise 360ms ease-out both;
}

.end-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
  animation: none;
}

.end-overlay-card {
  max-width: 460px;
  padding: 36px 44px 40px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: linear-gradient(180deg, #fbffe8, #dbeab0);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.end-overlay-card.is-plants {
  background: linear-gradient(180deg, #f6ffe2, #c9ec9a);
  border-color: rgba(46, 118, 39, 0.5);
  box-shadow: 0 40px 80px rgba(31, 88, 34, 0.42);
  color: var(--plant-deep);
}

.end-overlay-card.is-zombies {
  background: linear-gradient(180deg, #fff1e3, #f3bd95);
  border-color: rgba(134, 68, 34, 0.5);
  box-shadow: 0 40px 80px rgba(105, 49, 26, 0.42);
  color: var(--zombie-deep);
}

.end-overlay-card h2 {
  margin: 10px 0 14px;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 2.8rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.end-overlay-copy {
  margin: 0 0 18px;
  color: inherit;
  opacity: 0.85;
  line-height: 1.55;
}

.end-overlay-hint {
  margin: 0;
  color: inherit;
  opacity: 0.7;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
}

@keyframes end-rise {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes lane-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1240px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: 2;
  }

  .arena-panel {
    order: 1;
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 18px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 24px 22px;
    border-radius: 30px;
  }

  .hero-stats {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .status-strip,
  .status-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .action-buttons {
    width: 100%;
  }

  .board-header,
  .lane-row {
    grid-template-columns: 54px 1fr;
    gap: 10px;
  }
}

@media (max-width: 720px) {
  .hero-stats {
    grid-template-columns: 1fr;
  }

  .board-header {
    display: none;
  }

  .lane-row {
    grid-template-columns: 1fr;
  }

  .lane-base,
  .spawn-button {
    height: auto;
    min-height: 64px;
  }

  .spawn-button {
    padding: 16px;
  }

  .lane-battlefield {
    overflow-x: auto;
  }

  .cell-grid,
  .entity-layer {
    min-width: calc(var(--cell-width) * 7);
  }

  .footer-strip {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-notes {
    justify-content: flex-start;
  }
}

.help-button {
  position: fixed;
  bottom: 22px;
  right: 86px;
  z-index: 150;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #4caf52, #1f5822);
  box-shadow: 0 14px 24px rgba(31, 88, 34, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.help-button:hover {
  transform: translateY(-2px) scale(1.05);
  filter: saturate(1.08);
  box-shadow: 0 18px 30px rgba(31, 88, 34, 0.34);
}

.help-button-icon {
  display: block;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
}

body.is-gated .help-button {
  display: none;
}

.settings-button {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 150;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #4b6d87, #254257);
  box-shadow: 0 14px 24px rgba(37, 66, 87, 0.28);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.settings-button:hover {
  transform: translateY(-2px) rotate(40deg);
  filter: saturate(1.08);
  box-shadow: 0 18px 30px rgba(37, 66, 87, 0.34);
}

.settings-button-icon {
  width: 26px;
  height: 26px;
  display: block;
}

body.is-gated .settings-button {
  display: none;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 26, 18, 0.62);
  backdrop-filter: blur(8px);
  transition: opacity 220ms ease;
}

.settings-overlay[hidden] {
  display: none;
}

.settings-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.settings-card {
  position: relative;
  width: min(480px, 100%);
  padding: 36px 44px 40px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, #fbffe8, #dbeab0);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.36);
  text-align: center;
}

.settings-card:has(.settings-view[data-view="shortcuts"]:not(.is-hidden)) {
  width: min(680px, 100%);
  padding-left: 32px;
  padding-right: 32px;
}

.settings-card:has(.settings-view[data-view="units"]:not(.is-hidden)) {
  width: min(720px, 100%);
  padding-left: 28px;
  padding-right: 28px;
}

.settings-card .eyebrow {
  margin: 0 0 8px;
}

.settings-card h2 {
  margin: 0 0 20px;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.settings-view.is-hidden {
  display: none;
}

.settings-menu {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.settings-menu-item {
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, #4caf52, #1f5822);
  box-shadow: 0 14px 26px rgba(31, 88, 34, 0.32);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.settings-menu-item:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
}

.settings-menu-item[data-action="rules"],
.settings-menu-item[data-action="shortcuts"],
.settings-menu-item[data-action="units"],
.settings-menu-item[data-action="help"] {
  background: linear-gradient(135deg, #4b6d87, #254257);
  box-shadow: 0 14px 26px rgba(37, 66, 87, 0.3);
}

.settings-menu-item[data-action="restart"] {
  background: linear-gradient(135deg, #c9543a, #7a2a1a);
  box-shadow: 0 14px 26px rgba(122, 42, 26, 0.32);
}

.settings-view-body {
  text-align: left;
  margin: 0 0 22px;
  color: #3f513a;
  line-height: 1.55;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

.settings-view-body p {
  margin: 0 0 12px;
}

.settings-view-body p:last-child {
  margin-bottom: 0;
}

.shortcut-guide {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 14px;
  align-items: center;
}

.shortcut-guide dt {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #4a5b43;
}

.shortcut-guide dd {
  margin: 0;
  display: flex;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 4px;
  align-items: center;
  font-size: 0.82rem;
}

.shortcut-guide dd span {
  margin-right: 4px;
  color: #4a5b43;
}

.shortcut-guide dd span:last-child {
  margin-right: 0;
}

.shortcut-guide kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 7px;
  background: rgba(31, 88, 34, 0.12);
  border: 1px solid rgba(31, 88, 34, 0.28);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  color: #1f3b22;
}

.unit-stats-sheet {
  display: grid;
  gap: 16px;
}

.unit-stats-section {
  padding: 18px 18px 14px;
  border-radius: 22px;
  border: 1px solid rgba(37, 66, 87, 0.14);
  background: rgba(255, 255, 255, 0.5);
}

.unit-stats-section h3 {
  margin: 0 0 12px;
  color: #2f4332;
  font-family: Georgia, "Palatino Linotype", serif;
  font-size: 1.2rem;
}

.unit-stats-scroll {
  overflow-x: auto;
}

.unit-stats-grid {
  display: grid;
  gap: 12px;
  align-items: center;
  min-width: max-content;
}

.unit-stats-grid-plants {
  grid-template-columns: minmax(132px, 1.4fr) minmax(70px, 0.7fr) minmax(70px, 0.7fr);
}

.unit-stats-grid-zombies {
  grid-template-columns:
    minmax(132px, 1.3fr)
    minmax(70px, 0.65fr)
    minmax(70px, 0.65fr)
    minmax(80px, 0.8fr);
}

.unit-stats-header,
.unit-stats-row {
  padding: 9px 4px;
}

.unit-stats-header {
  border-bottom: 1px solid rgba(37, 66, 87, 0.18);
  color: #526252;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.unit-stats-row {
  border-bottom: 1px solid rgba(26, 34, 24, 0.08);
  color: #324133;
  font-size: 0.92rem;
}

.unit-stats-row:last-child {
  border-bottom: 0;
}

.unit-stats-name {
  font-weight: 800;
}

.settings-back {
  padding: 11px 28px;
  border: 0;
  border-radius: 999px;
  color: white;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  background: linear-gradient(135deg, #4b6d87, #254257);
  box-shadow: 0 12px 22px rgba(37, 66, 87, 0.3);
  transition: transform 160ms ease, filter 160ms ease;
}

.settings-back:hover {
  transform: translateY(-2px);
  filter: saturate(1.08);
}

/* ===== CRAWL SCREEN ===== */
.crawl-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 10000;
  overflow: hidden;
}

.crawl-screen.is-hidden {
  display: none;
}

/* Gradient that fades text out as it recedes to the horizon */
.crawl-fade-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: linear-gradient(to bottom, #000 25%, transparent 100%);
  z-index: 3;
  pointer-events: none;
}

.crawl-perspective {
  position: absolute;
  inset: 0;
  overflow: hidden;
  perspective: 320px;
  perspective-origin: 50% 13%;
}

.crawl-content {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 52%;
  transform: translateX(-50%) rotateX(28deg);
  transform-origin: 50% 0%;
  animation: star-wars-crawl 70s linear forwards;
  text-align: justify;
  padding-bottom: 30vh;
}

.crawl-title {
  text-align: center;
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #ffe566;
  font-family: 'Georgia', 'Times New Roman', serif;
  margin-bottom: 2.4rem;
}

.crawl-text {
  font-size: 1.4rem;
  line-height: 1.9;
  color: #ffe566;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-style: italic;
}

@keyframes star-wars-crawl {
  from { top: 100%; }
  to   { top: -420%; }
}

.crawl-skip {
  position: absolute;
  bottom: 1.8rem;
  right: 2rem;
  background: transparent;
  border: 1px solid rgba(255, 229, 102, 0.35);
  color: rgba(255, 229, 102, 0.55);
  padding: 0.45rem 1.1rem;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 4;
  transition: color 0.2s, border-color 0.2s;
}

.crawl-skip:hover {
  color: #ffe566;
  border-color: #ffe566;
}
