/* Scaffold Scramble: Rock N Split look. Night navy / quarry water, amber
   lantern glow, Georgia serif, outlined amber buttons. */
:root {
  --bg: #050505;
  --water: #050607;
  --amber: #f3c779;
  --amber-hi: #ffcf7a;
  --amber-soft: #ffd38a;
  --amber-line: #c98a35;
  --ember: #ff9a2a;
  --btn: #2a1a08;
  --lamp: #fff3c0;
  --glow-line: rgba(255, 200, 120, 0.32);
  --glow-fill: rgba(255, 200, 120, 0.06);
  --font: Georgia, "Times New Roman", serif;
  --app-h: 100dvh;
  --hud: 52px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--amber);
  font-family: var(--font);
  overflow: hidden;
  touch-action: none;
}
button, [role="button"] { cursor: pointer; font-family: inherit; }
button:disabled { cursor: default; opacity: 0.6; }
button:focus-visible { outline: 2px solid var(--amber-hi); outline-offset: 2px; }

.yard-host,
.yard-page {
  height: var(--app-h);
  min-height: 0;
}
.yard-host { position: relative; }
.yard-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 440px) minmax(0, 1fr);
  background: radial-gradient(ellipse at 50% 40%, #1a1006 0%, transparent 60%), var(--bg);
  overflow: hidden;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* desktop side panels */
.side { padding: 32px 28px; overflow: auto; min-width: 0; }
.side h2 {
  font-weight: normal;
  letter-spacing: 1px;
  line-height: 1.1;
  margin: 22px 0 12px;
  font-size: 22px;
  color: var(--amber-hi);
  text-shadow: 0 0 14px var(--ember);
}
.side-left h2 { font-size: 34px; margin-top: 0; }
.side p, .help, .floors {
  color: var(--amber);
  opacity: 0.85;
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 12px;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-line);
}
.price { font-size: 14px; opacity: 0.7; }
.floors, .help { padding-left: 18px; }
.floors li { margin: 4px 0; }
.floors li.now { color: var(--amber-hi); text-shadow: 0 0 10px var(--ember); }
.best-line { color: var(--amber-soft); }

/* the game column */
.cabinet {
  height: var(--app-h);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--water);
  border-left: 1px solid rgba(201, 138, 53, 0.18);
  border-right: 1px solid rgba(201, 138, 53, 0.18);
  position: relative;
  overflow: hidden;
}
.hud {
  height: calc(var(--hud) + var(--sat));
  padding: var(--sat) max(10px, var(--sar)) 0 max(12px, var(--sal));
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(#0a0806, #050505);
  border-bottom: 1px solid rgba(201, 138, 53, 0.22);
  flex: 0 0 auto;
}
.stat { display: flex; flex-direction: column; min-width: 40px; }
.stat span, .power {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-line);
}
.stat strong {
  font-weight: normal;
  font-size: 20px;
  line-height: 1.05;
  color: var(--amber-soft);
  text-shadow: 0 0 10px rgba(255, 154, 42, 0.55);
}
.lives { display: flex; gap: 6px; margin-left: auto; min-width: 40px; align-items: center; }
/* lives are little lanterns, like Rock N Split */
.life {
  display: block;
  width: 9px;
  height: 13px;
  border-radius: 3px;
  background: var(--lamp);
  border-top: 2px solid #3a2612;
  border-bottom: 2px solid #3a2612;
  box-shadow: 0 0 8px var(--ember), 0 0 2px var(--amber-hi);
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--amber-line);
  background: var(--btn);
  color: var(--amber-soft);
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 18px;
  flex: 0 0 auto;
}
.icon-btn svg { width: 20px; height: 20px; }
.power {
  position: absolute;
  top: calc(var(--hud) + var(--sat) + 6px);
  left: max(12px, var(--sal));
  z-index: 2;
  margin: 0;
  pointer-events: none;
  color: var(--amber-hi);
  text-shadow: 0 0 8px var(--ember);
}
.power[hidden] { display: none; }
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--water);
  touch-action: none;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* menus: the Rock N Split title screen */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(5, 5, 5, 0.72);
  overflow: auto;
  z-index: 3;
}
.overlay[hidden] { display: none; }
.menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  max-width: min(100%, 460px);
}
.menu p { margin: 0; }
.menu .title {
  font-size: clamp(22px, 7vw, 32px);
  letter-spacing: 2px;
  line-height: 1.15;
  color: var(--amber-hi);
  text-shadow: 0 0 18px var(--ember);
  margin-bottom: 2px;
}
.menu .lede { font-size: 16px; color: var(--amber); }
.menu button {
  font: inherit;
  font-size: 18px;
  background: var(--btn);
  color: var(--amber-soft);
  border: 1px solid var(--amber-line);
  border-radius: 8px;
  padding: 10px 22px;
  min-width: 200px;
  min-height: 44px;
}
.menu button.small { font-size: 15px; min-height: 40px; padding: 7px 18px; opacity: 0.9; }
.menu button:active { background: #3a2410; box-shadow: 0 0 16px rgba(255, 170, 70, 0.5); }
.scores {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.4;
}
.hint { font-size: 12px; opacity: 0.6; max-width: 320px; }
.score-xl {
  font-size: 48px;
  line-height: 1;
  color: var(--amber-hi);
  text-shadow: 0 0 18px var(--ember);
}

/* touch controls: glowing amber outlines, same recipe as Rock N Split's Arrows */
.pad {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px max(8px, var(--sar)) max(8px, var(--sab)) max(8px, var(--sal));
  background: var(--bg);
  touch-action: none;
}
.dpad {
  flex: 4 1 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.pad button {
  min-height: 58px;
  min-width: 0;
  border-radius: 14px;
  border: 2px solid var(--glow-line);
  background: var(--glow-fill);
  color: rgba(255, 211, 138, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  touch-action: none;
}
.pad button svg { width: 26px; height: 26px; }
.pad .jump { flex: 1.1 1 0; color: var(--amber-soft); border-color: rgba(255, 200, 120, 0.55); }
.pad button[data-on="true"] {
  background: rgba(255, 200, 120, 0.32);
  border-color: rgba(255, 200, 120, 0.85);
  color: var(--lamp);
  box-shadow: 0 0 18px rgba(255, 170, 70, 0.8);
}
/* left-handed: mirror the pad (Jump left, arrows/joystick right) */
.hand-left .pad { flex-direction: row-reverse; }
.pad .swap {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  min-height: 38px;
  align-self: center;
  border-radius: 50%;
  border-width: 1.5px;
  padding: 0;
  font-size: 0;
  color: rgba(255, 211, 138, 0.55);
  background: rgba(255, 200, 120, 0.05);
}
.pad .swap span { display: none; }
.pad .swap svg { width: 20px; height: 20px; }
.joy {
  display: none;
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 2px solid var(--glow-line);
  background: var(--glow-fill);
  touch-action: none;
  flex: 0 0 auto;
}
.joy .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: rgba(255, 211, 138, 0.3);
  pointer-events: none;
}
.joy.on { border-color: rgba(255, 200, 120, 0.55); background: rgba(255, 200, 120, 0.1); }
.joy.on .knob { background: rgba(255, 211, 138, 0.55); box-shadow: 0 0 14px rgba(255, 170, 70, 0.6); }

.ctrl-joy .dpad { display: none; }
.ctrl-joy .joy { display: block; }
.ctrl-joy .pad { justify-content: space-between; padding-left: max(18px, var(--sal)); padding-right: max(18px, var(--sar)); }
.ctrl-joy .pad .jump { flex: 0 0 auto; width: 80px; height: 80px; border-radius: 50%; }

/* phone landscape: controls float over the empty sides of the stage */
@media (orientation: landscape) and (max-height: 600px) {
  :root { --hud: 44px; }
  .pad {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: none;
    pointer-events: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 max(16px, var(--sar)) max(14px, var(--sab)) max(16px, var(--sal));
    z-index: 2;
  }
  .pad > * { pointer-events: auto; }
  .dpad {
    flex: 0 0 auto;
    grid-template-columns: repeat(3, 58px);
    grid-template-rows: repeat(3, 52px);
    gap: 4px;
  }
  .dpad .b-up { grid-area: 1 / 2; }
  .dpad .b-left { grid-area: 2 / 1; }
  .dpad .b-right { grid-area: 2 / 3; }
  .dpad .b-down { grid-area: 3 / 2; }
  .pad button { min-height: 52px; }
  .pad .jump { flex: 0 0 auto; width: 78px; height: 78px; border-radius: 50%; }
  .pad .swap { align-self: flex-end; margin-bottom: 4px; }
  .menu-open .pad { display: none; }
  .menu { gap: 7px; }
  .menu button { min-height: 40px; padding: 7px 22px; }
  .menu .lede { font-size: 14px; }
}

/* mouse and keyboard only (no touch screen): no on-screen pad */
@media not all and (any-pointer: coarse) {
  .pad { display: none; }
}

@media (max-width: 1200px) {
  .yard-page { grid-template-columns: 1fr; }
  .side { display: none; }
  .cabinet { border: 0; }
}

/* joystick mode: the swap button sits exactly mid-screen between the two controls */
.ctrl-joy .pad { position: relative; }
.ctrl-joy .pad .swap { position: absolute; left: calc(50% - 19px); }
@media (orientation: landscape) and (max-height: 600px) {
  .ctrl-joy .pad { position: absolute; }
  /* phone landscape: the middle is the game, so the swap button sits just above Jump */
  .yard-page .pad .swap {
    position: absolute;
    left: auto;
    right: calc(max(16px, var(--sar)) + 20px);
    bottom: calc(max(14px, var(--sab)) + 94px);
    margin: 0;
  }
  .yard-page.hand-left .pad .swap { right: auto; left: calc(max(16px, var(--sal)) + 20px); }
}
