:root {
  --bg: #070812;
  --ink: #f8fbff;
  --muted: #a4b0c5;
  --panel: rgba(8, 13, 27, 0.9);
  --panel-border: rgba(255, 255, 255, 0.14);
  --accent: #45e0c2;
  --accent-strong: #f7d35b;
  --danger: #ff5d77;
  --button: rgba(255, 255, 255, 0.11);
  --tile: rgba(255, 255, 255, 0.08);
  --tile-strong: rgba(255, 255, 255, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
}

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

.game-shell {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  overflow: hidden;
  background: #070812;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 42px;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.hud.is-hidden {
  opacity: 0;
}

.hud-group {
  min-width: 0;
  height: 46px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(4, 8, 20, 0.62);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.hud-label {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.hud strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.timer strong {
  color: var(--accent-strong);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 8, 20, 0.64);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  pointer-events: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(4, 6, 14, 0.38);
}

.overlay.is-visible {
  display: grid;
}

.platform-overlay {
  place-items: stretch center;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow: auto;
  touch-action: pan-y;
}

.platform-screen {
  width: min(760px, 100%);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.platform-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding-top: 4px;
}

.platform-chip,
.status-pill,
.tag-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  white-space: nowrap;
}

.platform-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #e9f1ff;
  font-size: 13px;
  font-weight: 800;
}

.sound-menu-button {
  border-color: rgba(69, 224, 194, 0.25);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-strip div {
  min-width: 0;
  min-height: 66px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.summary-strip span,
.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.summary-strip strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 24px;
  letter-spacing: 0;
}

.library-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.section-heading,
.card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.section-heading h2,
.card-title-row h3 {
  margin: 0;
  letter-spacing: 0;
}

.section-heading h2 {
  font-size: 22px;
}

.game-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 132px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.featured-card {
  border-color: rgba(69, 224, 194, 0.34);
}

.locked-card {
  opacity: 0.76;
}

.cartridge-art {
  position: relative;
  width: 92px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #11182b;
  background-size: 12px 12px;
}

.pixel-ship {
  position: absolute;
  left: 36px;
  top: 26px;
  width: 20px;
  height: 34px;
  background: #eefcff;
  clip-path: polygon(50% 0, 82% 64%, 62% 56%, 62% 100%, 38% 100%, 38% 56%, 18% 64%);
}

.pixel-bolt {
  position: absolute;
  left: 43px;
  top: 62px;
  width: 7px;
  height: 18px;
  background: var(--accent-strong);
}

.pixel-star {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent);
}

.star-a {
  left: 20px;
  top: 22px;
}

.star-b {
  right: 18px;
  bottom: 24px;
  background: #ff8ab1;
}

.maze-art {
  background:
    linear-gradient(90deg, transparent 0 18px, #45e0c2 18px 24px, transparent 24px 48px, #f7d35b 48px 54px, transparent 54px),
    linear-gradient(0deg, transparent 0 14px, rgba(255, 255, 255, 0.14) 14px 20px, transparent 20px 42px, rgba(255, 255, 255, 0.18) 42px 48px, transparent 48px),
    #121625;
  background-size: 54px 54px;
}

.tank-art {
  background:
    linear-gradient(90deg, rgba(247, 211, 91, 0.15) 1px, transparent 1px),
    linear-gradient(0deg, rgba(247, 211, 91, 0.13) 1px, transparent 1px),
    #182015;
  background-size: 14px 14px;
}

.pixel-tank {
  position: absolute;
  left: 30px;
  top: 30px;
  width: 34px;
  height: 26px;
  background: #8bd35f;
  box-shadow: inset 0 0 0 5px #355b30;
}

.pixel-tank::before {
  content: "";
  position: absolute;
  left: 12px;
  top: -16px;
  width: 10px;
  height: 22px;
  background: #d7ef8a;
}

.pixel-base {
  position: absolute;
  left: 35px;
  bottom: 12px;
  width: 24px;
  height: 20px;
  border: 4px solid #f7d35b;
  background: rgba(247, 211, 91, 0.18);
}

.pixel-shell {
  position: absolute;
  left: 45px;
  top: 12px;
  width: 4px;
  height: 8px;
  background: #ff5d77;
}

.game-card-body {
  min-width: 0;
}

.card-title-row h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.status-pill {
  min-height: 24px;
  padding: 0 9px;
  background: rgba(69, 224, 194, 0.16);
  color: #aaf8e8;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.muted {
  background: rgba(255, 255, 255, 0.1);
  color: #c9d2e4;
}

.game-card p {
  margin: 8px 0 10px;
  color: #d7dfef;
  font-size: 14px;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-row span {
  min-height: 24px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.09);
  color: #dce6f8;
  font-size: 12px;
}

.card-action {
  grid-column: 1 / -1;
  margin-top: 0;
}

.panel {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
}

.game-detail-panel {
  position: relative;
}

.panel.compact {
  width: min(340px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: 40px;
}

h2 {
  font-size: 30px;
}

.mode-picker,
.difficulty-picker {
  display: grid;
  gap: 8px;
}

.mode-picker {
  grid-template-columns: repeat(2, 1fr);
  margin: 22px 0 10px;
}

.game-sound-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  margin: 0 0 10px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #e7eefb;
  font-weight: 800;
}

.game-sound-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #c3cbd8;
  transition: transform 150ms ease, background 150ms ease;
}

.game-sound-control input:checked + .switch-track {
  background: rgba(69, 224, 194, 0.24);
}

.game-sound-control input:checked + .switch-track::after {
  transform: translateX(22px);
  background: var(--accent);
}

.difficulty-picker {
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 16px;
}

.difficulty-button,
.mode-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 8px;
  cursor: pointer;
}

.difficulty-button,
.mode-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--button);
  color: #dfe7f5;
}

.difficulty-button.is-selected,
.mode-button.is-selected {
  border-color: rgba(69, 224, 194, 0.7);
  background: rgba(69, 224, 194, 0.17);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(69, 224, 194, 0.18);
}

.mode-button.is-disabled {
  color: #7f8ba2;
  cursor: default;
  opacity: 0.7;
}

.primary-button,
.secondary-button {
  width: 100%;
  margin-top: 10px;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #051118;
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: var(--button);
  color: #edf4ff;
}

.ghost-button {
  position: absolute;
  top: 16px;
  right: 16px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #e3ebfb;
  font-size: 13px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0 10px;
}

.result-grid div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.tank-controls {
  position: absolute;
  inset: auto max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.tank-controls.is-hidden {
  display: none;
}

.tank-joystick,
.tank-fire-button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.tank-joystick {
  position: relative;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(5, 10, 20, 0.52);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

.tank-joystick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(69, 224, 194, 0.9);
  transform: translate(-50%, -50%);
}

.tank-fire-button {
  width: 88px;
  height: 88px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 93, 119, 0.88);
  color: #fff8fa;
  font-size: 34px;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

dt,
dd {
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  overflow: hidden;
  margin-top: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 24px;
  font-weight: 900;
}

@media (min-width: 680px) {
  .game-card {
    grid-template-columns: 104px minmax(0, 1fr) 132px;
    min-height: 124px;
    padding: 14px;
  }

  .cartridge-art {
    width: 104px;
  }

  .card-action {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .hud {
    grid-template-columns: 1fr 1fr 1fr 40px;
    gap: 6px;
  }

  .hud-group {
    height: 43px;
    padding: 7px 6px;
  }

  .hud strong {
    font-size: 16px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .panel {
    padding: 20px;
  }

  .ghost-button {
    top: 12px;
    right: 12px;
  }

  h1 {
    font-size: 34px;
  }

  .summary-strip strong {
    font-size: 20px;
  }

  .game-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .cartridge-art {
    width: 84px;
  }

  .game-card p {
    font-size: 13px;
  }

  .tank-joystick {
    width: 104px;
    height: 104px;
  }

  .tank-joystick span {
    width: 40px;
    height: 40px;
  }

  .tank-fire-button {
    width: 78px;
    height: 78px;
    font-size: 30px;
  }
}
