:root {
  /* Reonex live identity. No navy, and nothing from the retired service
     palette. Lumo Green is the only accent; Pewter is the drained neutral. */
  --lumo: #00CE58;      /* Lumo Green  — the player, charge, everything yours */
  --pewter: #63666B;    /* Pewter      — inert surfaces and the threat */
  --putty: #FAFAF5;     /* Putty       — type and bright highlights */

  /* Neutral darks, matching the sibling Reonex Games builds. Not a navy. */
  --ink: #0a0d0f;
  --ink-2: #11161a;
  --ink-3: #171d22;

  --putty-alt: #FAFAF5;
  --lumo-2: #00CE58;
  --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;
}

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% 50% at 50% 0%, rgba(99, 102, 107, 0.18), transparent 60%),
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(17, 22, 26, 0.9), transparent 70%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 55%, var(--ink) 100%);
  overflow: hidden;
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 206, 88, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 206, 88, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 85%);
  animation: drift 30s 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: -20%;
  left: 50%;
  width: 900px;
  height: 900px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(0, 206, 88, 0.14), 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: 14px clamp(14px, 3vw, 48px) 6px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

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

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

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

.brand-game {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(16px, 2vw, 26px);
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--putty), var(--lumo));
  -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.5);
}

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

.pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 68px;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
}

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

.pill-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--lumo);
  text-shadow: 0 0 12px rgba(0, 206, 88, 0.6);
}

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

.stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr) minmax(140px, 220px);
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 56px);
  padding: 6px clamp(14px, 3vw, 48px);
  min-height: 0;
  /* The board is portrait, so without a cap the side panels drift to the
     far edges of a wide monitor and the layout reads as empty. */
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(250, 250, 245, 0.08);
  backdrop-filter: blur(6px);
}

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

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  max-height: 100%;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 26px 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: rgba(0, 206, 88, 0.12);
  color: var(--putty);
  box-shadow: inset 0 0 0 1px rgba(0, 206, 88, 0.35);
}

.lb-rank {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--lumo);
}

.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);
}

.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: 10px;
}

.sys-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.sys-row span:last-child {
  color: var(--putty);
  font-weight: 600;
  text-align: right;
}

/* ---- Board (portrait) ---- */

.board-frame {
  position: relative;
  width: min(100%, 56vh, 440px);
  aspect-ratio: 560 / 1000;
  max-height: 100%;
  justify-self: center;
  padding: 10px;
}

.board-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid var(--lumo);
  opacity: 0.8;
  filter: drop-shadow(0 0 6px rgba(0, 206, 88, 0.7));
}

.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-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 0%, rgba(99, 102, 107, 0.12), transparent 60%), #0d1114;
  border: 1px solid rgba(0, 206, 88, 0.3);
  box-shadow:
    0 0 0 1px rgba(17, 22, 26, 0.6),
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(0, 206, 88, 0.06);
  overflow: hidden;
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(10, 13, 15, 0.82);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.overlay.hidden {
  display: none;
}

.overlay.demo-active {
  background: rgba(10, 13, 15, 0.45);
}

.demo-badge {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  margin-bottom: 6px;
  border-radius: 999px;
  border: 1px solid rgba(99, 102, 107, 0.4);
  background: rgba(99, 102, 107, 0.1);
  color: var(--putty-alt);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(99, 102, 107, 0.6);
}

.overlay.demo-active .demo-badge {
  display: inline-flex;
}

.demo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--putty-alt);
  box-shadow: 0 0 8px rgba(99, 102, 107, 0.9);
  animation: demo-pulse 1.2s ease-in-out infinite;
}

@keyframes demo-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.overlay-logo {
  height: 36px;
  width: 36px;
  margin-bottom: 6px;
  border-radius: 8px;
  opacity: 0.95;
}

.overlay-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(22px, 4.4vw, 38px);
  letter-spacing: 5px;
  background: linear-gradient(90deg, var(--lumo), var(--putty), var(--pewter));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(0, 206, 88, 0.35);
}

.overlay-msg {
  font-size: 14px;
  color: rgba(250, 250, 245, 0.75);
  white-space: pre-line;
  max-width: 300px;
  line-height: 1.55;
}

.overlay-btn {
  margin-top: 4px;
  padding: 10px 28px;
  border-radius: 999px;
  border: 1px solid var(--lumo);
  background: linear-gradient(90deg, rgba(0, 206, 88, 0.15), rgba(99, 102, 107, 0.15));
  color: var(--putty);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 206, 88, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.overlay-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(0, 206, 88, 0.45);
}

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

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

.name-input {
  width: 210px;
  padding: 9px 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: 15px;
  font-weight: 600;
  text-align: center;
  cursor: text;
  user-select: text;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.name-input::placeholder {
  color: rgba(250, 250, 245, 0.35);
  font-weight: 500;
}

.name-input:focus {
  border-color: var(--lumo);
  box-shadow: 0 0 16px rgba(0, 206, 88, 0.3);
}

.name-input.shake {
  animation: shake 0.35s ease;
  border-color: var(--putty-alt);
}

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

.overlay-leaderboard {
  width: 100%;
  max-width: 250px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  max-height: 128px;
  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;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(250, 250, 245, 0.35);
}

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

/* The horizontal lockup only goes where there is real width. At 40px the
   header takes the square tile instead, or the wordmarks turn to mush. */
.footer-lockup {
  height: 17px;
  width: auto;
  opacity: 0.75;
}

.footer-link {
  color: rgba(250, 250, 245, 0.55);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 206, 88, 0.35);
  transition: color 0.15s ease;
}

.footer-link:hover {
  color: var(--lumo);
}

/* Quiet route back to the original game. Lives in the overlay so it is
   reachable on a phone, where the footer is hidden. */
.alt-game-link {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(250, 250, 245, 0.5);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(250, 250, 245, 0.14);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.alt-game-link:hover {
  color: var(--lumo);
  border-color: var(--glass-border);
}

/* ---- Touch controls ---- */

.touch-ctl {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 5;
  gap: 10px;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
}

.flip-pad, .drop-btn {
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--lumo);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 2px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.flip-pad {
  flex: 1 1 0;
  max-width: 150px;
  height: 58px;
}

.drop-btn {
  flex: 0 0 auto;
  width: 92px;
  height: 58px;
  border-color: var(--lumo-2);
  color: var(--lumo-2);
  background: rgba(0, 206, 88, 0.08);
}

.flip-pad:active {
  background: rgba(0, 206, 88, 0.22);
  transform: translateY(1px);
}

.drop-btn:active {
  background: rgba(0, 206, 88, 0.25);
  transform: translateY(1px);
}

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

@media (max-width: 1040px) {
  .side-panel { display: none; }
  .stage { grid-template-columns: 1fr; }
  .board-frame { width: min(94vw, 52vh, 420px); }
}

/* Touch pads appear for coarse pointers and for any narrow viewport, so a
   phone can never end up with no visible controls if pointer media lies. */
@media (pointer: coarse), (max-width: 760px) {
  .touch-ctl { display: flex; }
  .stage { padding-bottom: 76px; }
  .board-frame { width: min(94vw, 48vh, 400px); }
  .footer { display: none; }
}

@media (max-width: 480px) {
  .brand-tag { display: none; }
  .stat-pills { gap: 6px; }
  .pill { min-width: 44px; padding: 4px 8px; }
  .pill-label { font-size: 9px; letter-spacing: 1px; }
  .pill-value { font-size: 15px; }
  .brand-logo { height: 30px; }
  .brand-game { letter-spacing: 2px; }
  .topbar { padding: 10px 12px 4px; }
}

@media (max-height: 740px) and (pointer: coarse), (max-height: 740px) and (max-width: 760px) {
  .board-frame { width: min(90vw, 46vh, 360px); }
}
