.console {
  position: relative;
  isolation: isolate;
  display: flex;
  /* Header metrics scale with the shell, not the viewport: on desktop the shell
     is capped well below the window and vw units overflowed the brand column. */
  container-type: inline-size;
  --frame: calc(max(8px, env(safe-area-inset-top)) + max(8px, env(safe-area-inset-bottom)));
  --shell: min(100%, 520px, calc((100dvh - var(--frame)) * .566));
  --header-button: clamp(32px, 9.4cqw, 48px);
  width: var(--shell);
  aspect-ratio: 944 / 1665;
  flex-direction: column;
  /* Percentage padding resolves against the BODY, not the shell: on desktop that
     inflated the bezel to ~87px and crushed the header. Scale it off the shell. */
  padding: calc(var(--shell) * .042) calc(var(--shell) * .061) calc(var(--shell) * .044);
  overflow: hidden;
  border: 2px solid var(--console-edge);
  border-radius: 9% / 5.2%;
  background:
    linear-gradient(115deg, transparent 0 15%, rgba(238,255,255,.24) 16%, transparent 17% 75%, rgba(0,65,79,.17) 76%, transparent 88%),
    radial-gradient(ellipse at 30% 8%, var(--console-surface-highlight) 0, var(--console-surface-mid) 16%, transparent 55%),
    linear-gradient(145deg, #28dcd1 0%, var(--console-primary) 35%, var(--console-secondary) 100%);
  box-shadow:
    inset 0 0 0 3px var(--console-glint),
    inset 0 0 0 7px var(--console-rim),
    inset 0 8px 13px rgba(237,255,255,.65),
    inset 0 -15px 22px rgba(0,68,83,.42),
    0 19px 32px rgba(0,16,26,.42),
    0 4px 7px rgba(0,15,23,.52);
}

.console::before,
.console::after {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  content: "";
}

.console::before {
  inset: 1.2%;
  border: 1px solid rgba(223,255,255,.7);
  border-radius: inherit;
  box-shadow: inset 0 0 12px rgba(255,255,255,.22);
}

.console::after {
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, rgba(255,255,255,.14), transparent 24% 73%, rgba(0,48,62,.12));
}

.console-header {
  z-index: 1;
  display: grid;
  flex: 0 0 9.4%;
  grid-template-columns: var(--header-button) minmax(0, 1fr) var(--header-button);
  align-items: center;
  gap: 2%;
  padding: 0 1%;
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 5%;
}

.brand-mark {
  width: clamp(18px, 6cqw, 29px);
  flex: 0 0 auto;
  max-height: 72%;
  color: var(--console-mark);
  filter: drop-shadow(0 1px rgba(180,255,248,.55));
}

.console-header h1 {
  display: inline-flex;
  margin: 0;
  align-items: center;
  gap: .12em;
  color: #073d4c;
  font-size: clamp(13px, 4.6cqw, 24px);
  font-weight: 1000;
  letter-spacing: .035em;
  line-height: 1;
  text-shadow: 0 1px rgba(221,255,249,.48);
}

.power-led {
  width: clamp(8px, 2.2cqw, 13px);
  aspect-ratio: 1;
  border: 1px solid #688d1d;
  border-radius: 50%;
  background: #a9f238;
  box-shadow: 0 0 6px rgba(194,255,53,.9), inset 0 1px 2px #f4ffc3;
  animation: led-breathe 2.4s ease-in-out infinite;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18%;
}

.coin-button,
.settings-button {
  display: grid;
  width: var(--header-button);
  aspect-ratio: 1;
  padding: 0;
  place-items: center;
  border: 2px solid #071f2a;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}

.coin-button {
  justify-self: start;
  color: #d8ffff;
  background: radial-gradient(circle at 35% 23%, #4b7682 0, #244a58 38%, #102734 74%);
  box-shadow:
    inset 0 2px 3px rgba(235,255,255,.5),
    inset 0 -4px 7px rgba(0,0,0,.6),
    0 0 0 3px var(--console-accent-ring),
    0 0 0 5px rgba(4,77,91,.9),
    0 5px 8px rgba(0,31,42,.55);
  font-size: clamp(17px, 4.5vw, 24px);
  line-height: 1;
}

.settings-button {
  color: #8ffaff;
  background:
    radial-gradient(circle at 35% 23%, #486b78 0, #203c4b 36%, #102734 72%);
  box-shadow:
    inset 0 2px 3px rgba(235,255,255,.5),
    inset 0 -4px 7px rgba(0,0,0,.6),
    0 0 0 3px var(--console-accent-ring),
    0 0 0 5px rgba(4,77,91,.9),
    0 5px 8px rgba(0,31,42,.55);
}

.settings-button svg { width: 58%; height: 58%; }

.screen-bezel {
  position: relative;
  display: grid;
  flex: 0 0 36%;
  margin: 1% -1% 0;
  padding: 3.2%;
  place-items: center;
  border: 2px solid #071d29;
  border-radius: 7% / 12%;
  background:
    linear-gradient(135deg, rgba(153,229,238,.16), transparent 25% 68%, rgba(0,0,0,.25)),
    linear-gradient(150deg, #1e3542, #0b1f2a 62%, #172f3b);
  box-shadow:
    inset 0 3px 4px rgba(225,255,255,.24),
    inset 0 -5px 8px rgba(0,0,0,.74),
    0 3px 0 var(--console-accent-shadow),
    0 0 0 2px var(--console-edge);
}

.screen-bezel::before {
  position: absolute;
  inset: 2.2%;
  border: 1px solid rgba(0,0,0,.86);
  border-radius: 5% / 10%;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.8);
  content: "";
  pointer-events: none;
}

.lcd {
  position: relative;
  width: 91%;
  height: 90%;
  overflow: hidden;
  border: 2px solid #071820;
  border-radius: 2px;
  background: var(--screen-bg);
  box-shadow:
    inset 0 0 18px rgba(34,64,39,.26),
    0 0 0 1px rgba(177,255,230,.15);
  --lcd-contrast: 1;
}

.lcd canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: contrast(var(--lcd-contrast));
}

.lcd-glass {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    linear-gradient(130deg, rgba(255,255,235,.19) 0 16%, transparent 16.3% 100%),
    repeating-linear-gradient(to bottom, transparent 0 3px, rgba(35,65,43,.055) 4px),
    repeating-linear-gradient(90deg, rgba(41,69,48,.018) 0 1px, transparent 1px 4px);
}

.main-controls {
  z-index: 1;
  display: flex;
  flex: 0 0 24.5%;
  align-items: center;
  justify-content: space-between;
  margin: 1.6% 0 0;
  padding: 0 1%;
}

.dpad {
  position: relative;
  width: 44%;
  max-width: 212px;
  aspect-ratio: 1;
  filter: drop-shadow(0 6px 2px rgba(0,40,53,.45));
  touch-action: manipulation;
}

.dpad::before {
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: #122d3a;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.15);
  content: "";
}

.direction {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 43%;
  height: 43%;
  padding: 0;
  place-items: center;
  border: 2px solid #091f2a;
  color: var(--console-dpad-arrow);
  background:
    linear-gradient(135deg, rgba(169,255,255,.25), transparent 42%),
    linear-gradient(145deg, #344d5b, #172c39 70%);
  cursor: pointer;
  touch-action: manipulation;
}

.direction.up {
  top: 0;
  left: 28.5%;
  border-radius: 24% 24% 9% 9%;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.38), 0 4px 0 #061923;
}

.direction.down {
  bottom: 0;
  left: 28.5%;
  border-radius: 9% 9% 24% 24%;
  box-shadow: inset 0 -2px 3px rgba(255,255,255,.2), 0 4px 0 #061923;
}

.direction.left {
  top: 28.5%;
  left: 0;
  border-radius: 24% 9% 9% 24%;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.29), 0 4px 0 #061923;
}

.direction.right {
  top: 28.5%;
  right: 0;
  border-radius: 9% 24% 24% 9%;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.29), 0 4px 0 #061923;
}

.direction span {
  width: 0;
  height: 0;
  border-right: 9px solid transparent;
  border-left: 9px solid transparent;
  filter: drop-shadow(0 1px #126c7b);
}

.direction.up span { border-bottom: 13px solid currentColor; }
.direction.down span { border-top: 13px solid currentColor; }
.direction.up span { transform: translateY(-4px); }
.direction.down span { transform: translateY(4px); }
.direction.left span {
  border-top: 9px solid transparent;
  border-right: 13px solid currentColor;
  border-bottom: 9px solid transparent;
  transform: translateX(-4px);
}
.direction.right span {
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid currentColor;
  transform: translateX(4px);
}

.dpad-hub {
  position: absolute;
  z-index: 2;
  top: 28.5%;
  left: 28.5%;
  width: 43%;
  height: 43%;
  border: 2px solid #091d28;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #263f4c, #0b1b25 73%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.18), 0 2px 4px rgba(0,0,0,.5);
  pointer-events: none;
}

.action-pad {
  position: relative;
  width: 44%;
  max-width: 212px;
  aspect-ratio: 1;
  transform: translateY(2%);
  filter: drop-shadow(0 6px 2px rgba(0,40,53,.32));
  touch-action: manipulation;
}

.action-pad button {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 43%;
  height: 43%;
  padding: 0;
  place-items: center;
  border: 2px solid #28641f;
  color: #172f38;
  background:
    radial-gradient(ellipse at 33% 22%, #efffb1 0, #c9f875 31%, var(--button-green) 58%, #82cf37 100%);
  box-shadow:
    inset 0 3px 4px rgba(255,255,255,.82),
    inset 0 -5px 8px rgba(78,157,29,.3),
    0 4px 0 var(--button-green-shadow);
  font-size: clamp(14px, 4.5vw, 24px);
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.action-a {
  top: 0;
  left: 28.5%;
  border-radius: 24% 24% 9% 9%;
}

.action-c {
  bottom: 0;
  left: 28.5%;
  border-radius: 9% 9% 24% 24%;
}

.action-d {
  top: 28.5%;
  left: 0;
  border-radius: 24% 9% 9% 24%;
}

.action-b {
  top: 28.5%;
  right: 0;
  border-radius: 9% 24% 24% 9%;
}

.action-pad .action-ok {
  z-index: 2;
  top: 28.5%;
  left: 28.5%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 24%, #f4ffba 0, #c9f875 34%, var(--button-green) 66%, #76c52f 100%);
  box-shadow:
    inset 0 3px 4px rgba(255,255,255,.82),
    inset 0 -5px 8px rgba(78,157,29,.34),
    0 3px 0 var(--button-green-shadow);
  font-size: clamp(10px, 3.5vw, 18px);
}

.nav-controls {
  z-index: 1;
  display: flex;
  flex: 0 0 9%;
  align-items: center;
  justify-content: center;
  gap: 9%;
  margin-top: 3.2%;
}

.nav-controls button {
  display: flex;
  width: 24%;
  height: 60%;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 8%;
  padding: 0 4%;
  border: 2px solid #092430;
  border-radius: 999px;
  color: #82faff;
  background: linear-gradient(155deg, #304d5b, #142b38 70%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.27), 0 4px 0 #071d29, 0 6px 8px rgba(0,39,52,.3);
  cursor: pointer;
  touch-action: manipulation;
}

.nav-controls svg { width: 28%; max-height: 65%; }
.nav-controls span { font-size: clamp(8px, 2vw, 11px); font-weight: 900; letter-spacing: .11em; }

.console-footer {
  z-index: 1;
  position: relative;
  display: grid;
  flex: 1 1 auto;
  place-items: center;
  padding: 2% 2% 0;
}

.speaker-grille {
  display: grid;
  width: 60%;
  grid-area: 1 / 1;
  grid-template-columns: repeat(15, 1fr);
  gap: clamp(3px, 1.3cqw, 8px);
  padding: 2%;
}

/* 15 x 5 field: two dots are dropped at each outer corner and one at each
   corner of the rows next to them, so the field itself reads as rounded. */
.speaker-grille i:nth-child(1),
.speaker-grille i:nth-child(2),
.speaker-grille i:nth-child(14),
.speaker-grille i:nth-child(15),
.speaker-grille i:nth-child(16),
.speaker-grille i:nth-child(30),
.speaker-grille i:nth-child(46),
.speaker-grille i:nth-child(60),
.speaker-grille i:nth-child(61),
.speaker-grille i:nth-child(62),
.speaker-grille i:nth-child(74),
.speaker-grille i:nth-child(75) {
  visibility: hidden;
}

.speaker-grille i {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(145deg, #053e4b, #071f2a);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.8), 0 1px 0 var(--console-glint);
}

.vent-grille {
  position: absolute;
  top: 50%;
  display: grid;
  width: clamp(24px, 11cqw, 52px);
  gap: clamp(4px, 1.4cqw, 7px);
}

.vent-left { left: 3%; transform: translateY(-50%) rotate(47deg); }
.vent-right { right: 3%; transform: translateY(-50%) rotate(-47deg); }

.vent-grille i {
  height: clamp(4px, 1.5cqw, 7px);
  border: 1px solid #07505e;
  border-radius: 999px;
  background: linear-gradient(#07515f, #073440);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.75), 0 1px var(--console-highlight);
}

.my-game-button {
  display: flex;
  z-index: 1;
  grid-area: 1 / 1;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  min-width: 40%;
  padding: 2.2% 9%;
  border: 2px solid #092430;
  white-space: nowrap;
  border-radius: 999px;
  color: #82faff;
  font-size: clamp(8px, 2cqw, 11px);
  font-weight: 900;
  letter-spacing: .11em;
  background: linear-gradient(155deg, #304d5b, #142b38 70%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.27), 0 4px 0 #071d29, 0 6px 8px rgba(0,39,52,.3);
  cursor: pointer;
  touch-action: manipulation;
}

button:active,
button.pressed {
  filter: brightness(.96);
  transform: translateY(3px);
}

.settings-button:active, .settings-button.pressed { transform: translateY(2px); }
.nav-controls button:active, .nav-controls button.pressed { transform: translateY(3px); }

@media (min-width: 700px) {
  .console {
    --shell: min(520px, calc((100dvh - var(--frame)) * .566));
  }
}

@media (max-width: 380px) {
  .console { --shell: min(100%, calc((100dvh - var(--frame)) * .566)); }
  .console-header h1 { font-size: clamp(16px, 5cqw, 22px); }
  .screen-bezel { flex-basis: 35%; }
  .main-controls { flex-basis: 23.5%; }
  .action-pad { width: 43%; }
  .dpad { width: 43%; }
  .nav-controls button { width: 27%; }
}


.modal {
  position: relative;
  width: min(400px, calc(100% - 32px));
  max-width: 400px;
  padding: 0;
  border: 2px solid var(--console-edge);
  border-radius: 22px;
  margin: auto;
  color: var(--shell-ink);
  background:
    radial-gradient(ellipse at 28% 0%, var(--console-surface-mid), transparent 58%),
    linear-gradient(160deg, var(--console-primary), var(--console-secondary));
  box-shadow:
    inset 0 0 0 3px var(--console-glint),
    inset 0 8px 13px rgba(237,255,255,.5),
    0 24px 44px rgba(0,16,26,.5);
}

.modal::backdrop {
  background: rgba(3,26,35,.62);
  backdrop-filter: blur(3px);
}

.modal[open] { animation: modal-arrive .22s cubic-bezier(.2,.75,.25,1) both; }

@keyframes modal-arrive {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 32px;
  aspect-ratio: 1;
  padding: 0;
  place-items: center;
  border: 2px solid #071f2a;
  border-radius: 50%;
  color: #82faff;
  background: linear-gradient(155deg, #304d5b, #142b38 70%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.27), 0 3px 0 #071d29;
  cursor: pointer;
  touch-action: manipulation;
}

.modal-close svg { width: 56%; height: 56%; }

.modal-body {
  display: grid;
  justify-items: center;
  padding: 38px 26px 28px;
  text-align: center;
}

.auth-title {
  max-width: 17ch;
  margin: 0;
  color: #073d4c;
  font-size: 19px;
  font-weight: 1000;
  line-height: 1.25;
  text-shadow: 0 1px rgba(221,255,249,.48);
}

.auth-subtitle {
  max-width: 30ch;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  opacity: .82;
  overflow-wrap: anywhere;
}

/* One step at a time. An author `display` beats the UA rule for [hidden],
   so hiding has to be restated or every step would show at once. */
.auth-step[hidden] { display: none; }

.auth-step {
  display: grid;
  width: 100%;
  justify-items: center;
  gap: 12px;
  margin-top: 22px;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #071f2a;
  border-radius: 12px;
  color: #d8fdff;
  font: inherit;
  font-size: 15px;
  text-align: center;
  background: linear-gradient(160deg, #11313f, #0a2531);
  box-shadow: inset 0 2px 4px rgba(0,20,28,.6);
}

.auth-input::placeholder { color: rgba(216,253,255,.4); }

.auth-input:focus-visible,
.auth-digit:focus-visible {
  outline: 3px solid #7cfff1;
  outline-offset: 2px;
}

.auth-code {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.auth-digit {
  width: 100%;
  padding: 12px 0;
  border: 2px solid #071f2a;
  border-radius: 11px;
  color: #d8fdff;
  font: inherit;
  font-family: "Courier New", monospace;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  background: linear-gradient(160deg, #11313f, #0a2531);
  box-shadow: inset 0 2px 4px rgba(0,20,28,.6);
}

.auth-submit {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #092430;
  border-radius: 999px;
  color: #82faff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  background: linear-gradient(155deg, #304d5b, #142b38 70%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.27), 0 4px 0 #071d29;
  cursor: pointer;
  touch-action: manipulation;
}

.auth-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.auth-link {
  padding: 2px;
  border: 0;
  color: #073d4c;
  font-size: 12px;
  text-decoration: underline;
  background: none;
  cursor: pointer;
}

.auth-status { margin: 16px 0 0; font-size: 12.5px; line-height: 1.45; }
.auth-status:empty { display: none; }
.auth-status[data-tone="error"] { color: #4d1414; font-weight: bold; }

.auth-step button:disabled,
.auth-step input:disabled { cursor: not-allowed; opacity: .55; }

.auth-account {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
}

.auth-account-email {
  min-width: 0;
  color: #06323f;
  font-size: 14px;
  font-weight: bold;
  /* The address is shown in full: it wraps rather than being cut off. */
  overflow-wrap: anywhere;
}

.auth-signout {
  display: grid;
  width: 28px;
  flex: 0 0 auto;
  aspect-ratio: 1;
  padding: 0;
  place-items: center;
  border: 2px solid #071f2a;
  border-radius: 50%;
  color: #82faff;
  background: linear-gradient(155deg, #304d5b, #142b38 70%);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.27), 0 2px 0 #071d29;
  cursor: pointer;
  touch-action: manipulation;
}

.auth-signout svg { width: 60%; height: 60%; }

.coin-packs {
  display: grid;
  width: 100%;
  padding: 0;
  margin: 4px 0 0;
  gap: 8px;
  list-style: none;
}

/* The 2px frame is the list item itself, so the popular pack can spin a
   gradient inside it while the others keep a flat border colour. */
.coin-pack {
  position: relative;
  padding: 2px;
  border-radius: 14px;
  background: #071f2a;
}

.coin-pack-inner {
  position: relative;
  display: flex;
  width: 100%;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  color: #d8fdff;
  background: linear-gradient(160deg, #11313f, #0a2531);
  box-shadow: inset 0 2px 4px rgba(0,20,28,.55);
}

.coin-pack--popular {
  overflow: hidden;
  background: none;
}

.coin-pack--popular::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  aspect-ratio: 1;
  background: conic-gradient(#7cfff1, #b9f35a, #10c7ca, #073d4c, #7cfff1);
  animation: pack-spin 4.5s linear infinite;
  content: "";
  translate: -50% -50%;
}

@keyframes pack-spin {
  to { rotate: 360deg; }
}

/* Flush into the card's top-left corner, so it reads as a ribbon on the card
   rather than a chip floating in the middle of the row. */
.coin-pack-tag {
  position: absolute;
  top: 0;
  left: 0;
  padding: 3px 9px 4px;
  border-radius: 12px 0 10px 0;
  color: #06323f;
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: .1em;
  white-space: nowrap;
  background: linear-gradient(150deg, #b9f35a, #7cfff1);
}

.coin-pack--popular .coin-pack-inner { padding-top: 24px; }

.coin-pack-amount {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .1em;
  white-space: nowrap;
}

.coin-pack-gem { font-size: 14px; letter-spacing: 0; }

.coin-pack-price {
  font-family: "Courier New", monospace;
  font-size: 16px;
  font-weight: bold;
}

.auth-terms {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 2px 0 0;
  font-size: 11.5px;
}

.auth-terms a { color: #073d4c; }

.auth-balance {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  color: #06323f;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .06em;
}

.coin-pack-inner:disabled { cursor: progress; opacity: .6; }
.coin-pack-inner:focus-visible { outline: 3px solid #7cfff1; outline-offset: 2px; }
