/* ===========================================================
   Cable Management // Reonex
   Shares the structural language of the Reonex games set,
   recoloured to the current brand palette.

   Brand:  Lumo Green #00CE58 · Pewter #63666B · Putty #FAFAF5
   =========================================================== */

:root {
  --green: #00CE58;
  --green-soft: rgba(0, 206, 88, 0.22);
  --green-line: rgba(0, 206, 88, 0.28);
  --warn: #FFA629;
  --pewter: #63666B;
  --pewter-dark: #3b3e42;
  --putty: #FAFAF5;
  --ink: #0a0d0f;
  --ink-2: #11161a;
  --ink-3: #161b20;
  --glass: rgba(250, 250, 245, 0.05);
  --glass-border: rgba(0, 206, 88, 0.25);
  --font-display: "Orbitron", "Rajdhani", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* several panels below are flex containers, so the hidden attribute
   needs to beat their display rule */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--putty);
  background: var(--ink);
}

.scene {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 60% 45% at 50% 0%, rgba(0, 206, 88, 0.14), transparent 62%),
    radial-gradient(ellipse 70% 55% at 50% 100%, rgba(99, 102, 107, 0.16), transparent 72%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 55%, var(--ink) 100%);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 206, 88, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 206, 88, 0.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 85%);
  animation: drift 34s linear infinite;
  pointer-events: none;
}

@keyframes drift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 42px 84px, 84px 42px; }
}

.bg-glow {
  position: absolute;
  top: -22%;
  left: 50%;
  width: 900px;
  height: 900px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(0, 206, 88, 0.12), transparent 65%);
  pointer-events: none;
  filter: blur(10px);
}

/* ---------------- Header ---------------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) clamp(12px, 3vw, 48px) 6px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  height: 40px;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 0 18px rgba(0, 206, 88, 0.3);
}

.brand-title { display: flex; flex-direction: column; line-height: 1.1; }

.brand-game {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(15px, 2vw, 24px);
  letter-spacing: 3px;
  text-indent: 3px;
  background: linear-gradient(90deg, var(--putty), var(--green));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tag {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(250, 250, 245, 0.45);
}

.stat-pills { display: flex; gap: 8px; }

.pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 62px;
  padding: 5px 12px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  transition: border-color .2s ease, background .2s ease;
}

.pill-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(250, 250, 245, 0.5);
  white-space: nowrap;
}

.pill-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--green);
  text-shadow: 0 0 12px rgba(0, 206, 88, 0.55);
  font-variant-numeric: tabular-nums;
}

/* crossings outstanding */
.pill.warn { border-color: rgba(255, 166, 41, 0.45); background: rgba(255, 166, 41, 0.08); }
.pill.warn .pill-value { color: var(--warn); text-shadow: 0 0 12px rgba(255, 166, 41, 0.55); }

/* shift clock running out */
.pill.urgent { border-color: rgba(255, 166, 41, 0.6); animation: tick 1s steps(2) infinite; }
.pill.urgent .pill-value { color: var(--warn); }
@keyframes tick { 50% { background: rgba(255, 166, 41, 0.14); } }

/* ---------------- Stage ---------------- */

.stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) minmax(150px, 220px);
  align-items: stretch;
  justify-content: center;
  gap: clamp(14px, 3vw, 48px);
  padding: 4px clamp(10px, 3vw, 48px);
  min-height: 0;
}

.board-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  min-height: 0;
  min-width: 0;
  height: 100%;
  width: 100%;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(250, 250, 245, 0.08);
  backdrop-filter: blur(6px);
  align-self: center;
  max-height: 100%;
  overflow-y: auto;
}

.side-left .leaderboard { min-height: 90px; }

.side-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--green);
}

.side-copy {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(250, 250, 245, 0.6);
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 6px;
  border-radius: 6px;
  color: rgba(250, 250, 245, 0.75);
}

.lb-row:nth-child(odd) { background: rgba(250, 250, 245, 0.03); }

.lb-row.lb-you {
  background: var(--green-soft);
  color: var(--putty);
  box-shadow: inset 0 0 0 1px var(--green-line);
}

.lb-rank { font-family: var(--font-display); font-size: 11px; color: var(--green); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-score { font-family: var(--font-display); font-weight: 700; color: var(--putty); font-variant-numeric: tabular-nums; }
.lb-empty { font-size: 12px; color: rgba(250, 250, 245, 0.45); padding: 4px 2px; }

.sys-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: rgba(250, 250, 245, 0.6);
  border-top: 1px solid rgba(250, 250, 245, 0.08);
  padding-top: 8px;
}
.sys-row:first-of-type { border-top: none; padding-top: 0; }
.sys-row span:last-child { color: var(--putty); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- Board ---------------- */

/* The cabinet fills whatever height is left over. The canvas lays
   itself out from its own box, so no fixed aspect ratio is needed;
   the max-width just stops it going letterbox-wide on desktop. */
.board-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: min(540px, 82vh);
  margin: 0 auto;
  padding: 9px;
}

.board-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--green);
  opacity: 0.75;
  filter: drop-shadow(0 0 6px rgba(0, 206, 88, 0.6));
  transition: opacity .18s ease, filter .18s ease;
}

.board-corner.tl { top: 0; left: 0;  border-right: none; border-bottom: none; }
.board-corner.tr { top: 0; right: 0; border-left: none;  border-bottom: none; }
.board-corner.bl { bottom: 0; left: 0;  border-right: none; border-top: none; }
.board-corner.br { bottom: 0; right: 0; border-left: none;  border-top: none; }

.board-frame.solved .board-corner {
  opacity: 1;
  filter: drop-shadow(0 0 16px rgba(0, 206, 88, 1));
}

.board-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 206, 88, 0.08), transparent 60%), #0c1013;
  border: 1px solid var(--green-line);
  box-shadow:
    0 0 0 1px rgba(99, 102, 107, 0.25),
    0 26px 70px rgba(0, 0, 0, 0.6),
    inset 0 0 60px rgba(0, 206, 88, 0.04);
  overflow: hidden;
  transition: box-shadow .25s ease;
}

.board-inner.flash {
  box-shadow:
    0 0 0 2px rgba(0, 206, 88, 0.9),
    0 0 60px rgba(0, 206, 88, 0.55),
    0 26px 70px rgba(0, 0, 0, 0.6),
    inset 0 0 90px rgba(0, 206, 88, 0.18);
}

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

/* ---------------- HUD strip ---------------- */

.hud-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  letter-spacing: 0.4px;
  color: rgba(250, 250, 245, 0.55);
  flex: 0 0 auto;
}

.hud-item b { color: var(--putty); font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-item i { font-style: normal; color: rgba(250, 250, 245, 0.4); }
.hud-sep { color: var(--green); opacity: .6; }

.hud-btn {
  padding: 5px 12px;
  min-height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 107, 0.5);
  background: rgba(250, 250, 245, 0.04);
  color: rgba(250, 250, 245, 0.75);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.hud-btn:hover, .hud-btn:focus-visible {
  border-color: var(--green);
  color: var(--putty);
  background: rgba(0, 206, 88, 0.1);
  outline: none;
}

.hud-btn[aria-pressed="false"] { color: rgba(250, 250, 245, 0.4); }

/* ---------------- Overlay ---------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 11, 13, 0.88);
  backdrop-filter: blur(6px);
  transition: opacity .2s ease;
  overflow-y: auto;
  padding: 16px 14px;
  scrollbar-width: none;
}

.overlay::-webkit-scrollbar { display: none; }

.overlay.hidden { display: none; }

.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  max-width: 340px;
}

.overlay-kicker {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: rgba(0, 206, 88, 0.8);
}

.overlay-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(21px, 5.4vw, 34px);
  line-height: 1.12;
  letter-spacing: 4px;
  text-indent: 4px;
  background: linear-gradient(90deg, var(--green), var(--putty) 62%, #a7adb3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(0, 206, 88, 0.25);
}

.overlay-msg {
  margin: 0;
  font-size: 14px;
  color: rgba(250, 250, 245, 0.72);
  white-space: pre-line;
  line-height: 1.55;
}

.overlay-score {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 206, 88, 0.07);
  border: 1px solid var(--green-line);
  font-size: 13px;
  color: rgba(250, 250, 245, 0.7);
}

.overlay-score .big {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 30px;
  color: var(--green);
  text-shadow: 0 0 20px rgba(0, 206, 88, 0.5);
  line-height: 1.2;
}

.overlay-score .row { display: flex; justify-content: space-between; gap: 10px; }
.overlay-score .row span:last-child { color: var(--putty); font-weight: 700; }

.overlay-note {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(250, 250, 245, 0.45);
  max-width: 280px;
}

.overlay-btn {
  margin-top: 2px;
  padding: 11px 30px;
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid var(--green);
  background: linear-gradient(90deg, rgba(0, 206, 88, 0.2), rgba(99, 102, 107, 0.18));
  color: var(--putty);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-indent: 3px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 206, 88, 0.22);
  transition: transform .15s ease, box-shadow .15s ease;
}

.overlay-btn:hover, .overlay-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(0, 206, 88, 0.42);
  outline: none;
}

.name-field { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.name-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(250, 250, 245, 0.45);
}

.name-input {
  width: 220px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(250, 250, 245, 0.06);
  color: var(--putty);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  cursor: text;
  user-select: text;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.name-input::placeholder { color: rgba(250, 250, 245, 0.35); font-weight: 500; }
.name-input:focus { border-color: var(--green); box-shadow: 0 0 16px rgba(0, 206, 88, 0.28); }
.name-input.shake { animation: shake .35s ease; border-color: var(--warn); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.overlay-leaderboard {
  width: 100%;
  max-width: 270px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}

/* ---------------- Footer ---------------- */

.footer {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(250, 250, 245, 0.3);
  text-align: center;
}

.footer .dot { color: var(--green); }

/* ---------------- Responsive ---------------- */

@media (max-width: 980px) {
  .side-panel { display: none; }
  .stage { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .brand-tag { display: none; }
  .brand-logo { height: 30px; }
  .brand-game { letter-spacing: 2px; }
  .topbar { padding-left: 10px; padding-right: 10px; gap: 6px; }
  .stat-pills { gap: 5px; }
  .pill { min-width: 0; padding: 4px 7px; }
  .pill-label { font-size: 8.5px; letter-spacing: .6px; }
  .pill-value { font-size: 14px; }
  .footer { letter-spacing: 1px; font-size: 9.5px; }
  .hud-strip { font-size: 12px; gap: 6px; }
}

/* Portrait phones: give the cabinet every pixel of height going */
@media (max-width: 760px) and (orientation: portrait) {
  .board-frame { max-width: 100%; padding: 7px; }
  .stage { padding: 2px 7px; align-items: stretch; }
  .overlay-inner { gap: 8px; }
}

/* Short landscape, e.g. a phone on its side */
@media (max-height: 520px) {
  .footer { display: none; }
  .topbar { padding-top: 6px; padding-bottom: 2px; }
  .overlay-msg { font-size: 12.5px; }
  .overlay-title { font-size: clamp(18px, 4.5vw, 26px); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-grid, .pill.urgent { animation: none; }
  .overlay-btn, .hud-btn { transition: none; }
}
