:root {
  color-scheme: dark;
  --black: #000000;
  --white: #ffffff;
  --panel: #111111;
  --panel-2: #1b1b1b;
  --field: #050505;
  --line: #333333;
  --muted: #b8b8b8;
  --quiet: #7a7a7a;
  --red: #ff0000;
  --yellow: #ffff00;
  --green: #00ff00;
  --blue: #0000ff;
  --danger: #ff0000;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--black);
  color: var(--white);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100dvh;
  overflow: hidden;
}

.screen {
  display: none;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
}

.entry-screen {
  align-items: center;
  justify-content: center;
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  background: var(--black);
}

.entry-panel {
  container-type: inline-size;
  width: min(100%, 430px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.brand-lockup {
  margin-bottom: 24px;
}

.eyebrow,
.tiny-label {
  display: block;
  margin: 0 0 6px;
  color: var(--yellow);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2.15rem, 12vw, 4.35rem);
  line-height: 0.95;
  text-transform: uppercase;
}

#entry-title {
  max-width: 100%;
  font-size: clamp(1.9rem, 8.6vw, 3rem);
  white-space: nowrap;
}

@supports (font-size: 1cqw) {
  #entry-title {
    font-size: clamp(2rem, 10.75cqw, 3rem);
  }
}

h2 {
  color: var(--white);
  font-size: 1.08rem;
}

.mode-switch,
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.mode-button,
.segmented-control span {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.mode-button.active,
.segmented-control input:checked + span {
  background: var(--green);
  color: var(--black);
}

.entry-form,
.settings-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.field-label,
.role-field legend {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.role-field {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented-control label {
  display: block;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  place-items: center;
  width: 100%;
}

input[type="text"],
input[type="number"],
input:not([type]) {
  width: 100%;
}

#player-name,
#room-code {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--white);
  padding: 0 14px;
  outline: 0;
}

#player-name::placeholder,
#room-code::placeholder {
  color: var(--quiet);
}

#player-name:focus,
#room-code:focus,
.number-input input:focus {
  border-color: var(--green);
}

.code-field {
  display: grid;
  gap: 7px;
}

.hidden {
  display: none !important;
}

.primary-action,
.secondary-action,
.icon-text-button,
.code-button,
.danger-action {
  min-height: 46px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-weight: 950;
}

.primary-action {
  background: var(--green);
  color: var(--black);
  border-color: var(--green);
}

.danger-action {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.secondary-action,
.icon-text-button,
.code-button {
  background: var(--panel-2);
  color: var(--white);
}

.secondary-action.active {
  background: var(--yellow);
  color: var(--black);
  border-color: var(--yellow);
}

.icon-text-button:hover,
.secondary-action:hover,
.code-button:hover,
.map-controls button:hover {
  border-color: var(--yellow);
}

.primary-action:disabled,
.secondary-action:disabled,
.icon-text-button:disabled,
.danger-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.lobby-screen,
.game-screen {
  flex-direction: column;
  background: var(--black);
}

.top-bar,
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px 12px;
  background: var(--black);
  border-bottom: 1px solid var(--line);
}

.top-bar h1,
.game-header h1 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: clamp(1.5rem, 7vw, 2.35rem);
  line-height: 1;
}

.code-button {
  min-width: 94px;
  min-height: 38px;
  padding: 0 10px;
  color: var(--yellow);
}

.lobby-layout {
  display: grid;
  gap: 14px;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 14px 16px 100px;
}

.settings-panel,
.players-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--yellow);
  border-radius: 999px;
  background: var(--black);
  color: var(--yellow);
  font-size: 0.76rem;
  font-weight: 950;
  white-space: nowrap;
}

.setting-row,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 850;
}

.number-input {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 850;
}

.number-input input {
  width: 76px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--white);
  padding: 0 8px;
  text-align: center;
  outline: 0;
}

.toggle-row input {
  width: 24px;
  height: 24px;
  accent-color: var(--green);
}

.player-list,
.compact-player-list {
  display: grid;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.player-row:last-child {
  border-bottom: 0;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  color: var(--white);
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 780;
}

.role-tag {
  justify-self: end;
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--white);
  font-size: 0.76rem;
  font-weight: 950;
}

.role-tag.runner {
  background: var(--red);
}

.role-tag.seeker {
  background: var(--blue);
}

.lobby-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--black);
  border-top: 1px solid var(--line);
}

.lobby-actions .form-error {
  grid-column: 1 / -1;
}

.game-screen {
  height: 100dvh;
}

.game-header {
  flex: 0 0 auto;
  z-index: 4;
}

.game-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 260px;
  overflow: hidden;
  background: var(--black);
}

.map-stage::after {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  content: "";
  pointer-events: none;
}

.map {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
  user-select: none;
}

.tile-pane,
.marker-pane {
  position: absolute;
  inset: 0;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  filter: grayscale(0.25) contrast(1.05) brightness(0.75);
  user-select: none;
  -webkit-user-drag: none;
}

.map-attribution {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--black);
  color: var(--muted);
  font-size: 0.68rem;
}

.map-attribution a {
  color: inherit;
}

.marker {
  position: absolute;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -100%);
  border: 3px solid var(--white);
  border-radius: 50% 50% 50% 0;
  rotate: -45deg;
}

.marker::after {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--white);
  content: "";
}

.marker span {
  position: absolute;
  top: 27px;
  left: 50%;
  max-width: 150px;
  transform: translateX(-50%) rotate(45deg);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--black);
  color: var(--white);
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 950;
  white-space: nowrap;
}

.marker.runner {
  background: var(--red);
}

.marker.seeker {
  background: var(--blue);
}

.accuracy-circle {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 1px solid var(--blue);
  border-radius: 50%;
  pointer-events: none;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  gap: 7px;
}

.map-controls button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 950;
}

.bottom-sheet {
  flex: 0 0 auto;
  padding: 9px 16px max(14px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.sheet-grip {
  width: 42px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--line);
}

.game-status-row,
.control-row,
.legend-row {
  display: grid;
  gap: 10px;
}

.game-status-row {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 10px;
}

.game-status-row strong {
  display: block;
  overflow: hidden;
  color: var(--white);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-row {
  grid-template-columns: 1fr;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 50%;
}

.runner-dot {
  background: var(--red);
}

.seeker-dot {
  background: var(--blue);
}

.compact-player-list {
  max-height: 120px;
  overflow: auto;
}

.compact-player-list .player-row {
  min-height: 42px;
  padding: 6px 0;
}

.catch-button {
  min-height: 34px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: var(--red);
  color: var(--white);
  font-weight: 950;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: var(--black);
}

.confirm-panel {
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.confirm-panel p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

@media (min-width: 760px) {
  .entry-screen {
    justify-content: flex-start;
    padding-left: 9vw;
  }

  .lobby-layout {
    grid-template-columns: minmax(300px, 0.82fr) 1fr;
    align-items: start;
    padding-bottom: 120px;
  }

  .lobby-actions {
    left: 50%;
    width: min(100% - 32px, 980px);
    grid-template-columns: 1fr 1fr;
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .game-screen {
    display: none;
  }

  .game-screen.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .game-header {
    grid-column: 1 / -1;
  }

  .map-stage {
    min-height: 0;
  }

  .bottom-sheet {
    display: block;
    overflow: auto;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .sheet-grip {
    display: none;
  }

  .game-status-row,
  .control-row {
    grid-template-columns: 1fr;
  }

  .compact-player-list {
    max-height: none;
  }
}
