:root {
  --ink: #1b1f2a;
  --paper: #fffdf5;
  --sun: #ffd84d;
  --healthy-green: #22a853;
  --healthy-dark: #146c35;
  --healthy-light: #e6f9ec;
  --junk-red: #e53935;
  --junk-orange: #ff8f1f;
  --junk-light: #fff0e6;
  --sky-dark: #10172b;
  --shadow-comic: 4px 4px 0 var(--ink);
  --shadow-comic-lg: 6px 6px 0 var(--ink);
  --font-comic: "Fredoka", "Chalkboard SE", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  background: var(--sky-dark);
  color: var(--ink);
  font-family: var(--font-comic);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app-shell {
  position: relative;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

/* Top HUD bar */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: clamp(0.5rem, 1.5vw, 1rem);
  pointer-events: none;
}

.hud-left,
.hud-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
}

.hud-pill {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 800;
  font-size: clamp(0.85rem, 0.7rem + 0.6vw, 1.05rem);
  box-shadow: var(--shadow-comic);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.hud-hearts-wrap {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.hud-hearts {
  background: #dcfce7;
  letter-spacing: 0.03em;
  font-size: clamp(0.84rem, 0.7rem + 0.45vw, 1.02rem);
}

.hud-hearts--p2 {
  background: #e0f2fe;
}

.hud-hearts--p3 {
  background: #f3e8ff;
}

.hud-hearts--p4 {
  background: #ffedd5;
}

.hud-objective {
  background: var(--sun);
}

/* Mode & Difficulty switcher pills on Title Screen */
.selector-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 0.3rem 0 0.6rem;
}

.mode-switcher,
.difficulty-switcher {
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.24rem;
  background: #f1f5f9;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
}

.mode-pill,
.diff-pill {
  appearance: none;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(0.76rem, 0.68rem + 0.3vw, 0.9rem);
  color: var(--ink);
  background: transparent;
  border: 2.5px solid transparent;
  border-radius: 999px;
  padding: 0.3rem 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.mode-pill:hover,
.diff-pill:hover {
  background: #e2e8f0;
}

.mode-pill.is-selected {
  background: var(--sun);
  border-color: var(--ink);
}

.diff-pill.is-selected[data-diff="easy"] {
  background: #86efac;
  border-color: var(--ink);
}

.diff-pill.is-selected[data-diff="medium"] {
  background: #fde047;
  border-color: var(--ink);
}

.diff-pill.is-selected[data-diff="hard"] {
  background: #fca5a5;
  border-color: var(--ink);
}

.mode-pill:focus-visible,
.diff-pill:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

/* 2P VS Launch Card */
.vs-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
}

.vs-panel[hidden],
.side-grid[hidden],
.hud-hearts--p2[hidden] {
  display: none;
}

.vs-matchup {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
}

.vs-fighter {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem;
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow-comic);
  text-align: center;
}

.vs-fighter--p1 {
  background: linear-gradient(155deg, #d8fbe3 0%, #86efac 100%);
}

.vs-fighter--p2 {
  background: linear-gradient(155deg, #ffedd5 0%, #fca5a5 100%);
}

.vs-label {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.vs-fighter strong {
  font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.3rem);
}

.vs-fighter small {
  font-size: 0.78rem;
  font-weight: 800;
  color: #1e293b;
}

.vs-bolt {
  font-size: 1.3rem;
  font-weight: 900;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 0.35rem 0.6rem;
  box-shadow: 3px 3px 0 var(--ink);
}

.vs-start-btn {
  width: min(420px, 100%);
  font-size: clamp(0.95rem, 0.85rem + 0.45vw, 1.15rem);
  padding: 0.75rem 1.25rem;
}

.vs-side-picker {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
}

.vs-player-chips {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.vs-chip {
  appearance: none;
  font-family: inherit;
  font-weight: 900;
  font-size: 0.8rem;
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.72rem;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}

.vs-chip--healthy {
  background: #86efac;
}

.vs-chip--junk {
  background: #fca5a5;
}

.vs-chip:active {
  transform: translate(1px, 1px);
}

/* Comic buttons */
.comic-btn {
  appearance: none;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(0.9rem, 0.78rem + 0.5vw, 1.08rem);
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.6rem 1.1rem;
  box-shadow: var(--shadow-comic);
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.comic-btn:hover {
  background: #fff4c2;
}

.comic-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.comic-btn:focus-visible,
.side-card:focus-visible {
  outline: 4px solid #38bdf8;
  outline-offset: 3px;
}

.comic-btn--small {
  padding: 0.4rem 0.8rem;
  font-size: clamp(0.8rem, 0.72rem + 0.35vw, 0.95rem);
  border-radius: 12px;
}

.comic-btn--primary {
  background: var(--sun);
}

.comic-btn--primary:hover {
  background: #ffe37a;
}

.comic-btn--secondary {
  background: #a7f3d0;
}

.comic-btn--secondary:hover {
  background: #bbf7d0;
}

.comic-btn--muted {
  background: #eef2f7;
}

.comic-btn--closet {
  background: #ddd6fe;
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
}

.comic-btn--closet:hover {
  background: #c4b5fd;
}

.comic-btn--shop {
  background: #fde047;
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
}

.comic-btn--shop:hover {
  background: #facc15;
}

.comic-btn--account {
  background: #fbcfe8;
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
}

.comic-btn--account:hover {
  background: #f9a8d4;
}

.comic-btn--account.is-signed-in {
  background: #bbf7d0;
}

.comic-btn--online {
  background: #bae6fd;
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
}

.comic-btn--online:hover {
  background: #7dd3fc;
}

.comic-btn--online.is-connected {
  background: #86efac;
}

.online-banner {
  margin: 0 0 0.55rem;
  padding: 0.35rem 0.8rem;
  background: #dcfce7;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 900;
}

.online-banner[hidden],
.online-share-box[hidden],
.comic-btn[hidden] {
  display: none;
}

.online-intro {
  margin: 0 0 0.7rem;
}

.online-status-box {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.85rem;
  background: #f1f5f9;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.online-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: #94a3b8;
  flex-shrink: 0;
}

.online-dot[data-state="waiting"],
.online-dot[data-state="connecting"] {
  background: #facc15;
}

.online-dot[data-state="connected"] {
  background: #22c55e;
}

.online-dot[data-state="error"] {
  background: #ef4444;
}

.online-share-box {
  padding: 0.65rem 0.85rem;
  background: #fef9c3;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  margin-bottom: 0.75rem;
}

.online-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.online-code-label {
  font-weight: 800;
  font-size: 0.86rem;
}

.online-code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0.15rem 0.55rem;
}

.online-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.online-join-row {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 440px) {
  .online-join-row {
    flex-direction: column;
  }
}

.comic-input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  font-size: 0.95rem;
  text-transform: uppercase;
  padding: 0.55rem 0.8rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
}

.comic-input:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

/* Closet modal styling */
dialog.comic-dialog--wide {
  width: min(820px, 95dvw);
  max-height: 90dvh;
}

.closet-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
}

.closet-player-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  background: #f1f5f9;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
}

.closet-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #334155;
  font-weight: 700;
}

.closet-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  overflow-y: auto;
  padding: 0.15rem 0.1rem;
}

@media (max-width: 680px) {
  .closet-columns {
    grid-template-columns: 1fr;
  }
}

.closet-section {
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 0.7rem;
}

.closet-section--healthy {
  background: var(--healthy-light);
}

.closet-section--junk {
  background: var(--junk-light);
}

.closet-section-title {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.closet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.char-card {
  appearance: none;
  font-family: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.5rem 0.45rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.char-card:hover {
  background: #fffbeb;
}

.char-card.is-equipped {
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
}

.char-card:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 2px;
}

.char-portrait {
  width: 72px;
  height: 72px;
  display: block;
}

.char-name {
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.15;
}

.char-perk {
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  background: rgba(255, 255, 255, 0.75);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

/* Foodland Shop modal */
.shop-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.shop-coin-pill {
  background: #fef08a;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-weight: 900;
  font-size: 0.95rem;
  box-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  overflow-y: auto;
  padding: 0.15rem 0.1rem;
}

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

.shop-card {
  background: #fffbeb;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 0.75rem 0.85rem;
  box-shadow: 3px 3px 0 var(--ink);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.shop-card.is-maxed {
  background: #dcfce7;
}

.shop-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.shop-card__title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 900;
}

.shop-card__icon {
  font-size: 1.25rem;
  line-height: 1;
}

.shop-card__lvl {
  font-size: 0.78rem;
  font-weight: 900;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}

.shop-card__desc {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
}

.shop-pips {
  display: flex;
  gap: 0.3rem;
}

.shop-pip {
  height: 10px;
  flex: 1;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #e2e8f0;
}

.shop-pip.is-filled {
  background: #facc15;
}

.shop-buy-btn {
  margin-top: 0.15rem;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
}

.stat-chip--coins {
  background: #fef08a;
}

/* Foodland Accounts modal */
.comic-input--normal {
  font-family: inherit;
  text-transform: none;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.account-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 900;
  font-size: 0.86rem;
}

.account-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  background: #fef9c3;
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.account-check[hidden],
.account-feedback[hidden],
.account-profile[hidden],
.account-form[hidden],
.account-saved-list[hidden] {
  display: none;
}

.account-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.account-btn-row .comic-btn {
  flex: 1 1 130px;
}

.account-feedback {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.75rem;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.86rem;
  background: #dcfce7;
}

.account-feedback[data-kind="error"] {
  background: #fee2e2;
  color: #7f1d1d;
}

.account-saved-list {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}

.account-profile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.account-hero-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(135deg, #dcfce7 0%, #fef9c3 100%);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 3px 3px 0 var(--ink);
}

.account-user-name {
  font-size: 1.15rem;
  font-weight: 900;
}

.account-user-slot {
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
}

.account-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.account-stat-box {
  background: #f8fafc;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.account-stat-box small {
  font-size: 0.74rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
}

.account-stat-box strong {
  font-size: 0.98rem;
  font-weight: 900;
}

.account-transfer {
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 2px dashed #cbd5e1;
  font-size: 0.84rem;
}

.account-transfer summary {
  font-weight: 800;
  cursor: pointer;
  color: #334155;
}

.account-note {
  margin: 0.45rem 0 0.55rem;
  font-size: 0.8rem;
  color: #475569;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  padding-top: 3.75rem;
  pointer-events: none;
  overflow-y: auto;
}

.overlay[hidden],
.cutscene-bar[hidden],
.controls-bar[hidden],
.touch-controls[hidden],
.hud-left[hidden] {
  display: none;
}

.title-card,
.end-card {
  pointer-events: auto;
  width: min(760px, 96%);
  background: rgba(255, 253, 245, 0.94);
  border: 4px solid var(--ink);
  border-radius: 24px;
  padding: clamp(1rem, 2.5vw, 1.85rem);
  box-shadow: var(--shadow-comic-lg);
  text-align: center;
  margin-top: auto;
  margin-bottom: auto;
}

.overlay--title {
  align-items: end;
  padding-bottom: clamp(0.9rem, 3dvh, 2rem);
}

.overlay--title .title-card {
  margin-top: auto;
  margin-bottom: 0;
  background: rgba(255, 253, 245, 0.92);
}

.title-badge {
  display: inline-block;
  margin: 0 0 0.45rem;
  padding: 0.25rem 0.8rem;
  background: var(--sun);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  font-size: clamp(0.75rem, 0.65rem + 0.35vw, 0.9rem);
  font-weight: 900;
  letter-spacing: 0.05em;
}

.game-title {
  margin: 0.15rem 0 0.4rem;
  font-size: clamp(1.5rem, 1rem + 2.4vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.title-junk {
  color: var(--junk-red);
  text-shadow: 2px 2px 0 var(--ink);
}

.title-vs {
  display: inline-block;
  margin: 0 0.35rem;
  padding: 0.05rem 0.45rem;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 10px;
  font-size: 0.72em;
  vertical-align: middle;
}

.title-healthy {
  color: var(--healthy-green);
  text-shadow: 2px 2px 0 var(--ink);
}

.title-tagline {
  margin: 0 0 1rem;
  font-size: clamp(0.9rem, 0.78rem + 0.5vw, 1.08rem);
  color: #334155;
  font-weight: 600;
}

.side-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

@media (max-width: 620px) {
  .top-bar {
    flex-direction: column-reverse;
    align-items: stretch;
    padding: 0.4rem 0.5rem;
    gap: 0.35rem;
  }

  .hud-left {
    justify-content: flex-start;
    gap: 0.3rem;
  }

  .hud-right {
    justify-content: flex-end;
    gap: 0.3rem;
  }

  .hud-pill {
    padding: 0.22rem 0.55rem;
    font-size: 0.78rem;
    border-width: 2.5px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .hud-hearts {
    font-size: 0.82rem;
    letter-spacing: 0.02em;
  }

  .comic-btn--small {
    padding: 0.26rem 0.52rem;
    font-size: 0.74rem;
    border-width: 2.5px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .overlay--title {
    padding: 0.5rem 0.65rem 0.75rem;
  }

  .overlay--title .title-card {
    padding: 0.72rem 0.8rem;
    border-radius: 18px;
  }

  .selector-row {
    gap: 0.35rem;
    margin: 0.2rem 0 0.4rem;
  }

  .mode-switcher,
  .difficulty-switcher {
    flex-wrap: nowrap;
    gap: 0.18rem;
    padding: 0.18rem;
  }

  .mode-pill,
  .diff-pill {
    padding: 0.24rem 0.5rem;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .title-tagline {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
  }

  .side-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .side-card {
    padding: 0.72rem 0.85rem;
    gap: 0.22rem;
  }

  .vs-matchup {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .vs-bolt {
    justify-self: center;
    padding: 0.2rem 0.55rem;
    font-size: 1rem;
  }
}

.side-card {
  appearance: none;
  font-family: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.95rem 1.05rem;
  border: 3.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-comic);
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.side-card--healthy {
  background: linear-gradient(155deg, #d8fbe3 0%, #86efac 100%);
}

.side-card--junk {
  background: linear-gradient(155deg, #ffedd5 0%, #fca5a5 100%);
}

@media (prefers-reduced-motion: no-preference) {
  .side-card:hover {
    transform: translateY(-4px);
    box-shadow: 6px 8px 0 var(--ink);
  }
}

.side-card:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.side-card__tag {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: var(--paper);
  border: 2px solid var(--ink);
}

.side-card__name {
  font-size: clamp(1.15rem, 0.95rem + 0.9vw, 1.45rem);
  font-weight: 900;
}

.side-card__desc {
  font-size: clamp(0.84rem, 0.74rem + 0.35vw, 0.95rem);
  line-height: 1.35;
  color: #1e293b;
}

.side-card__gear {
  margin-top: auto;
  padding-top: 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: #0f172a;
}

/* Cutscene control bar */
.cutscene-bar {
  position: absolute;
  bottom: clamp(0.75rem, 2.5dvh, 1.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(760px, 94dvw);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 253, 245, 0.95);
  border: 3.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-comic);
}

.cutscene-progress {
  font-weight: 900;
  font-size: clamp(0.85rem, 0.75rem + 0.4vw, 1rem);
}

.cutscene-actions {
  display: flex;
  gap: 0.55rem;
}

/* Desktop controls bar */
.controls-bar {
  position: absolute;
  bottom: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(255, 253, 245, 0.9);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.3rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 3px 3px 0 var(--ink);
  white-space: nowrap;
  max-width: 95dvw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Touch controls */
.touch-controls {
  position: absolute;
  bottom: 0.9rem;
  left: 0.9rem;
  right: 0.9rem;
  z-index: 9;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
  pointer-events: auto;
}

.dpad-btn {
  appearance: none;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: rgba(255, 253, 245, 0.88);
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--ink);
  touch-action: none;
}

.dpad-btn:active,
.dpad-btn.is-active {
  background: var(--sun);
  transform: translate(1px, 1px);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }
.dpad-right { grid-column: 3; grid-row: 2; }

.action-pad {
  display: flex;
  gap: 0.55rem;
  pointer-events: auto;
}

.action-btn {
  appearance: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  font-family: inherit;
  font-weight: 900;
  font-size: 0.8rem;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  touch-action: none;
}

.action-btn--slash { background: var(--sun); }
.action-btn--shoot { background: #86efac; }
.action-btn--shield { background: #bae6fd; }

.action-btn:active,
.action-btn.is-active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

@media (max-width: 440px) {
  .touch-controls {
    bottom: 0.7rem;
    left: 0.6rem;
    right: 0.6rem;
  }

  .dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 3px;
  }

  .dpad-btn {
    border-radius: 12px;
    font-size: 1rem;
  }

  .action-pad {
    gap: 0.4rem;
  }

  .action-btn {
    width: 54px;
    height: 54px;
    font-size: 0.72rem;
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 821px) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 820px), (pointer: coarse) {
  .controls-bar {
    display: none;
  }
}

/* End screen */
.end-title {
  margin: 0.2rem 0 0.5rem;
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.3rem);
}

.end-summary {
  margin: 0 0 0.9rem;
  font-size: clamp(0.95rem, 0.82rem + 0.5vw, 1.1rem);
  color: #334155;
  line-height: 1.45;
}

.end-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.15rem;
}

.stat-chip {
  background: #f1f5f9;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 0.45rem 0.85rem;
  font-weight: 800;
  font-size: 0.92rem;
}

.end-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* Native <dialog> modal styling following modern web guidance */
dialog.comic-dialog {
  width: min(540px, 92dvw);
  max-height: 85dvh;
  padding: 1.4rem 1.5rem;
  border: 4px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-comic-lg);
}

dialog.comic-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(16, 23, 43, 0.65);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-title {
  margin: 0;
  font-size: clamp(1.3rem, 1rem + 1vw, 1.65rem);
}

.dialog-body {
  font-size: 0.96rem;
  line-height: 1.5;
  overflow-y: auto;
}

.help-list {
  margin: 0.65rem 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.help-list code {
  background: #fef08a;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
}

.help-tip {
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.8rem;
  background: var(--healthy-light);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.25rem;
}
