/* ============================================================
   Kerstboom Circuit — eigen HTML5 pipe-rotation puzzel
   Stage 800×600, schaalt via transform: scale()
   ============================================================ */

:root {
  --bg-1: #07091f;
  --bg-2: #0c0f2c;
  --bg-3: #131a4a;
  --text: #f1f4ff;
  --text-soft: rgba(220,225,255,0.72);
  --accent: #ffd23a;
  --accent-dk: #b78c00;
  --good: #66ff99;
  --pipe-off: #1a1a26;
  --pipe-glow: #ffd23a;
  --pipe-glow-soft: rgba(255,210,58,0.6);

  --scale: 1;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Rubik', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: 0; outline: 0; }

.app {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 600px at 50% 100%, #d8ebf8 0%, transparent 65%),
    linear-gradient(180deg, #245a98 0%, #5f96c9 55%, #c8e8f7 100%);
  overflow: hidden;
}

/* Stage = puur scaling-container, geen card-frame meer.
   Achtergrond loopt door vanaf .app. Z-index boven sfeer-lagen. */
.stage {
  position: relative;
  width: 800px; height: 600px;
  overflow: hidden;
  transform-origin: center;
  transform: scale(var(--scale));
  background: transparent;
  z-index: 1;
}

/* Sterren-laag — vult het hele viewport (achter de stage) */
.stars {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 8% 12%,  rgba(255,255,255,0.85) 100%, transparent),
    radial-gradient(1px 1px at 22% 28%,     rgba(255,255,255,0.55) 100%, transparent),
    radial-gradient(2px 2px at 40% 8%,      rgba(255,255,255,0.95) 100%, transparent),
    radial-gradient(1px 1px at 58% 22%,     rgba(255,255,255,0.6) 100%, transparent),
    radial-gradient(1.5px 1.5px at 76% 14%, rgba(255,255,255,0.75) 100%, transparent),
    radial-gradient(2px 2px at 92% 20%,     rgba(255,255,255,0.7) 100%, transparent);
  background-size: 600px 400px;
  opacity: 0.30;
}

/* Sneeuw — vult het hele viewport (achter de stage) */
.snow {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.snowflake {
  position: absolute;
  top: -10px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(255,255,255,0.6);
  filter: blur(0.4px);
  animation: snowFall linear infinite;
}
@keyframes snowFall {
  0%   { transform: translate3d(0, -10px, 0); opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.9; }
  100% { transform: translate3d(30px, 110vh, 0); opacity: 0; }
}

/* Topbar — pills stacked links, icons rechts.
   pointer-events:none op de container zodat de lege ruimte tussen pills en
   icons geen clicks vangt boven de bovenste tile-rij van de boom. Alleen de
   echte controls (pills + icon-btn) krijgen weer pointer-events:auto. */
.topbar {
  position: absolute;
  top: 12px; left: 14px; right: 14px;
  display: flex; align-items: flex-start; gap: 10px;
  z-index: 5;
  pointer-events: none;
}
.topbar__left   { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.topbar__center { display: none; }
.topbar__right  { flex: 1; display: flex; justify-content: flex-end; gap: 6px; }
.topbar .pill,
.topbar .icon-btn { pointer-events: auto; }

.brand {
  font-size: 16px; font-weight: 800;
  color: var(--text);
  text-shadow: 0 2px 6px rgba(0,0,0,0.45);
  letter-spacing: -0.2px;
  line-height: 1.05;
  white-space: nowrap;
}
.brand span { display: block; color: var(--accent); }

.pill {
  background: rgba(15, 24, 60, 0.40);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 10px;
  padding: 6px 16px 8px;
  display: flex; flex-direction: column; align-items: center;
  min-width: 110px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.pill__label {
  font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase;
  font-weight: 800; color: rgba(235,242,255,0.82);
  text-shadow: 0 1px 2px rgba(0,0,0,0.32);
}
.pill__value {
  font-size: 22px; font-weight: 900; color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
  margin-top: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.40);
}
.pill--lights .pill__value { color: var(--accent); }
.pill.bump .pill__value { animation: pillBump 0.35s ease-out; display: inline-block; }
@keyframes pillBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.22); color: var(--good); }
  100% { transform: scale(1); }
}

.icon-btn {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: rgba(15, 24, 60, 0.32);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  font-size: 14px;
  display: grid; place-items: center;
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
  transition: filter .15s, transform .08s, background .15s;
}
.icon-btn:hover  { filter: brightness(1.15); }
.icon-btn:active { transform: translateY(1px); }

/* Board area: gecentreerd vlak waar boom + grid in zitten */
.board-wrap {
  position: absolute;
  left: 50%;
  top: 48px;
  transform: translateX(-50%);
  width: 680px;   /* 17 cells × 40px */
  height: 510px;  /* extra ruimte voor grotere boom + ster boven + stam onder */
}
.tree-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.board {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  top: 50px;            /* ruimte boven voor ster + top-laag */
  /* Tiles worden absoluut gepositioneerd binnen dit vlak. */
}

/* Een buis-tegel */
.tile {
  position: absolute;
  width: 40px; height: 40px;
  cursor: pointer;
  transition: transform .12s ease-out;
}
.tile:hover  { transform: scale(1.04); }
.tile:active { transform: scale(0.96); }
.tile.power  { cursor: default; }
.tile.power:hover,
.tile.power:active { transform: none; }
.tile-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 1px 1.5px rgba(0,0,0,0.18));
  transition: filter .18s ease;
}
.tile-svg rect, .tile-svg circle {
  transition: fill .18s ease;
}

/* Stroom op de buis → felgele kabel met soft glow */
.tile.powered .tile-svg rect,
.tile.powered .tile-svg circle {
  fill: #fff200;
}
.tile.powered .tile-svg {
  filter:
    drop-shadow(0 0 4px rgba(255,242,0,0.55))
    drop-shadow(0 0 10px rgba(255,242,0,0.30))
    drop-shadow(0 1px 1.5px rgba(0,0,0,0.20));
}
/* Animatie wanneer een tegel net gedraaid is */
.tile.spin .tile-svg {
  animation: tileSpin 0.22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes tileSpin {
  from { transform: rotate(-90deg); }
  to   { transform: rotate(0deg); }
}

/* Bauble bovenop tegel — duidelijk kerstlichtje.
   Off-state: GEDIMDE versie van de eigen kleur (geen grijs). Elke
   bauble houdt zijn eigen kleur, ook als hij uit staat — alleen
   helderheid, glow en grootte verschillen tussen aan en uit. */
.bauble {
  position: absolute;
  width: 28px; height: 28px;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: radial-gradient(circle at 32% 28%,
              var(--c-lo) 0%, var(--c-base) 80%);
  filter: brightness(0.50) saturate(0.95);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.50),
    0 1px 2px rgba(0,0,0,0.28);
  opacity: 0.92;
  pointer-events: none;
  transition: opacity .25s, box-shadow .25s, background .25s,
              transform .25s, filter .25s;
  z-index: 2;
}
.bauble::after {
  content: '';
  position: absolute;
  top: 5px; left: 8px;
  width: 9px; height: 6px;
  background: rgba(255,255,255,0.85);
  border-radius: 50%;
  filter: blur(1.2px);
  opacity: 0;
  transition: opacity .25s;
}
.bauble.lit {
  background: radial-gradient(circle at 32% 28%,
              #ffffff 0%, var(--c-hi) 22%, var(--c-lo) 62%, var(--c-base) 100%);
  filter: none;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.16),
    0 0 6px var(--c-lo),
    0 0 14px var(--c-glow),
    0 0 24px var(--c-glow);
  animation: baubleLight .35s ease-out;
}
.bauble.lit::after { opacity: 1; }
@keyframes baubleLight {
  0%   { transform: translate(-50%, -50%) scale(0.7); }
  60%  { transform: translate(-50%, -50%) scale(1.25); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* Power-source bliksem op de stam */
.power-icon {
  position: absolute;
  top: 36%; left: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c2 0%, #ffd23a 55%, #c98a00 100%);
  display: grid; place-items: center;
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.25),
    0 0 14px rgba(255,210,58,0.7),
    0 4px 10px rgba(0,0,0,0.35);
  z-index: 2;
  animation: powerPulse 1.8s ease-in-out infinite;
}
.power-icon svg { width: 18px; height: 18px; }
@keyframes powerPulse {
  0%, 100% { box-shadow: inset 0 -2px 4px rgba(0,0,0,0.25),
                          0 0 14px rgba(255,210,58,0.7),
                          0 4px 10px rgba(0,0,0,0.35); }
  50%      { box-shadow: inset 0 -2px 4px rgba(0,0,0,0.25),
                          0 0 22px rgba(255,230,120,0.95),
                          0 4px 10px rgba(0,0,0,0.35); }
}

/* Hint */
.hint {
  position: absolute;
  left: 0; right: 0; bottom: 12px;
  text-align: center;
  font-size: 12px; font-weight: 600;
  color: var(--text-soft);
  margin: 0;
  padding: 0 16px;
  letter-spacing: 0.2px;
  pointer-events: none;
}

/* Overlay */
.overlay {
  position: absolute; inset: 0;
  z-index: 50;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(500px 350px at 50% 50%, rgba(48,40,140,0.30) 0%, transparent 65%),
    rgba(5, 7, 22, 0.86);
}
.overlay--visible { display: flex; }

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(37,45,105,0.96) 0%, rgba(20,26,72,0.98) 100%);
  color: var(--text);
  border-radius: 22px;
  padding: 22px 26px 18px;
  text-align: center;
  max-width: 400px; width: 100%;
  border: 1.5px solid rgba(122,139,255,0.28);
  box-shadow:
    0 24px 70px rgba(0,0,0,0.55),
    0 0 0 1px rgba(122,139,255,0.10),
    inset 0 1px 0 rgba(255,255,255,0.08);
  animation: panelIn .35s ease-out;
}
@keyframes panelIn {
  from { transform: translateY(16px) scale(.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);   opacity: 1; }
}
.panel__title {
  margin: 0 0 4px;
  font-size: 32px; font-weight: 900;
  letter-spacing: -0.8px;
  line-height: 1.05;
  text-shadow:
    0 3px 0 rgba(0,0,0,0.28),
    0 8px 18px rgba(0,0,0,0.35);
}
.panel__title span { color: var(--accent); margin-left: 6px; }
.panel__intro {
  margin: 0 0 12px;
  font-size: 13px; font-weight: 600;
  color: var(--text-soft);
}
.panel__stats {
  display: flex; gap: 12px; justify-content: center;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.stat {
  background: linear-gradient(180deg, rgba(25,31,78,0.96), rgba(17,22,60,0.98));
  border: 1px solid rgba(130,150,255,0.20);
  border-radius: 14px;
  padding: 8px 18px;
  min-width: 96px;
  box-shadow:
    0 8px 20px rgba(0,0,0,0.28),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.stat__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  font-weight: 800;
  color: rgba(205,212,255,0.72);
}
.stat__value {
  font-size: 26px; font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
  margin-top: 2px;
}
.stat--record .stat__value { color: var(--accent); }

.panel__actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 4px;
}

/* Win-paneel: titel-variant + tijd-card + button-layout */
.panel__title--win {
  color: var(--accent);
  text-shadow:
    0 3px 0 rgba(0,0,0,0.28),
    0 8px 18px rgba(255,200,40,0.22);
}

/* Logo bovenop start-paneel — vervangt de tekst-titel */
.panel__logo {
  display: block;
  margin: 0 auto 10px;
  width: 100%;
  max-width: 380px;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.40));
}
/* Start-paneel iets compacter (geen extra titel-tekst meer) */
.panel--start { padding-top: 18px; }
.win-time-block {
  margin: 10px 0 18px;
  padding: 14px 22px 16px;
  border-radius: 16px;
  border: 1.5px solid rgba(255,210,58,0.40);
  background:
    linear-gradient(180deg, rgba(255,230,170,0.14), rgba(255,200,120,0.08));
  text-align: center;
}
.win-time-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 800;
  color: rgba(225,232,255,0.78);
}
.win-time-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.2px;
  margin-top: 6px;
  text-shadow: 0 2px 2px rgba(0,0,0,0.30);
}

.panel__actions--win {
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  width: 100%;
  flex-wrap: nowrap;
  margin-top: 8px;
}
.win-buttons-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
}
.win-buttons-row .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 16px;
}
.panel__actions--win .btn--submit {
  width: 100%;
  padding: 12px 16px;
}

/* Secondary "ghost" variant — donkerblauw glas */
.btn--ghost {
  background: linear-gradient(180deg, rgba(60,72,130,0.95), rgba(38,46,100,0.98));
  color: var(--text);
  border: 2px solid rgba(170,185,255,0.30);
  box-shadow: 0 6px 16px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn--ghost:hover  { transform: translateY(-1px); filter: brightness(1.10); }
.btn--ghost:active { transform: translateY(1px);  filter: brightness(0.96); }

/* Score-insturen knop — blauw/paars accent */
.btn--submit {
  background: linear-gradient(180deg, #6e7eff 0%, #3a4ab9 100%);
  color: #ffffff;
  border: 2px solid rgba(180,190,255,0.32);
  font-weight: 900;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.24), inset 0 1px 0 rgba(255,255,255,0.20);
}
.btn--submit:hover  { transform: translateY(-1px); filter: brightness(1.06); }
.btn--submit:active { transform: translateY(1px);  filter: brightness(0.96); }
.btn {
  background: linear-gradient(180deg, #ffdc55 0%, #ffc72d 52%, #f4a90f 100%);
  color: #1f1705;
  border: 2px solid rgba(255,255,255,0.28);
  border-radius: 16px;
  padding: 11px 22px;
  font-size: 14px; font-weight: 900;
  letter-spacing: 0.4px;
  font-family: inherit;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 8px 20px rgba(0,0,0,0.26),
    inset 0 1px 0 rgba(255,255,255,0.30);
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover  { transform: translateY(-1px); filter: brightness(1.04); }
.btn:active { transform: translateY(1px);  filter: brightness(0.98); }
