:root {
  --ink: #17202b;
  --muted: #637181;
  --paper: rgba(255, 253, 245, 0.94);
  --paper-solid: #fffdf5;
  --line: #17202b;
  --gold: #f4b83e;
  --teal: #25bda9;
  --coral: #ef6a5f;
  --blue: #4a9df0;
  --green: #6fc35f;
  --shadow: rgba(15, 27, 40, 0.25);
  --app-vh: var(--tg-viewport-height, 100dvh);
  --app-stable-vh: var(--tg-viewport-stable-height, 100dvh);
  --safe-top: max(env(safe-area-inset-top), var(--tg-safe-area-inset-top, 0px));
  --safe-right: max(env(safe-area-inset-right), var(--tg-safe-area-inset-right, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left), var(--tg-safe-area-inset-left, 0px));
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    linear-gradient(135deg, rgba(37, 189, 169, 0.2), transparent 36%),
    linear-gradient(315deg, rgba(239, 106, 95, 0.16), transparent 40%),
    #d9f3ff;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.game-shell {
  width: 100vw;
  height: var(--app-vh);
  min-height: var(--app-stable-vh);
}

.stage-card,
.side-panel,
.panel-block,
.modal-card {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 22px 50px var(--shadow);
}

.stage-card {
  position: fixed;
  inset: 0;
  min-width: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #060b18;
  box-shadow: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #0d1624;
  touch-action: none;
}

.top-hud {
  position: absolute;
  inset: calc(14px + var(--safe-top)) calc(390px + var(--safe-right)) auto calc(14px + var(--safe-left));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.brand,
.wallet,
.interaction-prompt {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 245, 0.9);
  box-shadow: 0 12px 28px rgba(15, 27, 40, 0.18);
}

.brand {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
}

.brand strong {
  font-size: 1.25rem;
  line-height: 1;
}

.brand span,
.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wallet {
  display: flex;
  gap: 8px;
  padding: 8px;
  pointer-events: auto;
}

.wallet span {
  min-width: 90px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.wallet b {
  display: block;
  color: var(--ink);
  font-size: 1.1rem;
}

.stats-button {
  min-width: 82px;
  min-height: 50px;
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #dff9f3;
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 4px 0 #17202b;
}

.stats-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #17202b;
}

.guide-button {
  background: #fff3c5;
}

.quest-chip {
  position: absolute;
  left: calc(14px + var(--safe-left));
  top: calc(92px + var(--safe-top));
  z-index: 5;
  display: none;
  max-width: min(390px, calc(100vw - 28px - var(--safe-left) - var(--safe-right)));
  padding: 10px 12px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 245, 0.92);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 12px 28px rgba(15, 27, 40, 0.18);
}

.quest-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quest-chip strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 0.92rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interaction-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  min-width: min(620px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
  pointer-events: none;
}

.interaction-prompt.active {
  color: var(--ink);
  background: #fff4c7;
}

.side-panel {
  position: fixed;
  top: calc(92px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));
  z-index: 4;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) 132px;
  gap: 10px;
  width: 360px;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  background: rgba(255, 253, 245, 0.9);
  backdrop-filter: blur(10px);
}

.touch-controls {
  position: fixed;
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  bottom: calc(12px + var(--safe-bottom));
  z-index: 6;
  display: none;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.dpad {
  display: grid;
  grid-template-columns: 54px 54px 54px;
  grid-template-rows: 54px 54px;
  gap: 6px;
  pointer-events: auto;
}

.dpad button,
.touch-actions button {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 245, 0.9);
  color: var(--ink);
  font-weight: 950;
  box-shadow: 0 5px 0 #17202b;
}

.dpad button {
  min-width: 54px;
  min-height: 54px;
  font-size: 1rem;
}

.dpad button[data-dir="up"] {
  grid-column: 2;
}

.dpad button[data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}

.dpad button[data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}

.dpad button[data-dir="down"] {
  grid-column: 2;
  grid-row: 2;
}

.touch-actions {
  display: grid;
  gap: 8px;
  min-width: 104px;
  pointer-events: auto;
}

.touch-actions button {
  min-height: 52px;
  padding: 0 14px;
}

.touch-actions .primary-touch {
  min-height: 68px;
  background: var(--gold);
  font-size: 1.25rem;
}

.dpad button.pressed,
.touch-actions button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #17202b;
  filter: brightness(1.04);
}

.panel-block {
  padding: 12px;
  box-shadow: 0 8px 18px rgba(15, 27, 40, 0.12);
}

.objective strong {
  display: block;
  margin-top: 5px;
  font-size: 1.22rem;
}

.objective p,
.modal-body p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.42;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title button,
.battle-actions button,
.modal-actions button {
  min-height: 40px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #17202b;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.section-title button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.section-title button:hover,
.battle-actions button:hover,
.modal-actions button:hover,
.unit-card:hover {
  filter: brightness(1.04);
}

.section-title button:active,
.battle-actions button:active,
.modal-actions button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #17202b;
}

.team-list {
  display: grid;
  gap: 8px;
}

.team-slot,
.unit-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.team-slot {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.team-slot.active,
.unit-card.active {
  background: #fff3c5;
  border-color: #a66a00;
}

.unit-card {
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.unit-card:disabled,
.hero-picker-card:disabled,
.party-slot-card:disabled {
  cursor: not-allowed;
  filter: grayscale(0.65) opacity(0.72);
}

.unit-face {
  width: 58px;
  height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #eaf7ff;
  object-fit: cover;
}

.unit-info {
  min-width: 0;
}

.unit-info strong,
.team-slot strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-info span,
.team-slot span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.class-tag {
  min-width: 70px;
  padding: 6px 7px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 950;
  text-align: center;
}

.class-rock {
  background: #6e7781;
}

.class-paper {
  background: #2fae9d;
}

.class-scissors {
  background: #df5b55;
}

.battle-actions {
  display: grid;
  gap: 9px;
}

.battle-actions strong {
  display: block;
  font-size: 1.08rem;
}

.battle-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
  line-height: 1.35;
}

.battle-actions button:nth-of-type(1) {
  background: #dff9f3;
}

.battle-actions button:nth-of-type(2) {
  background: #ffe4df;
}

.roster-block {
  min-height: 0;
  overflow: hidden;
}

.roster-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 472px);
  overflow: auto;
  padding-right: 3px;
}

.log-block {
  min-height: 0;
}

.log {
  height: 92px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.35;
}

.log p {
  margin: 0 0 6px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 23, 34, 0.45);
  z-index: 10;
}

.modal.hidden,
.hidden {
  display: none;
}

.modal-card {
  position: relative;
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
}

.modal-card h2 {
  margin: 4px 42px 12px 0;
  font-size: 1.5rem;
}

.modal-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.contract-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.guide-flow,
.station-guide,
.picker-help {
  display: grid;
  gap: 12px;
}

.current-task,
.guide-card,
.picker-help,
.station-tip {
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.current-task {
  background: #fff3c5;
}

.guide-card strong,
.current-task strong,
.picker-help strong,
.station-tip strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
}

.guide-card p,
.current-task p,
.picker-help p,
.station-tip p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 730;
  line-height: 1.38;
}

.guide-grid,
.class-rule-grid,
.station-link-grid {
  display: grid;
  gap: 10px;
}

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

.class-rule-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.class-rule,
.station-link {
  padding: 10px;
  border: 2px solid #d6dee7;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.station-link {
  text-align: left;
}

button.station-link {
  cursor: pointer;
  box-shadow: 0 5px 0 #17202b;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

button.station-link:hover {
  filter: brightness(1.04);
}

button.station-link:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #17202b;
}

.station-link strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
}

.station-link span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 780;
}

.party-builder {
  display: grid;
  gap: 14px;
}

.party-slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #eef8ff;
}

.party-slot-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: auto auto;
  gap: 8px;
  align-items: center;
  min-height: 86px;
  padding: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 0 #17202b;
}

.party-slot-card.selected {
  background: #fff3c5;
  border-color: #a66a00;
}

.party-slot-card .unit-face {
  grid-row: span 2;
  width: 52px;
  height: 52px;
}

.slot-index {
  align-self: end;
  width: max-content;
  padding: 4px 7px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #17202b;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 950;
}

.empty-face {
  display: block;
  background:
    linear-gradient(135deg, rgba(37, 189, 169, 0.16), transparent),
    #f8fbff;
}

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

.hero-picker-card {
  display: grid;
  grid-template-rows: 150px minmax(90px, auto) auto auto;
  gap: 8px;
  min-height: 328px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 #17202b;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.hero-picker-card:hover {
  filter: brightness(1.04);
}

.hero-picker-card:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 #17202b;
}

.hero-picker-card.active {
  background: #fff3c5;
  border-color: #a66a00;
}

.hero-picker-card.in-party:not(.active) {
  background: #e9f6ff;
}

.hero-picker-card.locked {
  background: #f1f5f8;
  color: #7b8794;
}

.hero-picker-card.locked .hero-picker-portrait {
  filter: grayscale(0.75) contrast(0.85);
}

.hero-picker-portrait {
  width: 100%;
  height: 150px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #eaf7ff;
  object-fit: cover;
}

.hero-picker-info {
  min-width: 0;
}

.hero-picker-info strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-picker-info span,
.hero-picker-info small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.3;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.hero-stats span {
  padding: 6px 5px;
  border: 2px solid #d6dee7;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

.hero-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.stats-cell {
  min-height: 80px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stats-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stats-cell strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1.05;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 0;
  border-bottom: 2px solid #d6dee7;
  color: var(--muted);
  font-weight: 800;
}

.stats-row strong {
  color: var(--ink);
}

.pick-action {
  min-width: 0;
  padding: 6px 7px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 950;
  text-align: center;
}

.contract-grid button,
.result-card button {
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #e9f6ff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 #17202b;
}

.contract-grid button:nth-child(2) {
  background: #fff3c5;
}

.contract-grid button:nth-child(3) {
  background: #ffe4df;
}

.contract-grid button:disabled,
.result-card button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.9) opacity(0.65);
}

.modal-actions button.primary {
  background: var(--gold);
}

.modal-actions button.secondary {
  background: #dff9f3;
}

.result-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.result-card img {
  width: 96px;
  height: 96px;
  border: 2px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.hpbar {
  height: 9px;
  margin-top: 6px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffe4df;
}

.hpbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6fc35f, #25bda9);
}

@media (max-width: 1120px) {
  .side-panel {
    top: auto;
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    bottom: calc(8px + var(--safe-bottom));
    width: auto;
    max-height: 42vh;
    grid-template-rows: auto auto auto;
    overflow: auto;
  }

  .top-hud {
    inset: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) auto calc(10px + var(--safe-left));
  }

  .interaction-prompt {
    bottom: calc(42vh + 18px + var(--safe-bottom));
  }

  .roster-list {
    max-height: 340px;
  }

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

  .party-slot-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .game-shell {
    width: 100vw;
    height: var(--app-vh);
  }

  .top-hud {
    display: grid;
    align-items: start;
    justify-content: stretch;
    gap: 8px;
  }

  .wallet {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
  }

  .wallet span {
    min-width: 0;
    padding: 6px 7px;
    font-size: 0.68rem;
  }

  .wallet b {
    font-size: 0.96rem;
  }

  .stats-button {
    min-width: 0;
    min-height: 44px;
    padding: 5px;
    font-size: 0.74rem;
  }

  .brand {
    width: max-content;
    max-width: calc(100vw - 20px - var(--safe-left) - var(--safe-right));
    padding: 8px 10px;
  }

  .brand strong {
    font-size: 1rem;
  }

  .quest-chip {
    top: calc(150px + var(--safe-top));
    display: block;
    pointer-events: auto;
  }

  .interaction-prompt {
    top: auto;
    bottom: calc(152px + var(--safe-bottom));
    display: none;
    min-width: min(480px, calc(100vw - 22px - var(--safe-left) - var(--safe-right)));
    padding: 8px 10px;
    font-size: 0.74rem;
  }

  .interaction-prompt.active {
    display: block;
  }

  .side-panel {
    display: none;
  }

  .team-slot,
  .unit-card {
    grid-template-columns: 46px 1fr auto;
    min-height: 60px;
    gap: 7px;
    padding: 6px;
  }

  .unit-face {
    width: 46px;
    height: 46px;
  }

  .unit-info strong,
  .team-slot strong {
    font-size: 0.82rem;
  }

  .unit-info span,
  .team-slot span {
    font-size: 0.68rem;
  }

  .class-tag {
    min-width: 56px;
    padding: 5px;
    font-size: 0.62rem;
  }

  .roster-list {
    max-height: 150px;
  }

  .touch-controls {
    display: flex;
  }

  .dpad {
    grid-template-columns: 50px 50px 50px;
    grid-template-rows: 50px 50px;
  }

  .dpad button {
    min-width: 50px;
    min-height: 50px;
  }

  .touch-actions {
    min-width: 92px;
    gap: 7px;
  }

  .touch-actions button {
    min-height: 44px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .touch-actions .primary-touch {
    min-height: 58px;
    font-size: 1.08rem;
  }

  .modal {
    align-items: stretch;
    padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
  }

  .modal-card {
    width: 100%;
    max-height: calc(var(--app-vh) - 20px - var(--safe-top) - var(--safe-bottom));
    padding: 14px;
  }

  .modal-card h2 {
    font-size: 1.22rem;
  }

  .guide-grid,
  .class-rule-grid,
  .station-link-grid {
    grid-template-columns: 1fr;
  }

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

  .hero-picker-card {
    grid-template-columns: 92px 1fr;
    grid-template-rows: auto auto auto;
    min-height: 0;
  }

  .hero-picker-portrait {
    grid-row: span 3;
    height: 120px;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-card-footer {
    align-items: stretch;
  }

  .party-slot-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .party-slot-grid {
    position: sticky;
    top: 0;
    z-index: 1;
  }

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

@media (max-width: 640px) and (max-height: 740px) {
  .brand {
    padding: 7px 9px;
  }

  .brand span {
    display: none;
  }

  .wallet span,
  .stats-button {
    min-height: 40px;
    padding: 4px 5px;
  }

  .quest-chip {
    top: calc(124px + var(--safe-top));
    padding: 8px 10px;
  }

  .interaction-prompt {
    bottom: calc(138px + var(--safe-bottom));
  }

  .dpad {
    grid-template-columns: 46px 46px 46px;
    grid-template-rows: 46px 46px;
  }

  .dpad button {
    min-width: 46px;
    min-height: 46px;
  }

  .touch-actions button {
    min-height: 40px;
  }

  .touch-actions .primary-touch {
    min-height: 52px;
  }
}
