/*
 * style.css — Starswing's cards and corner, cut from the night sky itself.
 *
 * The sky is glow on near-black, so the cards are dark glass over it with a
 * thin rim of starlight: the bot keeps swinging behind the start screen and
 * shows through. One accent, the first zone's ice blue, with the dust's gold
 * for a record. The corner plates are round, like everything that shines
 * here. No web fonts (hub §1): the system's rounded face, else its sans.
 *
 * Layout: each card is one grid, centred with top/left 50% and translate
 * (hub §2, the iPad lesson — never inset:0 + margin:auto). On a sideways
 * phone each card becomes two columns laid over the same markup by grid
 * area, maxgear's shape, so no menu scrolls there. The chrome's structure is
 * geometry_pong's; the surface is this game's.
 */

:root {
  --night: #05060f;
  --glass: rgba(8, 10, 24, 0.78);
  --edge: rgba(150, 190, 255, 0.24);
  --ink: #eef2ff;
  --dim: #98a4c8;
  --ice: #5ac8ff;
  --gold: #ffd678;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 48px;
  --corner-gap: 8px;
  --corner-room: calc(3 * var(--tap) + 2 * var(--corner-gap) + 24px);
  --gutter: 84px; /* every caption in the menu starts its control at the same x */
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

/* A game, not a document (hub §2): js/touch-guard.js is the other half. */
html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* The sky. A finger anywhere on it is the one button. */
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* ---- the corner ---- */

#corner {
  position: absolute;
  z-index: 2;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  display: flex;
  gap: var(--corner-gap);
  pointer-events: auto;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  color: var(--ink);
  background: var(--glass);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* [hidden] loses to display:flex without this (hub §2, hit three times). */
.icon-button[hidden] {
  display: none;
}
#sound-btn[aria-pressed="true"] .icon-waves,
#sound-btn:not([aria-pressed="true"]) .icon-slash,
#screen-toggle[aria-pressed="true"] .icon-expand,
#screen-toggle:not([aria-pressed="true"]) .icon-contract {
  display: none;
}

/* ---- cards ---- */

.card {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: min(400px, calc(100% - 32px));
  max-height: calc(100% - 2 * (var(--tap) + 24px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto; /* a safety net on very short screens, not the plan */
  padding: 24px 22px 20px;
  display: grid;
  gap: 16px;
  align-content: start;
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: 22px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 40px rgba(90, 200, 255, 0.12), 0 20px 60px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

h1,
h2 {
  margin: 0;
  text-wrap: balance;
}
h2 {
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

/* STAR in starlight, SWING in the comet's colours, one line. */
.wordmark {
  display: flex;
  gap: 0.12em;
  font-size: clamp(2.2rem, 11vw, 3.1rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}
.wordmark span:first-child {
  color: var(--ink);
  text-shadow: 0 0 18px rgba(190, 215, 255, 0.7);
}
.wordmark span:last-child {
  background: linear-gradient(90deg, var(--ice), #aa82ff 55%, #ff6ebe);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(90, 200, 255, 0.45));
}

.tag {
  margin: 0;
  color: var(--dim);
  line-height: 1.45;
}
.title-block {
  display: grid;
  gap: 12px;
}

/* ---- buttons ---- */

.doors,
.actions {
  display: grid;
  gap: 10px;
  justify-items: stretch;
}
.go {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 700 1.05rem var(--font);
  letter-spacing: 0.02em;
  cursor: pointer;
  background: var(--ice);
  color: #03121c;
  box-shadow: 0 0 24px rgba(90, 200, 255, 0.45);
}
.go.alt {
  background: transparent;
  color: var(--ink);
  border-color: var(--edge);
  box-shadow: none;
}
/* The way back to the arcade: secondary, last, a little apart. */
.go.exit {
  margin-top: 8px;
  background: transparent;
  color: var(--dim);
  border-color: var(--edge);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.go.exit svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.go:disabled {
  opacity: 0.5;
  cursor: default;
}
button:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

#update {
  display: grid;
  gap: 2px;
  padding: 8px 16px;
  border-color: var(--gold);
  color: var(--gold);
}
#update .update-sub {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.8;
}
#update[hidden] {
  display: none;
}
#build {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* ---- the menu panel ---- */

.menu {
  grid-template-areas: "head" "actions" "settings" "exit";
}
.menu-head {
  grid-area: head;
  display: grid;
  gap: 6px;
}
.menu-actions {
  grid-area: actions;
}
.menu-settings {
  grid-area: settings;
  display: grid;
  gap: 10px;
}
#menu-exit {
  grid-area: exit;
}
.vol-row {
  display: grid;
  grid-template-columns: var(--gutter) 1fr 3ch;
  align-items: center;
  gap: 10px;
}
.lang-row {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  align-items: center;
  gap: 10px;
}
.vol-row label,
.cap {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.vol-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.vol-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--dim);
  line-height: 1.4;
}

/* The start screen's Players and Mode: one block, one caption gutter. */
.setup {
  display: grid;
  gap: 10px;
}

/* Segmented rows: alternatives, so one size each (flex: 1 1 0). */
.seg {
  display: flex;
  gap: 6px;
}
.seg-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 42px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--edge);
  background: transparent;
  color: var(--ink);
  font: 700 0.95rem var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
/* A guest's view of the host's choice: the choice stays lit. */
.seg-btn:disabled {
  cursor: default;
}
.seg-btn:disabled:not([aria-pressed="true"]) {
  opacity: 0.45;
}
.seg-btn[aria-pressed="true"] {
  border-color: var(--ice);
  color: var(--ice);
  background: rgba(90, 200, 255, 0.1);
  box-shadow: 0 0 14px rgba(90, 200, 255, 0.25);
}
.flag {
  width: 22px;
  height: 16px;
  flex: none;
  border-radius: 2px;
}

/* A styled range: a beam with a star on it. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ice), #aa82ff);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ice), #aa82ff);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  box-shadow: 0 0 12px 2px rgba(190, 215, 255, 0.8);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: #fff;
  box-shadow: 0 0 12px 2px rgba(190, 215, 255, 0.8);
}

/* ---- the end of a run ---- */

.over {
  justify-items: center;
  text-align: center;
}
#over-title {
  font-size: 2.4rem;
  font-variant-numeric: tabular-nums;
}
.record-line {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 214, 120, 0.6);
}
.over.record #over-title {
  color: var(--gold);
}
.actions.pair {
  grid-template-columns: 1fr 1fr;
  width: 100%;
}
/* A guest has no Play again: its one button takes the row. */
#over-again[hidden] + #over-main {
  grid-column: 1 / -1;
}

/* ---- online: the lobby card ---- */

/* geometry_pong's lobby in this sky's light: the same glass and buttons as
   every other card, the code glowing like a caught star, and each seat a
   round comet in its player's colour. */
.online-head {
  display: grid;
  gap: 6px;
}
.online-step {
  display: grid;
  gap: 12px;
  margin: 0;
}
.status {
  margin: 0;
  min-height: 1.4em;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--dim);
}
.status.warn {
  color: var(--gold);
}
/* The picture code (hub §8): three slots that fill as the keypad is
   tapped, and the same three, big, in the room — what a host reads out and
   a guest checks they got right. Emoji from the system font: no download. */
.code-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.code-slot {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 30px;
  line-height: 1;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: rgba(90, 200, 255, 0.07);
}
.code-slot.empty {
  color: var(--dim);
  font-size: 20px;
  font-weight: 700;
}
.code-row.hero {
  gap: 12px;
}
.code-row.hero .code-slot {
  width: 84px;
  height: 84px;
  font-size: 46px;
  border-color: rgba(90, 200, 255, 0.45);
  background: rgba(90, 200, 255, 0.1);
  box-shadow: 0 0 26px rgba(90, 200, 255, 0.18);
}
.code-words {
  margin: 0;
  min-height: 1.3em;
  text-align: center;
  font-size: 0.9rem;
  color: var(--dim);
}
/* Twelve keys, six by two: alternatives, so one size each (hub §2). */
.pad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
#room-wait {
  text-align: center;
}
.pad-key {
  color: inherit;
  min-height: var(--tap);
  font-size: 26px;
  line-height: 1;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: rgba(130, 170, 255, 0.08);
  cursor: pointer;
}
.pad-key:active {
  background: rgba(90, 200, 255, 0.2);
}
.room-code-block {
  display: grid;
  gap: 4px;
  justify-items: center;
  text-align: center;
}
/* The seats: one group, so one grid with a shared swatch gutter (hub §2). */
.seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}
.seat {
  --c: var(--ice);
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--edge);
  font-size: 0.85rem;
}
.seat::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--c);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--c);
}
.seat.bot {
  color: var(--dim);
}
.seat.bot::before {
  opacity: 0.45;
}
.seat.me {
  border-color: var(--c);
  box-shadow: inset 0 0 0 1px var(--c);
}
#online-back {
  margin-top: 4px;
}

/* ---- a sideways phone: two columns, nothing scrolls ---- */

@media (orientation: landscape) and (max-height: 500px) {
  /* The corner takes the top right only, so the card keeps clear of it on
     that side alone and centres in what is left. */
  .card {
    left: calc(env(safe-area-inset-left, 0px) + 16px);
    right: calc(env(safe-area-inset-right, 0px) + var(--corner-room));
    margin-inline: auto;
    translate: 0 -50%;
    width: min(680px, calc(100% - var(--corner-room) - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    max-height: calc(100% - 24px);
    padding: 14px 18px;
    gap: 10px 22px;
  }
  .start {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "title doors" "setup doors";
    align-items: center;
  }
  .title-block {
    grid-area: title;
  }
  .setup {
    grid-area: setup;
  }
  .doors {
    grid-area: doors;
  }
  /* The lobby: the heading, the status and Back down the left, whichever
     step is showing down the right. */
  .online {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "head step" "status step" "back step";
    align-items: center;
  }
  .online-head {
    grid-area: head;
  }
  .online-step {
    grid-area: step;
  }
  #online-status {
    grid-area: status;
  }
  #online-back {
    grid-area: back;
  }
  .code-row.hero .code-slot {
    width: 62px;
    height: 62px;
    font-size: 34px;
  }
  .code-slot {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  .pad-key {
    min-height: 40px;
    font-size: 22px;
  }
  .seats {
    grid-template-columns: 1fr 1fr;
  }
  .seat {
    padding: 4px 8px;
  }
  .menu {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "head settings" "actions settings" "exit settings";
  }
  .menu-settings {
    align-content: center;
  }
  .over {
    width: min(420px, calc(100% - var(--corner-room) - 32px));
  }
  .go {
    min-height: 40px;
  }
  .seg-btn {
    height: 38px;
  }
}

/* ---- the opening sting ---- */

/*
 * js/intro.js, a canvas the script creates and removes. Over everything in
 * the game, the corner plates and the cards included, because it is a
 * curtain: a tap anywhere on it is the skip. The crash bar is raised above
 * it, so a boot failure is still read rather than hidden behind the night.
 */
#intro {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  touch-action: none;
  cursor: pointer;
}

/* ---- failure ---- */

#crash {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 30; /* above the sting */
  padding: 10px 14px;
  border-radius: 10px;
  background: #3a0d16;
  border: 1px solid #ff5266;
  color: #ffd9de;
  font-size: 0.85rem;
  pointer-events: auto;
}
.noscript {
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  margin: 0;
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .wordmark span:last-child {
    filter: none;
  }
}
