@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  color-scheme: light;
  --paper: #f3f0e8;
  --ink: #11110f;
  --muted: #706e67;
  --line: #c9c5ba;
  --hazard: #ff5c35;
  --safe: #18a56b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background:
    linear-gradient(rgba(17, 17, 15, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 15, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.scoreboard,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 54px;
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand-mark {
  width: 17px;
  height: 17px;
  background: var(--ink);
  box-shadow: 6px 6px 0 var(--hazard);
}

.connection-status {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a5a198;
}

.status-dot.online {
  background: var(--safe);
  box-shadow: 0 0 0 4px rgba(24, 165, 107, 0.12);
}

.game-panel {
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
  background: var(--paper);
}

.scoreboard {
  min-height: 76px;
  padding: 12px 20px;
  border-bottom: 2px solid var(--ink);
}

.scoreboard > div {
  display: flex;
  min-width: 120px;
  flex-direction: column;
}

.scoreboard-center {
  align-items: center;
}

.scoreboard-right {
  align-items: flex-end;
}

.eyebrow,
.kicker,
label,
.control-hint,
.game-footer {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--muted);
}

.scoreboard strong {
  font-size: 25px;
  line-height: 1.15;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  background: #e8e4da;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 8 / 5;
  touch-action: none;
}

.screen-overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(243, 240, 232, 0.9);
  backdrop-filter: blur(4px);
}

.elimination-notice {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 50%;
  max-width: calc(100% - 36px);
  transform: translateX(-50%);
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 10px 16px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 5px 5px 0 var(--hazard);
}

.elimination-notice[hidden] {
  display: none;
}

.screen-overlay[hidden] {
  display: none;
}

.myForm,
.game-over-card {
  width: min(620px, 100%);
}

.kicker {
  margin: 0 0 14px;
  color: var(--hazard);
}

h1,
h2 {
  margin: 0;
  font-size: clamp(42px, 7vw, 80px);
  line-height: 0.88;
  letter-spacing: -0.075em;
}

.intro {
  max-width: 500px;
  margin: 24px 0 28px;
  color: #56544e;
  font-size: 15px;
  line-height: 1.55;
}

label:not(.color-option) {
  display: block;
  margin-bottom: 8px;
}

.input-row {
  display: flex;
}

input[type="text"] {
  min-width: 0;
  flex: 1;
  height: 52px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  padding: 0 16px;
  outline: none;
}

input[type="text"]:focus {
  box-shadow: inset 0 0 0 2px var(--hazard);
}

.color-picker {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.color-picker legend {
  margin-bottom: 8px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.color-options {
  display: flex;
  gap: 10px;
}

.color-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.color-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.color-swatch {
  display: block;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  background: var(--swatch);
}

.color-option input:checked + .color-swatch {
  outline: 3px solid var(--paper);
  box-shadow: 0 0 0 5px var(--ink);
}

.color-option input:focus-visible + .color-swatch {
  outline: 3px solid var(--paper);
  box-shadow: 0 0 0 5px var(--hazard);
}

.color-black { --swatch: #11110f; }
.color-orange { --swatch: #ff5c35; }
.color-red { --swatch: #d92d20; }
.color-pink { --swatch: #ec4899; }
.color-green { --swatch: #18a56b; }

.input-row button,
.game-over-card button {
  min-height: 52px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 0 22px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.input-row button:hover,
.game-over-card button:hover {
  background: var(--hazard);
}

.form-message {
  min-height: 20px;
  margin: 8px 0 0;
  color: #b62f17;
  font-size: 12px;
}

.install-app-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.install-app-button:hover {
  background: var(--ink);
  color: var(--paper);
}

.install-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  line-height: 1.5;
}

.control-hint {
  margin: 12px 0 0;
  color: var(--muted);
}

.mobile-touch-copy {
  display: none;
}

kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  margin: 0 2px;
  place-items: center;
  border: 1px solid #9f9b91;
  background: #e8e4da;
  color: var(--ink);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  box-shadow: 0 2px 0 #9f9b91;
}

.game-over {
  text-align: center;
}

.game-over-card h2 {
  margin-bottom: 22px;
}

.game-over-card > p:not(.kicker, .control-hint) {
  margin-bottom: 22px;
  color: var(--muted);
}

.game-footer {
  min-height: 54px;
  padding: 0 18px;
  border-top: 2px solid var(--ink);
  color: var(--muted);
}

.game-footer p {
  margin: 0;
}

.legend-player,
.legend-obstacle {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  vertical-align: -1px;
}

.legend-player {
  background: var(--ink);
}

.legend-obstacle {
  border: 2px solid var(--hazard);
}

.divider {
  margin: 0 8px;
}

@media (hover: none) and (pointer: coarse) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  body {
    background: var(--ink);
  }

  .game-shell {
    display: flex;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    margin: 0;
    padding: 0;
  }

  .topbar {
    min-height: 40px;
    flex: 0 0 40px;
    border: 0;
    background: var(--paper);
    padding: 0 12px;
  }

  .brand {
    font-size: 15px;
  }

  .brand-mark {
    width: 13px;
    height: 13px;
    box-shadow: 4px 4px 0 var(--hazard);
  }

  .connection-status {
    font-size: 9px;
  }

  .game-panel {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    border: 0;
  }

  .scoreboard {
    min-height: 54px;
    flex: 0 0 54px;
    padding: 8px 12px;
    border-top: 1px solid var(--ink);
    border-bottom: 2px solid var(--ink);
  }

  .scoreboard > div {
    min-width: 0;
    flex: 1;
  }

  .scoreboard strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 15px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .eyebrow {
    font-size: 8px;
  }

  .canvas-wrap {
    display: flex;
    min-height: 0;
    flex: 1;
    align-items: center;
    justify-content: center;
    background: var(--ink);
  }

  canvas {
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 9 / 16;
  }

  .screen-overlay {
    position: fixed;
    overflow-y: auto;
    align-items: center;
    padding:
      max(24px, env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
    background: var(--paper);
    backdrop-filter: none;
  }

  .myForm,
  .game-over-card {
    width: min(100%, 420px);
  }

  .myForm .kicker,
  .intro,
  .control-hint,
  .desktop-help,
  .game-footer {
    display: none;
  }

  h1,
  h2 {
    font-size: clamp(38px, 12vw, 54px);
    line-height: 0.95;
  }

  .myForm label:not(.color-option) {
    margin-top: 28px;
  }

  .input-row {
    flex-direction: column;
    gap: 10px;
  }

  input[type="text"] {
    width: 100%;
    min-height: 54px;
    flex: none;
  }

  .input-row button {
    width: 100%;
    min-height: 54px;
    padding: 0 14px;
  }

  .color-picker {
    margin-top: 22px;
  }

  .color-options {
    justify-content: space-between;
  }

  .color-swatch {
    width: 40px;
    height: 40px;
  }

  .form-message {
    min-height: 18px;
    margin-top: 10px;
  }

  .mobile-touch-copy {
    display: block;
    margin: 8px 0 0;
    color: var(--muted);
    font-family: "DM Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    line-height: 1.5;
    text-transform: uppercase;
  }

  .elimination-notice {
    top: 10px;
    max-width: calc(100% - 24px);
    padding: 8px 12px;
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
