:root {
  color-scheme: dark;
  --bg: #080912;
  --panel: rgba(12, 16, 30, 0.78);
  --panel-strong: rgba(15, 22, 38, 0.96);
  --text: #f7fbff;
  --muted: #aab8ce;
  --line: rgba(255, 255, 255, 0.18);
  --line-strong: rgba(255, 255, 255, 0.44);
  --yellow: #ffd84a;
  --cyan: #38d5ff;
  --green: #41e48f;
  --red: #ff5d6c;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
}

button,
a {
  font: inherit;
}

.top-bar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.home-link,
.icon-button,
.mode-button,
.exit-game {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(10, 14, 28, 0.82);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  text-decoration: none;
  cursor: pointer;
}

.home-link {
  min-width: 74px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0;
}

.top-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-button {
  min-width: 42px;
  height: 42px;
  border-radius: 8px;
  font-weight: 900;
}

.icon-button.wide {
  width: 72px;
}

.home-link:hover,
.icon-button:hover,
.mode-button:hover,
.exit-game:hover {
  border-color: var(--line-strong);
  background: rgba(29, 42, 72, 0.94);
}

.status-pill {
  min-height: 42px;
  max-width: min(48vw, 620px);
  display: flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 20, 0.72);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(82px, auto));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 8, 17, 0.8);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
}

.mode-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  box-shadow: none;
  color: var(--muted);
  background: transparent;
}

.mode-button.active {
  color: #07111c;
  border-color: rgba(255, 255, 255, 0.74);
  background: linear-gradient(180deg, #ffe889, var(--yellow));
}

.arcade-view {
  position: fixed;
  inset: 0;
  background: #070812;
}

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

.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 10;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px rgba(56, 213, 255, 0.6);
  pointer-events: none;
}

.crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
  transform: translate(-50%, -50%);
}

.interaction-prompt {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 12;
  width: min(560px, calc(100vw - 28px));
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 20, 0.74);
  color: var(--text);
  transform: translateX(-50%);
  text-align: center;
  font-weight: 700;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px);
}

.movement-panel {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 12;
  width: 152px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 20, 0.68);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  backdrop-filter: blur(12px);
}

.movement-title {
  color: var(--text);
  font-weight: 900;
}

.arcade-mobile-controls {
  display: none;
  position: fixed;
  inset: auto 12px 18px;
  height: 178px;
  z-index: 18;
  pointer-events: none;
}

.arcade-mobile-joystick {
  position: absolute;
  left: 6px;
  bottom: 0;
  width: 156px;
  height: 156px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(8, 11, 20, 0.58);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36), inset 0 0 24px rgba(56, 213, 255, 0.12);
  pointer-events: auto;
  touch-action: none;
}

.arcade-mobile-joystick-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66px;
  height: 66px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe889, var(--yellow));
  box-shadow: 0 0 24px rgba(255, 216, 74, 0.35);
  transform: translate(-50%, -50%);
}

.arcade-mobile-look {
  left: auto;
  right: 6px;
}

.arcade-mobile-look .arcade-mobile-joystick-stick {
  background: #38d5ff;
  box-shadow: 0 0 24px rgba(56, 213, 255, 0.35);
}

.arcade-mobile-actions {
  position: absolute;
  right: 0;
  bottom: 136px;
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 9px;
  pointer-events: auto;
}

.arcade-mobile-actions button {
  min-height: 58px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(10, 14, 28, 0.88);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  font-weight: 900;
}

#arcade-mobile-play {
  min-height: 58px;
  color: #07111c;
  background: linear-gradient(180deg, #ffe889, var(--yellow));
}

.classic-view {
  min-height: 100vh;
  overflow-y: auto;
  padding: 88px 18px 42px;
  background:
    linear-gradient(rgba(8, 9, 18, 0.82), rgba(8, 9, 18, 0.9)),
    repeating-linear-gradient(90deg, rgba(65, 228, 143, 0.12) 0 2px, transparent 2px 120px),
    repeating-linear-gradient(0deg, rgba(56, 213, 255, 0.1) 0 2px, transparent 2px 120px);
}

.classic-view[hidden],
.game-overlay[hidden] {
  display: none;
}

.site-header {
  width: min(1080px, 100%);
  margin: 0 auto 22px;
  text-align: center;
}

.arcade-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 216, 74, 0.58);
  border-radius: 8px;
  color: var(--yellow);
  background: rgba(255, 216, 74, 0.1);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
}

.site-header h1 {
  margin: 10px 0 4px;
  font-size: clamp(32px, 7vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}

.site-header p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.game-grid {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.game-grid.compact {
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  max-height: min(68vh, 720px);
  overflow-y: auto;
  padding-right: 4px;
}

.game-card {
  min-height: 172px;
  display: grid;
  grid-template-rows: 104px auto;
  align-items: center;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 19, 33, 0.86);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.game-card:hover,
.game-card:focus-visible {
  outline: none;
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(23, 35, 57, 0.96);
  box-shadow: 0 16px 34px rgba(56, 213, 255, 0.18);
}

.game-icon {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent),
    var(--icon-color, #264c84);
  color: white;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.game-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card-title {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-weight: 800;
  line-height: 1.15;
}

.locator-dialog {
  width: min(1080px, calc(100vw - 28px));
  max-height: min(88vh, 860px);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(7, 9, 18, 0.96);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}

.locator-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.locator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.locator-header h2,
.locator-header p {
  margin: 0;
}

.locator-header h2 {
  font-size: 28px;
}

.eyebrow {
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  background: #02030a;
}

.game-overlay:fullscreen {
  width: 100vw;
  height: 100vh;
}

.game-chrome {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 9, 18, 0.98);
}

.exit-game {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 900;
}

.game-title {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: black;
}

body.playing .top-bar,
body.playing .interaction-prompt,
body.playing .movement-panel,
body.playing .arcade-mobile-controls,
body.classic .arcade-view {
  display: none;
}

body.classic {
  overflow: auto;
}

@media (max-width: 760px), (pointer: coarse) {
  .arcade-mobile-controls {
    display: block;
  }

  .top-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .top-center {
    order: 3;
    justify-content: stretch;
  }

  .status-pill {
    max-width: none;
    flex: 1;
  }

  .mode-toggle {
    justify-self: stretch;
  }

  .movement-panel {
    display: none;
  }

  .interaction-prompt {
    bottom: 202px;
    font-size: 13px;
  }

  .arcade-mobile-joystick {
    width: 132px;
    height: 132px;
  }

  .arcade-mobile-joystick-stick {
    width: 58px;
    height: 58px;
  }

  .game-grid {
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  }

  .game-card {
    min-height: 148px;
    grid-template-rows: 82px auto;
  }

  .game-icon {
    width: 76px;
    height: 76px;
    font-size: 22px;
  }
}
