/* Palette and type follow montel.fi: deep navy/indigo, teal-blue accent,
   violet glow, Montserrat, square corners, short accent bars. */

@font-face {
  font-family: "Montserrat";
  src: url("assets/fonts/montserrat-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #0c103a;
  --panel: rgba(17, 26, 51, 0.88);
  --teal: #0f7ca7;
  --teal-light: #61aecc;
  --violet: #5c15cc;
  --white: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --hairline: rgba(97, 174, 204, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--white);
  font-family: Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
  display: block;
}

#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 16px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

#hud > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#hud > div:nth-child(2) {
  align-items: center;
}

#hud > div:nth-child(3) {
  align-items: flex-end;
}

.label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-light);
}

#energy {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 56px);
  left: 50%;
  width: 96px;
  height: 3px;
  margin-left: -48px;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

#energy-fill {
  height: 100%;
  width: 100%;
  background: var(--teal-light);
}

/* Testing aid: the editor's ◂ Edit. */
#editor-button {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  padding: 9px 16px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-light);
  background: rgba(17, 26, 51, 0.7);
  border: 1px solid var(--teal);
  border-radius: 0;
  cursor: pointer;
}

#editor-button:active {
  background: var(--teal);
  color: var(--white);
}

[hidden] {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 4, 30, 0.55);
}

.card {
  width: min(360px, 100%);
  /* The start screen (rules, picker, leaderboard) is taller than a phone. */
  max-height: 100%;
  overflow-y: auto;
  padding: 34px 28px 30px;
  text-align: center;
  background: var(--panel);
  border: 2px solid var(--violet);
  box-shadow: 0 0 40px rgba(92, 21, 204, 0.35), 0 24px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal-light);
}

.card h1 {
  margin: 0 0 24px;
  font-size: 30px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Short thick teal bar under headings, as on montel.fi. */
.card h1::after,
.card .final::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin: 16px auto 0;
  background: var(--teal);
}

.card .sub {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.card .final {
  margin: 0;
  font-size: 64px;
  font-weight: 300;
  line-height: 1;
}

.card .best {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 22px 0 24px;
  padding: 12px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
  font-weight: 500;
}

.howto {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.howto li {
  counter-increment: step;
  position: relative;
  padding: 4px 0 4px 32px;
}

.howto li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-light);
}

.card button {
  width: 100%;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 16px 20px;
  border: none;
  border-radius: 0;
  background: var(--teal);
  color: var(--white);
  cursor: pointer;
  transition: background 120ms ease;
}

.card button:active {
  background: #0b6185;
}

.card button:disabled {
  background: rgba(15, 124, 167, 0.35);
  color: var(--muted);
  cursor: default;
}

.section-label {
  display: block;
  margin: 22px 0 10px;
  text-align: left;
}

.note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.card .player-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: none;
  background: rgba(12, 16, 58, 0.6);
  border: 1px solid var(--hairline);
  color: var(--muted);
}

.card .player-grid button[aria-pressed="true"] {
  border-color: var(--teal-light);
  background: rgba(15, 124, 167, 0.3);
  color: var(--white);
}

.player-grid img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  border: 1.5px solid var(--teal-light);
}

.player-grid .name {
  font-weight: 400;
}

.board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 13px;
}

.board-list li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 4px;
  border-bottom: 1px solid var(--hairline);
}

.board-list li.own {
  background: rgba(15, 124, 167, 0.25);
  color: var(--white);
}

.board-list .rank {
  font-weight: 600;
  color: var(--teal-light);
}

.board-list .who {
  overflow-wrap: anywhere;
}

.board-list .score {
  font-size: 11px;
  color: var(--muted);
}

.card .best .label {
  white-space: nowrap;
}

.board + button {
  margin-top: 24px;
}
