/* ==========================================================================
   SNAKE·DMG — Retro Handheld Pixel Console & Mobile-Stabilized Touch UI
   ========================================================================== */

:root {
  /* Outer Environment */
  --desk-bg: #151815;
  --desk-grid: rgba(155, 188, 15, 0.045);

  /* Handheld Molded ABS Plastic Shell (Classic Putty-Gray) */
  --shell-main: #c8c5b8;
  --shell-hi: #dfddd2;
  --shell-lo: #9a9688;
  --shell-edge: #6f6b5f;
  --shell-ink: #2c2b30;
  --accent-burgundy: #7f2245;
  --accent-burgundy-hi: #a1335b;
  --accent-burgundy-lo: #53122a;
  --bezel-bg: #4b4d57;
  --bezel-lo: #2e3038;

  /* Default Palette: DMG Classic Olive Dot-Matrix */
  --lcd-bg: #9bbc0f;
  --lcd-grid: rgba(15, 56, 15, 0.1);
  --lcd-soft: #8bac0f;
  --lcd-mid: #306230;
  --lcd-ink: #0f380f;
  --lcd-glow: rgba(155, 188, 15, 0.18);

  /* Dock Surface */
  --dock-bg: #22252a;
  --dock-panel: #2b2f36;
  --dock-border: #424854;
  --dock-text: #e7e9df;
  --dock-muted: #9da4b0;
  --dock-accent: #b6d92c;
  --dock-danger: #ef6461;

  --font-pixel: "Silkscreen", "DotGothic16", "Courier New", ui-monospace, monospace;
  --font-ui: "DotGothic16", "Silkscreen", "PingFang SC", "Microsoft YaHei", monospace;
}

html[data-palette="amber"] {
  --lcd-bg: #dda137;
  --lcd-grid: rgba(54, 30, 4, 0.12);
  --lcd-soft: #c98c24;
  --lcd-mid: #7d4b0a;
  --lcd-ink: #2e1802;
  --lcd-glow: rgba(242, 174, 54, 0.22);
  --dock-accent: #f2ae36;
}

html[data-palette="cyan"] {
  --lcd-bg: #8bd4d8;
  --lcd-grid: rgba(12, 42, 54, 0.11);
  --lcd-soft: #70bcc2;
  --lcd-mid: #286472;
  --lcd-ink: #0a2936;
  --lcd-glow: rgba(139, 212, 216, 0.24);
  --dock-accent: #70e1e8;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--desk-bg);
  background-image:
    linear-gradient(var(--desk-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--desk-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--dock-text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* ==========================================================================
   Main Desktop / Mobile Responsive Shell
   ========================================================================== */

.workspace-shell {
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding:
    max(12px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.mobile-only {
  display: none !important;
}

/* ==========================================================================
   Handheld Console Hardware Chassis
   ========================================================================== */

.handheld-chassis {
  width: 440px;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(165deg, var(--shell-hi) 0%, var(--shell-main) 48%, #b9b5a7 100%);
  border-radius: 20px 20px 54px 20px;
  padding: 14px 18px 18px;
  border: 3px solid var(--shell-edge);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.65),
    inset 0 -5px 0 rgba(88, 84, 72, 0.45),
    0 22px 48px rgba(0, 0, 0, 0.62);
  color: var(--shell-ink);
  user-select: none;
  -webkit-user-select: none;
}

/* Top Hardware Bar */
.chassis-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px groove rgba(111, 107, 95, 0.38);
}

.power-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.led-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8d8d8d;
  border: 1.5px solid #2b2b2b;
  flex-shrink: 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.led-dot[data-state="online"] {
  background: #3be25a;
  box-shadow: 0 0 8px #3be25a;
}

.led-dot[data-state="offline"] {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.led-dot[data-state="suspended"] {
  background: #ef4444;
  box-shadow: 0 0 9px #ef4444;
}

.link-label {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #3d3b42;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hardware-switches {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}

.hw-chip {
  appearance: none;
  border: 1.5px solid #57544a;
  background: #d9d6ca;
  color: #26252a;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.15;
  box-shadow: 0 2px 0 #797567;
}

.hw-chip:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #797567;
}

.hw-chip-accent {
  background: #373a44;
  color: #f4f4ec;
  border-color: #202229;
  box-shadow: 0 2px 0 #1c1d22;
}

/* ==========================================================================
   Recessed Screen Bezel & Dot-Matrix LCD
   ========================================================================== */

.screen-bezel {
  background: linear-gradient(180deg, var(--bezel-bg) 0%, #3d3f48 100%);
  border-radius: 12px 12px 30px 12px;
  padding: 10px 14px 12px;
  border: 2px solid var(--bezel-lo);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.5),
    0 2px 0 rgba(255, 255, 255, 0.45);
}

.bezel-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.bezel-stripes {
  flex: 1;
  height: 5px;
  border-top: 2px solid #8a2c52;
  border-bottom: 2px solid #2e3d78;
}

.bezel-brand {
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: #cbcdd6;
  white-space: nowrap;
}

.lcd-glass {
  background: var(--lcd-bg);
  border: 3px solid #1e221b;
  border-radius: 5px;
  padding: 6px;
  color: var(--lcd-ink);
  box-shadow:
    inset 0 3px 9px rgba(0, 0, 0, 0.28),
    0 0 18px var(--lcd-glow);
  position: relative;
}

/* Subtle CRT / Dot-Matrix Scanline Texture */
.lcd-glass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.035) 0px,
    rgba(0, 0, 0, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  border-radius: 3px;
}

.lcd-hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 2px solid var(--lcd-ink);
  font-family: var(--font-pixel);
}

.hud-metric {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-k {
  font-size: 9px;
  color: var(--lcd-mid);
  line-height: 1.1;
}

.hud-v {
  font-size: 13px;
  font-weight: 700;
  color: var(--lcd-ink);
  line-height: 1.2;
}

.hud-bonus[data-active="false"] {
  opacity: 0.35;
}

.bonus-meter {
  height: 9px;
  margin-top: 3px;
  border: 1.5px solid var(--lcd-ink);
  padding: 1px;
  background: var(--lcd-soft);
  display: block;
}

.bonus-meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--lcd-ink);
  transition: width 0.08s linear;
}

/* Square 20x20 Stage */
.lcd-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: min(50dvh, 336px);
  margin: 0 auto;
  border: 2px solid var(--lcd-ink);
  background: var(--lcd-bg);
  touch-action: none;
}

/* Keep stage strictly square when constrained by max-height */
@supports (aspect-ratio: 1 / 1) {
  .lcd-stage {
    width: min(100%, min(50dvh, 336px));
  }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* In-LCD Modal Overlay */
.lcd-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: color-mix(in srgb, var(--lcd-bg) 84%, transparent);
  backdrop-filter: blur(1px);
}

.lcd-overlay[hidden] {
  display: none !important;
}

.lcd-card {
  width: 100%;
  max-height: 100%;
  border: 2.5px solid var(--lcd-ink);
  background: var(--lcd-bg);
  box-shadow: 4px 4px 0 var(--lcd-ink);
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lcd-card[hidden] {
  display: none !important;
}

.pixel-emblem {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--lcd-mid);
}

.lcd-title {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--lcd-ink);
}

.lcd-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--lcd-mid);
  line-height: 1.35;
}

.lcd-footnote {
  margin: 0;
  font-size: 11px;
  color: var(--lcd-mid);
}

.lcd-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.lcd-btn {
  appearance: none;
  border: 2px solid var(--lcd-ink);
  background: var(--lcd-soft);
  color: var(--lcd-ink);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--lcd-ink);
}

.lcd-btn-primary {
  background: var(--lcd-ink);
  color: var(--lcd-bg);
}

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

.lcd-mini-btn {
  appearance: none;
  border: 1.5px solid currentColor;
  background: transparent;
  color: inherit;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.score-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.summary-cell {
  border: 1.5px solid var(--lcd-ink);
  background: var(--lcd-soft);
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
}

.summary-k {
  font-size: 10px;
  color: var(--lcd-mid);
}

.summary-v {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--lcd-ink);
}

.settle-banner {
  border: 1.5px dashed var(--lcd-ink);
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1.35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
}

.settle-banner[data-tone="ok"] {
  border-style: solid;
  background: var(--lcd-ink);
  color: var(--lcd-bg);
}

.lcd-footer-strip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1.5px solid var(--lcd-mid);
  font-family: var(--font-pixel);
  font-size: 9.5px;
  color: var(--lcd-mid);
}

/* Brand Row */
.chassis-brand-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 4px 2px;
}

.brand-mark {
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 13px;
  color: #2a2f66;
  letter-spacing: 0.05em;
}

.brand-model {
  font-family: var(--font-pixel);
  font-style: italic;
  font-size: 10px;
  color: #5b584f;
}

/* ==========================================================================
   Mechanical Control Deck (Cross D-Pad + Anti-Mispress Large Mode)
   ========================================================================== */

.control-deck {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  touch-action: none;
}

.control-deck[data-pad-mode="cross"] .deck-large-layout {
  display: none;
}

.control-deck[data-pad-mode="large"] .deck-cross-layout {
  display: none;
}

.deck-cross-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px;
}

/* Generous Touch Well for Thumb-Rolling D-Pad */
.dpad-touch-well {
  width: 152px;
  height: 152px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(95, 91, 80, 0.22) 0%, rgba(95, 91, 80, 0.05) 72%, transparent 74%);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  position: relative;
}

.dpad-cross {
  position: relative;
  width: 126px;
  height: 126px;
  pointer-events: none;
}

.dpad-arm {
  position: absolute;
  width: 42px;
  height: 42px;
  background: #27282d;
  color: #8f939e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid #141518;
  box-shadow: 0 4px 0 #121316;
  transition: transform 0.04s ease, background-color 0.04s ease, color 0.04s ease;
}

.dpad-up {
  top: 0;
  left: 42px;
  border-radius: 7px 7px 0 0;
  border-bottom: none;
}

.dpad-down {
  bottom: 0;
  left: 42px;
  border-radius: 0 0 7px 7px;
  border-top: none;
}

.dpad-left {
  top: 42px;
  left: 0;
  border-radius: 7px 0 0 7px;
  border-right: none;
}

.dpad-right {
  top: 42px;
  right: 0;
  border-radius: 0 7px 7px 0;
  border-left: none;
}

.dpad-pivot {
  position: absolute;
  top: 42px;
  left: 42px;
  width: 42px;
  height: 42px;
  background: #27282d;
  box-shadow: 0 4px 0 #121316;
}

.dpad-pivot::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1d1e22, #32343b);
}

.dpad-cross[data-active-dir="0"] .dpad-up,
.dpad-cross[data-active-dir="1"] .dpad-right,
.dpad-cross[data-active-dir="2"] .dpad-down,
.dpad-cross[data-active-dir="3"] .dpad-left {
  background: #3c4048;
  color: var(--dock-accent);
  transform: translateY(2px);
  box-shadow: 0 2px 0 #121316;
}

/* Angled B / A Buttons */
.ab-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ab-pod {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 40px;
  background: rgba(110, 106, 94, 0.22);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
  transform: rotate(-24deg);
}

.ab-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.ab-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--accent-burgundy-lo);
  background: radial-gradient(circle at 32% 28%, var(--accent-burgundy-hi), var(--accent-burgundy));
  color: #f6e7ec;
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 5px 0 var(--accent-burgundy-lo), 0 7px 12px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.ab-btn:active,
.ab-btn.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--accent-burgundy-lo);
}

.ab-caption {
  font-family: var(--font-pixel);
  font-size: 8.5px;
  color: #363462;
  letter-spacing: 0.04em;
}

/* Mode 2: Full-Width Anti-Mispress Large Pad */
.deck-large-layout {
  width: 100%;
  padding: 2px 0;
}

.large-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, 58px);
  gap: 8px;
}

.lpad-up {
  grid-column: 2;
  grid-row: 1;
}

.lpad-left {
  grid-column: 1;
  grid-row: 2;
}

.lpad-down {
  grid-column: 2;
  grid-row: 2;
}

.lpad-right {
  grid-column: 3;
  grid-row: 2;
}

.lpad-key {
  appearance: none;
  border: 2px solid #141518;
  border-radius: 10px;
  background: linear-gradient(180deg, #353840 0%, #24262c 100%);
  color: #eef0e6;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 4px 0 #121316;
  touch-action: none;
}

.lpad-key span {
  font-size: 13px;
  color: #b7bcc8;
}

.lpad-key:active,
.lpad-key.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #121316;
  border-color: var(--dock-accent);
  color: var(--dock-accent);
}

/* Bottom SELECT / START + Speaker Vents */
.meta-buttons-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 2px 8px 0;
}

.pill-pair {
  display: flex;
  gap: 22px;
  margin-left: 62px;
}

.pill-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transform: rotate(-24deg);
}

.pill-btn {
  width: 44px;
  height: 14px;
  border-radius: 10px;
  border: 1.5px solid #35363c;
  background: #5b5d66;
  box-shadow: 0 3px 0 #313238;
  touch-action: none;
}

.pill-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #313238;
}

.pill-label {
  font-family: var(--font-pixel);
  font-size: 8.5px;
  color: #363462;
  letter-spacing: 0.06em;
}

.speaker-vents {
  display: flex;
  gap: 6px;
  transform: rotate(-26deg);
  padding-bottom: 4px;
}

.speaker-vents span {
  width: 5px;
  height: 36px;
  border-radius: 4px;
  background: #6c695d;
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   Right Data Link Cartridge Dock
   ========================================================================== */

.data-dock {
  width: 390px;
  height: min(760px, 94dvh);
  background: var(--dock-bg);
  border: 2px solid var(--dock-border);
  border-radius: 16px;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dock-header {
  padding: 14px 16px 10px;
  background: #1b1e23;
  border-bottom: 2px solid var(--dock-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dock-title-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cartridge-grip {
  width: 96px;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    #424854 0px,
    #424854 6px,
    transparent 6px,
    transparent 10px
  );
}

.dock-heading {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 13px;
  color: var(--dock-accent);
}

.dock-close-btn {
  appearance: none;
  border: 1.5px solid var(--dock-border);
  background: var(--dock-panel);
  color: var(--dock-text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
}

.dock-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #1b1e23;
  border-bottom: 2px solid var(--dock-border);
  padding: 0 10px;
  gap: 6px;
}

.dock-tab {
  appearance: none;
  border: 2px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--dock-muted);
  padding: 9px 6px;
  font-size: 13px;
  border-radius: 8px 8px 0 0;
}

.dock-tab.is-active {
  background: var(--dock-bg);
  border-color: var(--dock-border);
  color: var(--dock-accent);
  font-weight: 700;
}

.dock-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px 16px 20px;
}

.dock-panel[hidden] {
  display: none !important;
}

/* Leaderboard */
.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.limit-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--dock-muted);
}

.pixel-select {
  background: var(--dock-panel);
  color: var(--dock-text);
  border: 1.5px solid var(--dock-border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}

.pixel-action-btn {
  appearance: none;
  border: 1.5px solid var(--dock-border);
  background: var(--dock-panel);
  color: var(--dock-text);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12px;
}

.pixel-action-btn:hover {
  border-color: var(--dock-accent);
}

.btn-danger {
  border-color: rgba(239, 100, 97, 0.55);
  color: #ff9492;
}

.status-note {
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: 6px;
  background: rgba(182, 217, 44, 0.1);
  border: 1px solid rgba(182, 217, 44, 0.35);
  font-size: 12px;
  color: var(--dock-text);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.leaderboard-table th {
  text-align: left;
  padding: 8px 8px;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--dock-muted);
  border-bottom: 2px solid var(--dock-border);
}

.leaderboard-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(66, 72, 84, 0.65);
}

.leaderboard-table .col-score {
  text-align: right;
  font-family: var(--font-pixel);
}

.leaderboard-table tr.is-self {
  background: rgba(182, 217, 44, 0.14);
  color: var(--dock-accent);
}

.rank-pill {
  font-family: var(--font-pixel);
  font-size: 12px;
}

.rank-1 {
  color: #ffd166;
}

.rank-2 {
  color: #cbd5e1;
}

.rank-3 {
  color: #f4a261;
}

.empty-row {
  text-align: center;
  color: var(--dock-muted);
  padding: 28px 8px !important;
}

/* Pilot Auth & Profile */
.pending-run-callout {
  background: rgba(182, 217, 44, 0.13);
  border: 1.5px solid var(--dock-accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12px;
}

.pending-run-callout p {
  margin: 4px 0 0;
  color: var(--dock-muted);
}

.pilot-card,
.auth-card,
.appeal-card {
  background: var(--dock-panel);
  border: 1.5px solid var(--dock-border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.pilot-badge-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pilot-kicker {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--dock-muted);
}

.pilot-name {
  margin: 3px 0 0;
  font-size: 19px;
  color: var(--dock-accent);
  word-break: break-all;
}

.session-pill {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(59, 226, 90, 0.16);
  color: #5ef07a;
  border: 1px solid rgba(59, 226, 90, 0.45);
}

.pilot-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.pilot-stat {
  background: var(--dock-bg);
  border: 1px solid var(--dock-border);
  border-radius: 8px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pilot-stat span {
  font-size: 11px;
  color: var(--dock-muted);
}

.pilot-stat strong {
  font-family: var(--font-pixel);
  font-size: 16px;
}

.pilot-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.auth-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  background: var(--dock-bg);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.auth-mode-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--dock-muted);
  padding: 7px;
  border-radius: 6px;
  font-size: 13px;
}

.auth-mode-btn.is-active {
  background: var(--dock-panel);
  color: var(--dock-accent);
  font-weight: 700;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--dock-muted);
}

.field-group input,
.appeal-card textarea {
  width: 100%;
  background: var(--dock-bg);
  border: 1.5px solid var(--dock-border);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--dock-text);
  font-size: 16px; /* >= 16px prevents iOS Safari auto-zoom on input focus! */
}

.field-group input:focus,
.appeal-card textarea:focus {
  outline: none;
  border-color: var(--dock-accent);
}

.form-feedback {
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(239, 100, 97, 0.14);
  border: 1px solid rgba(239, 100, 97, 0.5);
  color: #ffb0ae;
}

.form-feedback[data-tone="ok"] {
  background: rgba(59, 226, 90, 0.14);
  border-color: rgba(59, 226, 90, 0.5);
  color: #98f7ab;
}

.pixel-submit-btn {
  width: 100%;
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--dock-accent);
  color: #161a10;
  font-size: 14px;
  font-weight: 700;
}

/* Appeal Box */
.appeal-card {
  border-color: rgba(239, 100, 97, 0.65);
}

.appeal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ff9492;
  font-size: 13px;
  margin-bottom: 6px;
}

.appeal-ttl {
  font-family: var(--font-pixel);
  font-size: 11px;
}

.appeal-desc {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--dock-muted);
  line-height: 1.45;
}

.appeal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
}

.char-counter {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--dock-muted);
}

/* Guide */
.guide-block {
  background: var(--dock-panel);
  border: 1.5px solid var(--dock-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.guide-block h3 {
  margin: 0 0 8px;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--dock-accent);
}

.guide-block ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--dock-text);
}

.guide-block li + li {
  margin-top: 6px;
}

.guide-block code {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--dock-accent);
}

/* ==========================================================================
   Mobile Handheld Viewport Lock (< 960px)
   Fits 100% within 100dvh with ZERO page scroll & generous thumb ergonomics
   ========================================================================== */

@media (max-width: 959px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .workspace-shell {
    padding:
      env(safe-area-inset-top, 0px)
      env(safe-area-inset-right, 0px)
      env(safe-area-inset-bottom, 0px)
      env(safe-area-inset-left, 0px);
    gap: 0;
  }

  .handheld-chassis {
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border-width: 0;
    padding: 8px 12px max(10px, env(safe-area-inset-bottom));
    box-shadow: none;
  }

  .chassis-topbar {
    padding-bottom: 5px;
    margin-bottom: 4px;
  }

  .link-label {
    max-width: 78px;
  }

  .screen-bezel {
    padding: 7px 9px 8px;
    border-radius: 10px 10px 22px 10px;
  }

  .bezel-caption {
    margin-bottom: 4px;
  }

  .lcd-stage {
    max-height: min(41dvh, 320px);
    width: min(100%, min(41dvh, 320px));
  }

  .chassis-brand-row {
    padding: 2px 4px 0;
  }

  .dpad-touch-well {
    width: 156px;
    height: 156px;
  }

  .dpad-cross {
    width: 132px;
    height: 132px;
  }

  .dpad-arm,
  .dpad-pivot {
    width: 44px;
    height: 44px;
  }

  .dpad-up,
  .dpad-down,
  .dpad-pivot {
    left: 44px;
  }

  .dpad-left,
  .dpad-right,
  .dpad-pivot {
    top: 44px;
  }

  .pill-pair {
    margin-left: 28px;
  }

  /* Slide-Up Cartridge Drawer on Mobile */
  .dock-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.65);
  }

  .dock-backdrop[hidden] {
    display: none !important;
  }

  .data-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    width: 100%;
    height: 84dvh;
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .data-dock.is-open {
    transform: translateY(0);
  }
}

/* Extra-short mobile screens (e.g. landscape / compact phones) */
@media (max-width: 959px) and (max-height: 745px) {
  .bezel-caption,
  .chassis-brand-row,
  .lcd-footer-strip {
    display: none;
  }

  .lcd-stage {
    max-height: 41dvh;
    width: min(100%, 41dvh);
  }

  .dpad-touch-well {
    width: 138px;
    height: 138px;
  }

  .large-pad-grid {
    grid-template-rows: repeat(2, 48px);
  }
}
