@font-face {
  font-family: 'Press Start 2P';
  src: url('../assets/fonts/PressStart2P-latin.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #1a1c2c;
  --paper: #f4f4f4;
  --plum: #5d275d;
  --red: #b13e53;
  --orange: #ef7d57;
  --yellow: #ffcd75;
  --lime: #a7f070;
  --green: #38b764;
  --teal: #257179;
  --navy: #29366f;
  --blue: #3b5dc9;
  --sky: #41a6f6;
  --cyan: #73eff7;
  --slate: #566c86;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --text: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --frame: 0 0 0 3px var(--ink), 0 0 0 6px var(--paper), 0 0 0 9px var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--blue);
}

kbd {
  font-family: var(--pixel);
  font-size: 0.6rem;
  padding: 0.2em 0.4em;
  border: 2px solid var(--ink);
  border-bottom-width: 4px;
  background: #fff;
  border-radius: 3px;
}

.skip-link {
  position: fixed;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 10px;
}
.skip-link:focus {
  top: 8px;
}

#world {
  position: fixed;
  inset: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  outline: none;
}

.blink {
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
  to {
    visibility: hidden;
  }
}

/* ---------- Boot ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 16;
  display: grid;
  place-items: center;
}

.boot {
  background: #c4cfa1;
  cursor: pointer;
}
.boot-logo {
  font-family: var(--pixel);
  font-size: clamp(24px, 6vw, 48px);
  color: #2b3a67;
  letter-spacing: 2px;
  animation: boot-drop 1.6s steps(24) forwards;
  transform: translateY(-60vh);
}
.boot-logo span {
  font-size: 0.4em;
  vertical-align: top;
}
@keyframes boot-drop {
  to {
    transform: translateY(0);
  }
}
.boot::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  animation: boot-flash 0.5s 1.8s ease-out;
}
@keyframes boot-flash {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- Title ---------- */
.title {
  background: radial-gradient(ellipse at center, rgba(26, 28, 44, 0.25) 0%, rgba(26, 28, 44, 0.85) 75%);
  text-align: center;
  padding: 16px;
}
.title-box {
  display: grid;
  gap: 18px;
  justify-items: center;
}
.title-pre,
.title-sub,
.title-hint,
.title-foot {
  font-family: var(--pixel);
  font-size: 10px;
  margin: 0;
  color: var(--paper);
  text-shadow: 2px 2px 0 var(--ink);
}
.title-sub {
  color: var(--cyan);
}
.title-logo {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  line-height: 1;
  display: grid;
  gap: 8px;
  animation: float 3s ease-in-out infinite;
}
.title-logo span {
  font-size: clamp(34px, 10vw, 84px);
  color: var(--yellow);
  text-shadow:
    3px 3px 0 var(--orange),
    6px 6px 0 var(--red),
    9px 9px 0 var(--plum),
    12px 12px 0 var(--ink);
}
.title-logo span + span {
  color: var(--cyan);
  text-shadow:
    3px 3px 0 var(--sky),
    6px 6px 0 var(--blue),
    9px 9px 0 var(--navy),
    12px 12px 0 var(--ink);
}
@keyframes float {
  50% {
    transform: translateY(-6px);
  }
}
.title-menu {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 16px 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--frame);
  min-width: min(300px, 86vw);
}
.title-menu button,
.menu button {
  font-family: var(--pixel);
  font-size: 12px;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 8px 10px 26px;
  position: relative;
  color: var(--ink);
}
.title-menu button:focus-visible,
.title-menu button:hover,
.menu button:focus-visible,
.menu button:hover {
  outline: none;
  background: #e1e6f0;
}
.title-menu button:focus::before,
.title-menu button:hover::before,
.menu button:focus::before,
.menu button:hover::before {
  content: '▶';
  position: absolute;
  left: 8px;
  animation: nudge 0.6s steps(2) infinite;
}
@keyframes nudge {
  50% {
    transform: translateX(3px);
  }
}
.title-foot {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  font-size: 8px;
  opacity: 0.75;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
}
.hud-place,
.hud-btn {
  font-family: var(--pixel);
  font-size: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink), 3px 3px 0 2px rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  margin: 2px;
  pointer-events: auto;
}
.hud-place {
  margin: 2px;
}
.hud-actions {
  display: flex;
  gap: 6px;
}
.hud-btn {
  border: 0;
}
.hud-btn:hover,
.hud-btn:focus-visible {
  background: var(--yellow);
  outline: none;
}

/* ---------- Dialog ---------- */
.dialog {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  min-height: 108px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--frame);
  padding: 16px 20px 22px;
  cursor: pointer;
  animation: pop 0.15s steps(3);
}
.dialog-name {
  margin: 0 0 10px;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--red);
}
.dialog-text {
  margin: 0;
  font-family: var(--pixel);
  font-size: clamp(10px, 2.4vw, 13px);
  line-height: 1.8;
  -webkit-user-select: text;
  user-select: text;
}
.dialog-next {
  position: absolute;
  right: 16px;
  bottom: 8px;
  font-size: 12px;
  animation: nudge-y 0.6s steps(2) infinite;
}
@keyframes nudge-y {
  50% {
    transform: translateY(3px);
  }
}
@keyframes pop {
  from {
    transform: translateX(-50%) scale(0.9);
  }
}

/* ---------- Overlays & panels ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 30, 0.72);
  padding: 16px;
}
.panel {
  position: relative;
  width: min(940px, 100%);
  max-height: calc(100dvh - 40px);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--frame);
  display: flex;
  animation: panel-in 0.25s steps(5);
}
@keyframes panel-in {
  from {
    transform: scale(0.94);
    opacity: 0;
  }
}
.panel-body {
  overflow-y: auto;
  padding: 26px clamp(16px, 4vw, 36px) 32px;
  width: 100%;
  -webkit-user-select: text;
  user-select: text;
}
.panel-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--pixel);
  font-size: 12px;
  width: 34px;
  height: 34px;
}
.panel-close:hover,
.panel-close:focus-visible {
  background: var(--red);
  outline: none;
}
.place-logos {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 44px 14px 0;
}
.place-logos canvas {
  height: 44px;
  width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.25));
}
.eyebrow {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--red);
  margin: 0 0 8px;
  text-transform: uppercase;
}
.panel h2 {
  font-family: var(--pixel);
  font-size: clamp(16px, 3.5vw, 24px);
  font-weight: 400;
  margin: 0 0 14px;
  line-height: 1.3;
}
.panel-summary {
  font-size: 16px;
  line-height: 1.55;
  max-width: 70ch;
}
.section-title {
  font-family: var(--pixel);
  font-size: 11px;
  font-weight: 400;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 3px dotted var(--slate);
}
.role {
  margin: 18px 0;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 2px var(--ink);
}
.role h3 {
  margin: 0;
  font-size: 17px;
}
.role .at {
  color: var(--blue);
}
.role-period {
  margin: 4px 0 8px;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--slate);
}
.quests {
  margin: 0;
  padding: 0;
  list-style: none;
}
.quests li {
  position: relative;
  padding: 4px 0 4px 26px;
  line-height: 1.45;
}
.quests li::before {
  content: '✔';
  position: absolute;
  left: 2px;
  color: var(--green);
  font-weight: 700;
}

.skills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.skills li {
  display: grid;
  grid-template-columns: minmax(120px, 190px) 1fr auto;
  gap: 12px;
  align-items: center;
}
.skill-name {
  font-weight: 600;
}
.skill-lv {
  font-family: var(--pixel);
  font-size: 9px;
}
meter {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: #d8dde6;
  box-shadow: 0 0 0 2px var(--ink);
  border: 0;
}
meter::-webkit-meter-bar {
  background: #d8dde6;
  border: 0;
  border-radius: 0;
  height: 14px;
}
meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, var(--green), var(--lime));
  border-radius: 0;
  transform-origin: left;
  animation: fill 0.8s steps(8) both;
  animation-delay: var(--delay, 0ms);
}
meter::-moz-meter-bar {
  background: linear-gradient(90deg, var(--green), var(--lime));
}
@keyframes fill {
  from {
    transform: scaleX(0);
  }
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.badge {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--ink);
  background: var(--yellow);
  position: relative;
}
.badge span {
  background: rgba(255, 255, 255, 0.85);
  padding: 3px;
}
.badge-teal { background: linear-gradient(135deg, #73eff7, #257179); }
.badge-purple { background: linear-gradient(135deg, #c79bff, #5d275d); }
.badge-gold { background: linear-gradient(135deg, #fff1a8, #d49a1e); }
.badge-blue { background: linear-gradient(135deg, #9fd3f0, #3b5dc9); }
.badge-orange { background: linear-gradient(135deg, #ffcd75, #ef7d57); }
.badge-green { background: linear-gradient(135deg, #a7f070, #38b764); }
.badge-leaf { background: linear-gradient(135deg, #b5e48c, #2f7d3b); }
.badge-legend {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 4px;
  font-size: 14px;
}
.badge-legend b {
  font-family: var(--pixel);
  font-size: 9px;
  display: inline-block;
  width: 44px;
}

.trainer {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 22px;
  align-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #fff, #e8eefc);
  box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 3px var(--ink);
}
.trainer-avatar {
  width: 120px;
  height: 120px;
  image-rendering: pixelated;
  background: #cfe3ff;
  box-shadow: 0 0 0 3px var(--ink);
}
.trainer dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
}
.trainer dt {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--slate);
  align-self: center;
}
.trainer dd {
  margin: 0;
  font-weight: 600;
}
.links {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.btn {
  font-family: var(--pixel);
  font-size: 10px;
  text-decoration: none;
  color: var(--ink);
  background: var(--yellow);
  padding: 12px 14px;
  box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 2px var(--ink);
}
.btn:hover,
.btn:focus-visible {
  background: var(--lime);
  outline: none;
}
.controls {
  line-height: 2.2;
  padding-left: 18px;
}

/* ---------- Menu ---------- */
.menu {
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  min-width: min(300px, 90vw);
  background: var(--paper);
  box-shadow: var(--frame);
  animation: panel-in 0.2s steps(4);
}

/* ---------- Cards ---------- */
.card-row,
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 22px;
  justify-items: center;
}
.card {
  --rx: 0deg;
  --ry: 0deg;
  --mx: 50%;
  --my: 50%;
  --type: var(--slate);
  --type-2: #94b0c2;
  position: relative;
  width: 100%;
  max-width: 250px;
  aspect-ratio: 5 / 7;
  border: 0;
  padding: 9px;
  border-radius: 12px;
  background: linear-gradient(160deg, #ffe58a, #f5c542 40%, #d9a520);
  box-shadow: 0 0 0 2px var(--ink), 0 10px 18px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  transform: perspective(800px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.12s ease-out;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  font-size: 12px;
}
.card:focus-visible {
  outline: 4px solid var(--sky);
  outline-offset: 3px;
}
.card-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 9px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--type-2), #fdfdfd 55%);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.card-name {
  font-family: var(--pixel);
  font-size: 9.5px;
  line-height: 1.3;
}
.card-hp {
  font-family: var(--pixel);
  font-size: 7px;
  color: var(--red);
  white-space: nowrap;
}
.card-hp b {
  font-size: 11px;
  font-weight: 400;
  margin-left: 2px;
}
.card-art {
  position: relative;
  background:
    radial-gradient(circle at 50% 60%, rgba(255, 255, 255, 0.9), transparent 60%),
    linear-gradient(135deg, var(--type), var(--type-2));
  box-shadow: 0 0 0 2px var(--ink), inset 0 -8px 0 rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  padding: 6px;
  aspect-ratio: 2 / 1;
}
.card-art canvas {
  height: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.3));
}
.card-type {
  margin: 0;
  font-size: 10px;
  font-style: italic;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
}
.card-moves {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 3px;
}
.card-moves li {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  padding-bottom: 2px;
}
.move-name {
  font-weight: 800;
  font-size: 11.5px;
}
.move-dmg {
  font-family: var(--pixel);
  font-size: 10px;
}
.card-moves small {
  grid-column: 1 / -1;
  font-size: 10px;
  line-height: 1.25;
  color: #333;
}
.card-stats {
  display: grid;
  margin: 0;
  font-size: 9px;
  color: #444;
}
.card-flavor {
  margin: 0;
  font-size: 9.5px;
  font-style: italic;
  line-height: 1.3;
  color: #333;
  flex: 1;
}
.card-links {
  display: flex;
  gap: 6px;
  margin: 0;
}
.card-link {
  font-family: var(--pixel);
  font-size: 7.5px;
  text-decoration: none;
  color: var(--paper);
  background: var(--ink);
  padding: 5px 6px;
  border-radius: 3px;
  position: relative;
  z-index: 3;
}
.card-link:hover,
.card-link:focus-visible {
  background: var(--blue);
}
.card-shine {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: 12px;
  z-index: 2;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.45), transparent 45%);
  mix-blend-mode: soft-light;
}
.rarity-holo .card-shine,
.rarity-secret .card-shine,
.rarity-legendary .card-shine {
  background:
    radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.65), transparent 40%),
    repeating-linear-gradient(115deg, #ff7eb3 0%, #ffd36e 6%, #7afcff 12%, #b388ff 18%, #ff7eb3 24%);
  background-size: 100% 100%, 300% 300%;
  background-position: center, var(--mx) var(--my);
  mix-blend-mode: color-dodge;
  opacity: 0.22;
  transition: opacity 0.2s;
}
.rarity-holo:hover .card-shine,
.rarity-secret:hover .card-shine,
.rarity-legendary:hover .card-shine,
.zoom-stage .card-shine {
  opacity: 0.5;
}
.rarity-secret,
.rarity-legendary {
  background: linear-gradient(160deg, #e9e9ff, #b8c1ff 35%, #7c86d9 70%, #e0e7ff);
}
.rarity-legendary {
  animation: legend-glow 2s ease-in-out infinite;
}
@keyframes legend-glow {
  50% {
    box-shadow: 0 0 0 2px var(--ink), 0 0 30px 6px rgba(255, 205, 117, 0.9);
  }
}

.type-ops { --type: #566c86; --type-2: #c9d3e0; }
.type-cloud { --type: #ff9900; --type-2: #ffe0b3; }
.type-kube { --type: #326ce5; --type-2: #c7d7fb; }
.type-ai { --type: #a259ff; --type-2: #e6d6ff; }
.type-iac { --type: #7b42bc; --type-2: #dccbf2; }
.type-reliability { --type: #e0533d; --type-2: #fbd0c8; }
.type-leadership { --type: #f2a93b; --type-2: #fde6c2; }
.type-iot { --type: #c7254e; --type-2: #f8c8d4; }
.type-code { --type: #257179; --type-2: #c1e6e8; }
.type-football { --type: #2e9e4f; --type-2: #c9efd3; }
.type-kids { --type: #f06ea9; --type-2: #fcd5e7; }
.type-legend { --type: #f5d142; --type-2: #fff4c2; }

.card.is-locked {
  background: repeating-linear-gradient(45deg, #29366f 0 10px, #3b5dc9 10px 20px);
  box-shadow: 0 0 0 2px var(--ink), 0 6px 12px rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  transform: none;
}
.card-back {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 4px var(--ink), 0 0 0 9px var(--yellow), 0 0 0 12px var(--ink);
}
.card-back-logo {
  font-family: var(--pixel);
  font-size: 32px;
  color: var(--ink);
}

/* ---------- Zoom ---------- */
.zoom-overlay {
  z-index: 25;
  background: rgba(10, 12, 30, 0.85);
}
.zoom-stage {
  display: grid;
  justify-items: center;
  gap: 16px;
  width: min(360px, 88vw);
}
.zoom-stage .card {
  max-width: none;
  font-size: 14px;
  animation: zoom-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.zoom-stage .card-name { font-size: 12px; }
.zoom-stage .move-name { font-size: 14px; }
.zoom-stage .card-moves small { font-size: 12px; }
.zoom-stage .card-flavor { font-size: 11.5px; }
.zoom-stage .card-stats { font-size: 11px; }
.zoom-stage .card-link { font-size: 9px; padding: 7px 8px; }
.zoom-stage .card.is-locked { width: 100%; }
.zoom-hint {
  font-family: var(--pixel);
  font-size: 10px;
  text-align: center;
}
@keyframes zoom-in {
  from {
    transform: scale(0.6) rotateY(90deg);
  }
}

/* ---------- Booster pack ---------- */
.pack-overlay {
  z-index: 26;
  background: radial-gradient(circle, rgba(59, 93, 201, 0.55), rgba(10, 12, 30, 0.95) 70%);
  cursor: pointer;
}
.pack-stage {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 20px;
  width: 100%;
}
.pack {
  position: relative;
  width: 180px;
  height: 270px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff7eb3, #ffd36e 25%, #7afcff 50%, #b388ff 75%, #ff7eb3);
  background-size: 300% 300%;
  animation: foil 3s linear infinite;
  box-shadow: 0 0 0 3px var(--ink), 0 20px 40px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  transition: transform 0.4s, opacity 0.4s;
}
.pack-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: repeating-linear-gradient(90deg, #d9d9d9 0 6px, #f4f4f4 6px 12px);
  border-bottom: 3px dashed var(--ink);
  border-radius: 8px 8px 0 0;
  transition: transform 0.45s ease-in;
}
.pack-label {
  font-family: var(--pixel);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  color: var(--paper);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink);
  background: rgba(26, 28, 44, 0.55);
  padding: 12px 8px;
}
@keyframes foil {
  to {
    background-position: 300% 300%;
  }
}
.pack-overlay.is-shaking .pack {
  animation: foil 3s linear infinite, shake 0.5s ease-in-out infinite;
}
@keyframes shake {
  25% { transform: rotate(-4deg) translateY(-4px); }
  75% { transform: rotate(4deg) translateY(-4px); }
}
.pack-overlay.is-open .pack-top {
  transform: translate(140px, -160px) rotate(40deg);
}
.pack-overlay.is-open .pack {
  transform: translateY(60vh) scale(0.8);
  opacity: 0;
  transition-delay: 0.3s;
}
.pack-cards {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
  pointer-events: none;
}
.pack-cards .card {
  width: min(230px, 42vw);
  opacity: 0;
}
.pack-overlay.is-revealed .pack {
  display: none;
}
.pack-overlay.is-revealed .pack-cards {
  position: static;
  pointer-events: auto;
}
.pack-overlay.is-revealed .pack-cards .card {
  animation: deal 0.6s cubic-bezier(0.2, 1.3, 0.4, 1) both;
  animation-delay: calc(var(--i, 0) * 180ms);
}
@keyframes deal {
  from {
    opacity: 0;
    transform: translateY(120px) rotateY(180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.pack-hint {
  font-family: var(--pixel);
  font-size: 10px;
  margin: 0;
  color: var(--paper);
}
.card.is-new::after {
  content: 'NEW!';
  position: absolute;
  top: -2px;
  right: -2px;
  z-index: 4;
  font-family: var(--pixel);
  font-size: 9px;
  padding: 5px 6px;
  background: var(--red);
  color: var(--paper);
  box-shadow: 0 0 0 2px var(--ink);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  z-index: 35;
  transform: translateX(-50%);
  font-family: var(--pixel);
  font-size: 11px;
  background: var(--ink);
  color: var(--yellow);
  padding: 12px 16px;
  box-shadow: 0 0 0 3px var(--yellow);
}
.toast.is-in {
  animation: toast-in 0.3s steps(4);
}
@keyframes toast-in {
  from {
    transform: translate(-50%, -30px);
    opacity: 0;
  }
}

/* ---------- Touch pad ---------- */
.pad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px;
  pointer-events: none;
}
.pad button {
  pointer-events: auto;
  touch-action: none;
  border: 0;
  background: rgba(26, 28, 44, 0.7);
  color: var(--paper);
  font-size: 18px;
  box-shadow: 0 0 0 2px rgba(244, 244, 244, 0.6);
}
.pad button.is-down {
  background: rgba(65, 166, 246, 0.9);
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
}
.pad-up { grid-area: 1 / 2; }
.pad-left { grid-area: 2 / 1; }
.pad-right { grid-area: 2 / 3; }
.pad-down { grid-area: 3 / 2; }
.abpad {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
.abpad button {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  font-family: var(--pixel);
  font-size: 14px;
}
.pad-a {
  margin-bottom: 30px;
  background: rgba(177, 62, 83, 0.85) !important;
}
body:has(#dialog:not([hidden])) .pad,
body:has(.overlay:not([hidden])) .pad {
  opacity: 0.35;
}

/* ---------- Quick CV ---------- */
.cv {
  display: none;
}
.cv.is-open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  background: #fbfbf8;
  color: #1f2330;
  -webkit-user-select: text;
  user-select: text;
  outline: none;
}
.cv-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--ink);
  z-index: 2;
}
.cv-toolbar button {
  font-family: var(--pixel);
  font-size: 10px;
  border: 0;
  background: var(--yellow);
  color: var(--ink);
  padding: 10px 12px;
}
.cv-toolbar button:hover,
.cv-toolbar button:focus-visible {
  background: var(--lime);
  outline: none;
}
.cv-body {
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 22px 80px;
  font-size: 16px;
  line-height: 1.6;
}
.cv-body h1 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(20px, 4vw, 30px);
  margin: 0 0 12px;
}
.cv-title {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
}
.cv-links {
  margin: 6px 0 0;
}
.cv-body h2 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: 13px;
  margin: 36px 0 12px;
  padding-bottom: 8px;
  border-bottom: 3px solid #1f2330;
}
.cv-role h3 {
  margin: 18px 0 0;
  font-size: 17px;
}
.cv-period {
  margin: 2px 0 6px;
  color: #5b6378;
  font-size: 14px;
}
.cv-body ul {
  padding-left: 20px;
  margin: 6px 0;
}
.cv-projects li {
  margin-bottom: 6px;
}

@media (max-width: 560px) {
  .skills li {
    grid-template-columns: 1fr auto;
  }
  .skills meter {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .trainer {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .hud-place {
    display: none;
  }
  .card-row,
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }
  .card {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .boot-logo {
    transform: none;
  }
}

@media print {
  body {
    overflow: visible;
    background: #fff;
  }
  .game-only,
  .skip-link {
    display: none !important;
  }
  .cv,
  .cv.is-open {
    display: block;
    position: static;
    overflow: visible;
    background: #fff;
  }
  .cv-body {
    padding: 0;
  }
  .cv a {
    color: inherit;
  }
}
