/* ==========================================================================
   Adventskalender – Pixel-Weihnachts-Stil
   ========================================================================== */

@font-face {
  font-family: 'Press Start 2P';
  src: url('../fonts/press-start-2p-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'DotGothic16';
  src: url('../fonts/dotgothic16-latin-400-normal.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}

:root {
  --ink: #160f22;
  --night: #0f1534;
  --cream: #fbf3df;
  --cream-2: #efe2c3;
  --red: #d63c3c;
  --red-d: #962525;
  --green: #2a8f55;
  --green-d: #17613a;
  --gold: #f2bf3a;
  --gold-d: #b9851a;
  --snow: #eef3ff;
  --px: 4px;
  --font-px: 'Press Start 2P', ui-monospace, monospace;
  --font: 'DotGothic16', ui-rounded, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 18px;
  color: var(--snow);
  background: var(--night);
  font-synthesis: none;
}
img, canvas, svg { image-rendering: pixelated; }
a { color: var(--gold); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

#scene {
  position: fixed; inset: 0;
  z-index: 0;
  image-rendering: pixelated;
  pointer-events: none;
}

/* --------------------------------------------------------- Pixel-Bausteine */
.px-title {
  font-family: var(--font-px);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 1px;
  margin: 0;
  color: var(--gold);
  text-shadow: 3px 0 0 var(--red-d), 0 3px 0 var(--red-d), 3px 3px 0 var(--red-d), 6px 6px 0 rgba(0, 0, 0, .55);
}
.px-title--big { font-size: clamp(18px, 3.2vw, 40px); }

.px-panel {
  position: relative;
  background: var(--cream);
  color: var(--ink);
  margin: var(--px);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(var(--px) * -1) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink),
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 rgba(120, 80, 30, .18),
    inset var(--px) var(--px) 0 0 rgba(255, 255, 255, .7),
    0 calc(var(--px) * 3) 0 0 rgba(0, 0, 0, .35);
}

.px-btn {
  --b: var(--cream);
  --t: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 600; font-size: 17px; line-height: 1;
  color: var(--t);
  background: var(--b);
  border: 0; border-radius: 0;
  padding: 10px 16px;
  margin: 3px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow:
    0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset -3px -3px 0 0 rgba(0, 0, 0, .22), inset 3px 3px 0 0 rgba(255, 255, 255, .45);
  transition: transform .06s steps(2);
  user-select: none;
}
.px-btn:hover { transform: translateY(-2px); }
.px-btn:active, .px-btn.is-active {
  transform: translateY(1px);
  box-shadow:
    0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink),
    inset 3px 3px 0 0 rgba(0, 0, 0, .25), inset -3px -3px 0 0 rgba(255, 255, 255, .25);
}
.px-btn:focus-visible { outline: 3px dashed var(--gold); outline-offset: 5px; }
.px-btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.px-btn--gold { --b: var(--gold); --t: #3b2405; }
.px-btn--red { --b: var(--red); --t: #fff; }
.px-btn--green { --b: var(--green); --t: #fff; }
.px-btn--dark { --b: #2b2240; --t: var(--snow); }
.px-btn--big { font-size: 22px; padding: 14px 26px; }
.px-btn--small { font-size: 14px; padding: 6px 10px; }
.px-btn--icon { padding: 8px; min-width: 40px; min-height: 40px; }
.px-btn--icon.is-active { --b: var(--gold); --t: #3b2405; }

.px-input, .px-select, .px-textarea {
  font-family: var(--font); font-size: 18px;
  color: var(--ink);
  background: #fff;
  border: 0; border-radius: 0;
  padding: 10px 12px;
  margin: 3px;
  width: calc(100% - 6px);
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 3px 3px 0 0 rgba(0, 0, 0, .12);
}
.px-input:focus, .px-textarea:focus, .px-select:focus { outline: 3px dashed var(--gold-d); outline-offset: 5px; }
.px-textarea { min-height: 120px; resize: vertical; line-height: 1.35; }

.px-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.px-check input {
  appearance: none; width: 22px; height: 22px; margin: 3px; background: #fff; cursor: pointer; flex: none;
  box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink);
}
.px-check input:checked {
  background:
    linear-gradient(var(--green), var(--green)) 5px 5px / 12px 12px no-repeat, #fff;
}
.px-check input[type=radio]:checked { background: linear-gradient(var(--red), var(--red)) 5px 5px / 12px 12px no-repeat, #fff; }
.px-check input:focus-visible { outline: 3px dashed var(--gold-d); outline-offset: 4px; }

.px-range { width: 100%; accent-color: var(--red); }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100;
  transform: translate(-50%, 30px);
  opacity: 0; pointer-events: none;
  font-family: var(--font); font-weight: 600; font-size: 18px;
  background: var(--cream); color: var(--ink);
  padding: 12px 18px;
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink), 0 10px 0 0 rgba(0, 0, 0, .35);
  transition: opacity .2s steps(3), transform .2s steps(3);
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ================================================================= Login */
.page-login { min-height: 100vh; overflow: hidden; }
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(420px, 100%); padding: 30px 30px 26px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.login-box .px-title { font-size: 18px; }
.login-box .px-input { text-align: center; }
.login-sub { margin: 0; font-size: 18px; color: #6b4d3a; }
.login-error { margin: 0; color: var(--red-d); font-weight: 600; }
.login-icon { margin-top: -70px; filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, .4)); animation: bob 1.6s steps(4) infinite alternate; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-8px); } }

/* ============================================================== Kalender */
.page-calendar { min-height: 100vh; overflow-x: hidden; }
.page-calendar.has-admin { --cal-chrome: 300px; }
.page-calendar > *:not(#scene) { position: relative; z-index: 1; }

.admin-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 8px 16px;
  background: repeating-linear-gradient(-45deg, #2b2240 0 14px, #251d38 14px 28px);
  border-bottom: 4px solid var(--gold);
  font-size: 15px;
}
.admin-bar strong { font-family: var(--font-px); font-size: 11px; color: var(--gold); }
.admin-bar__sim { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.admin-bar__sim input { font-family: var(--font); font-size: 15px; padding: 4px 6px; border: 0; }

.cal-head { text-align: center; padding: clamp(14px, 3vh, 34px) 16px 8px; }
.cal-greeting { margin: 10px 0 4px; font-size: clamp(18px, 2vw, 26px); font-weight: 600; color: #fff; text-shadow: 3px 3px 0 rgba(0, 0, 0, .5); }
.cal-status { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; align-items: center; margin-top: 6px; font-size: 17px; color: #dfe6ff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); }
.cal-status .chip { display: inline-flex; align-items: center; gap: 8px; }
.cal-status svg { color: var(--gold); filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .5)); }
.cal-pbar { width: 120px; height: 12px; background: #120c1e; box-shadow: 0 0 0 3px #0b0814; position: relative; }
.cal-pbar span { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--gold) 0 6px, #ffd968 6px 12px); }

.cal-wrap { padding: 12px clamp(10px, 3vw, 40px) 10px; }
.calendar {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-template-areas:
    "d13 d5  d5  d21 d24 d24 d2  d11"
    "d17 d9  d19 d21 d24 d24 d14 d15"
    "d7  d3  d19 d1  d1  d6  d22 d18"
    "d10 d16 d4  d20 d8  d6  d23 d12";
  gap: clamp(10px, 1.3vw, 18px);
  width: min(94vw, calc((100vh - var(--cal-chrome, 250px)) * 2), 1500px);
  min-width: min(94vw, 720px);
  aspect-ratio: 2 / 1;
  margin: 0 auto;
}
@media (max-width: 760px) {
  .calendar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    grid-template-areas:
      "d13 d5  d5  d21"
      "d17 d9  d19 d21"
      "d24 d24 d19 d2"
      "d24 d24 d14 d11"
      "d7  d3  d1  d1"
      "d10 d16 d6  d15"
      "d22 d18 d6  d4"
      "d20 d8  d23 d12";
    width: 94vw; min-width: 0;
    aspect-ratio: 1 / 2;
  }
}

.door {
  position: relative;
  container-type: size;
  perspective: 2600px;
  border: 0; padding: 0; margin: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.door:focus-visible { outline: 4px dashed var(--gold); outline-offset: 6px; }

.door__inside {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .03) 0 4px, transparent 4px 8px),
    #1a1230;
  box-shadow: 0 0 0 4px var(--ink), inset 6px 6px 0 rgba(0, 0, 0, .55);
  overflow: hidden;
}
.door__thumb {
  width: 84%; height: 84%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, .55));
}
.door__inside .door__wait { color: #b9a9e6; opacity: .7; }
.door__progress {
  position: absolute; left: 8%; right: 8%; bottom: 6%;
  height: max(6px, 4cqmin);
  background: #0b0814;
  box-shadow: 0 0 0 2px #0b0814;
}
.door__progress span { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--green) 0 5px, #3fb873 5px 10px); }
.door__badge {
  position: absolute; top: 5%; right: 5%;
  color: var(--gold);
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .7));
  animation: twinkle 1.4s steps(2) infinite;
}
.door__badge svg { width: max(16px, 14cqmin); height: auto; }
@keyframes twinkle { 50% { transform: scale(1.15); } }

.door__flap {
  position: absolute; inset: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  transition: transform .75s steps(8, end);
  z-index: 2;
}
.door__front, .door__back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.door__front {
  background-color: var(--bg);
  background-image: var(--pat, none);
  background-size: var(--pat-size, auto);
  color: var(--fg);
  box-shadow:
    0 0 0 4px var(--ink),
    inset -6px -6px 0 0 rgba(0, 0, 0, .25),
    inset 6px 6px 0 0 rgba(255, 255, 255, .22);
  display: grid; place-items: center;
}
.door__back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .05) 0 4px, transparent 4px 8px),
    #e5d4b0;
  box-shadow: 0 0 0 4px var(--ink), inset -6px 0 0 rgba(0, 0, 0, .18);
}
.door__num {
  font-family: var(--font-px);
  font-size: clamp(12px, 30cqmin, 64px);
  line-height: 1;
  text-shadow: 0.08em 0.08em 0 var(--sh, rgba(0, 0, 0, .45));
  position: relative;
  z-index: 1;
}
.door__icon {
  position: absolute; top: 7%; left: 7%;
  width: 26cqmin; height: 26cqmin;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .35));
}
.door__icon svg { width: 100%; height: 100%; }
.door__lock {
  position: absolute; right: 7%; bottom: 7%;
  opacity: 0; color: var(--fg);
  transition: opacity .15s steps(2);
}
.door__lock svg { width: max(12px, 12cqmin); height: auto; }
.door.is-locked:hover .door__lock { opacity: .75; }
.door.is-locked .door__front { filter: saturate(.7) brightness(.86); }
.door.is-locked:hover .door__front { filter: none; }

.door.is-locked:hover .door__flap { transform: rotateY(-8deg); transition-duration: .2s; }
.door.is-available:hover .door__flap { transform: rotateY(-20deg); transition-duration: .25s; }
.door.is-open .door__flap,
.door.is-opening .door__flap { transform: rotateY(-97deg); }
.door.is-open .door__flap { pointer-events: none; }
.door.is-open { z-index: 2; }
.door.is-open:hover .door__inside { box-shadow: 0 0 0 4px var(--gold), inset 6px 6px 0 rgba(0, 0, 0, .55); }
.door.is-shake { animation: shake .4s steps(6); }
@keyframes shake {
  20% { transform: translateX(-5px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(3px); }
}

.door.is-today .door__front::after {
  content: '';
  position: absolute; inset: -10px;
  box-shadow: 0 0 0 4px var(--gold);
  animation: glow 1s steps(2) infinite;
  pointer-events: none;
}
@keyframes glow { 50% { box-shadow: 0 0 0 4px #fff3a6, 0 0 0 8px rgba(242, 191, 58, .35); } }

.door.is-available .door__front::before {
  content: '';
  position: absolute; width: 6px; height: 6px;
  top: 14%; right: 16%;
  background: #fff;
  box-shadow: 6px 0 0 rgba(255,255,255,.7), -6px 0 0 rgba(255,255,255,.7), 0 6px 0 rgba(255,255,255,.7), 0 -6px 0 rgba(255,255,255,.7);
  animation: sparkle 2.2s steps(1) infinite;
}
@keyframes sparkle { 0%, 60% { opacity: 0; } 61%, 100% { opacity: 1; } }

.cal-foot { text-align: center; padding: 16px 0 26px; font-size: 15px; }
.cal-foot a { color: #cbd4ff; text-shadow: 2px 2px 0 rgba(0, 0, 0, .6); }

.page-calendar.is-leaving .calendar { animation: zoomout .35s steps(4) forwards; }
@keyframes zoomout { to { opacity: 0; transform: scale(1.04); } }

/* ================================================================ Spiel */
.page-game {
  height: 100vh; overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #120d1f;
  user-select: none;
}
.g-top {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  background: #241b38;
  border-bottom: 4px solid var(--ink);
  box-shadow: inset 0 -4px 0 #2f2449;
  z-index: 3;
}
.g-title { font-family: var(--font-px); font-size: 14px; color: var(--gold); text-shadow: 2px 2px 0 var(--red-d); white-space: nowrap; }
.g-progress { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 160px; font-size: 16px; color: #d9d2f0; }
.g-pbar { flex: 1; max-width: 340px; height: 14px; background: #0b0814; box-shadow: 0 0 0 3px #0b0814; position: relative; }
.g-pbar span { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(90deg, var(--green) 0 6px, #3fb873 6px 12px); transition: width .2s steps(4); }
.g-tools { display: flex; align-items: center; gap: 4px; }
.g-tools .sep { width: 10px; }
.g-save { font-size: 14px; color: #8f84b0; min-width: 92px; text-align: right; }
.g-save.is-error { color: #ff8b8b; }

.g-stage { position: relative; overflow: hidden; background:
  linear-gradient(45deg, #1a1429 25%, transparent 25%, transparent 75%, #1a1429 75%) 0 0 / 32px 32px,
  linear-gradient(45deg, #1a1429 25%, transparent 25%, transparent 75%, #1a1429 75%) 16px 16px / 32px 32px,
  #1e1730; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; image-rendering: auto; }
#board.is-pan { cursor: grab; }
#board.is-panning { cursor: grabbing; }
#board.is-paint { cursor: crosshair; }

.minimap {
  position: absolute; right: 16px; bottom: 16px;
  background: #fff;
  box-shadow: 0 0 0 4px var(--ink), 0 8px 0 4px rgba(0, 0, 0, .35);
  cursor: pointer;
  image-rendering: pixelated;
}

.g-palette {
  position: relative;
  background: #241b38;
  border-top: 4px solid var(--ink);
  box-shadow: inset 0 4px 0 #2f2449;
  padding: 14px 14px 18px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 12px;
  max-height: 34vh;
  overflow-y: auto;
  z-index: 3;
}
.swatch {
  --c: #fff; --t: #000;
  position: relative;
  width: 48px; height: 48px;
  border: 0; padding: 0; margin: 3px 3px 8px;
  background: var(--c);
  color: var(--t);
  font-family: var(--font); font-weight: 700; font-size: 17px;
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--ink), inset -4px -4px 0 rgba(0, 0, 0, .22), inset 4px 4px 0 rgba(255, 255, 255, .28);
  transition: transform .08s steps(2);
}
.swatch:hover { transform: translateY(-3px); }
.swatch.is-selected {
  transform: translateY(-7px);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink), 0 7px 0 3px rgba(0, 0, 0, .4), inset -4px -4px 0 rgba(0, 0, 0, .22), inset 4px 4px 0 rgba(255, 255, 255, .28);
}
.swatch__bar { position: absolute; left: 0; right: 0; bottom: -10px; height: 5px; background: #0b0814; }
.swatch__bar span { position: absolute; inset: 0 auto 0 0; background: var(--gold); }
.swatch.is-done { opacity: .55; }
.swatch.is-done .swatch__num { display: none; }
.swatch .swatch__check { display: none; }
.swatch.is-done .swatch__check { display: grid; place-items: center; height: 100%; }
.swatch.is-done.is-selected { opacity: 1; }

.g-hint {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  background: rgba(22, 15, 34, .9); color: #fff;
  font-size: 15px; padding: 8px 14px;
  box-shadow: 0 0 0 3px var(--ink);
  pointer-events: none;
  opacity: 0; transition: opacity .2s steps(3);
}
.g-hint.is-visible { opacity: 1; }

/* Dialoge */
.px-dialog {
  border: 0; padding: 0; background: transparent; color: var(--ink);
  max-width: min(560px, calc(100vw - 30px));
}
.px-dialog::backdrop { background: rgba(10, 6, 20, .6); }
.px-dialog .px-panel { padding: 22px 24px; }
.px-dialog h2 { font-family: var(--font-px); font-size: 15px; margin: 0 0 16px; color: var(--red-d); }
.px-dialog fieldset { border: 0; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.px-dialog legend { font-weight: 700; margin-bottom: 6px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 16px; margin: 0; }
.keys dt { font-weight: 700; white-space: nowrap; }
.keys dd { margin: 0; }
kbd { font-family: var(--font); font-weight: 700; background: var(--cream-2); padding: 1px 6px; box-shadow: 0 2px 0 #bfa978; }

/* Abschluss-Overlay */
.finish {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(10, 6, 20, .78);
  padding: 16px;
}
.finish__fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.finish__panel {
  position: relative;
  width: min(1000px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px 24px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.finish__head { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.finish__head h2 { font-family: var(--font-px); font-size: clamp(14px, 1.8vw, 20px); color: var(--red-d); margin: 0; flex: 1; line-height: 1.4; }
.finish__stage {
  display: grid; place-items: center;
  background: #1a1230;
  padding: 14px;
  box-shadow: 0 0 0 4px var(--ink), inset 4px 4px 0 rgba(0, 0, 0, .5);
  min-height: 200px;
}
.finish__stage canvas { max-width: 100%; height: auto; box-shadow: 4px 4px 0 rgba(0, 0, 0, .5); }
.finish__side { display: grid; gap: 14px; align-content: start; }
.finish__msg h3 { font-family: var(--font-px); font-size: 14px; line-height: 1.5; margin: 0 0 10px; color: var(--green-d); }
.finish__msg p { margin: 0; font-size: 20px; line-height: 1.45; white-space: pre-wrap; }
.finish__msg { animation: appear .5s steps(5); }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } }
.finish__actions { display: flex; flex-wrap: wrap; gap: 4px; }
.finish__actions .px-btn { font-size: 15px; padding: 9px 12px; }
.finish__note { font-size: 14px; color: #7b6650; margin: 0; }
.finish__stagebar { display: flex; justify-content: center; gap: 4px; margin-top: 10px; }
@media (max-width: 820px) { .finish__panel { grid-template-columns: 1fr; } }

.help-card { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 6, 20, .5); z-index: 5; }
.help-card .px-panel { padding: 22px 26px; max-width: 520px; }
.help-card h2 { font-family: var(--font-px); font-size: 14px; margin: 0 0 14px; color: var(--red-d); }

/* ================================================================= Admin */
.page-admin { background: #17112a; min-height: 100vh; color: var(--snow); }
.a-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 20px; background: #241b38; border-bottom: 4px solid var(--ink); }
.a-top h1 { font-family: var(--font-px); font-size: 15px; color: var(--gold); margin: 0; flex: 1; text-shadow: 2px 2px 0 var(--red-d); }
.a-main { padding: 20px; max-width: 1500px; margin: 0 auto; }
.a-flash { margin: 0 0 18px; padding: 12px 16px; }
.a-flash.is-error { background: #ffd9d9; }
.a-section { margin-bottom: 30px; }
.a-section > h2 { font-family: var(--font-px); font-size: 13px; color: #d9d2f0; margin: 0 0 14px; }
.a-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.a-day { padding: 12px; display: grid; gap: 8px; align-content: start; }
.a-day__head { display: flex; justify-content: space-between; align-items: baseline; }
.a-day__num { font-family: var(--font-px); font-size: 14px; color: var(--red-d); }
.a-day__img { aspect-ratio: 1; display: grid; place-items: center; background: #1a1230; box-shadow: inset 3px 3px 0 rgba(0, 0, 0, .5); }
.a-day__img img { width: 90%; height: 90%; object-fit: contain; image-rendering: pixelated; }
.a-day__img .empty { color: #7d6fa8; font-size: 14px; }
.a-day__meta { font-size: 14px; color: #5d4a3a; min-height: 2.6em; }
.a-day__meta b { color: var(--ink); }
.a-day__actions { display: flex; flex-wrap: wrap; gap: 2px; }
.a-day__actions .px-btn, .a-day__actions form .px-btn { font-size: 13px; padding: 6px 8px; }
.a-day__actions form { display: inline; }
.tag { display: inline-block; font-size: 13px; padding: 2px 6px; background: var(--cream-2); }
.tag--ok { background: #c9efd6; }
.tag--done { background: #ffe9a6; }
.a-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; }
.a-form { padding: 18px 20px; display: grid; gap: 10px; align-content: start; }
.a-form h3 { margin: 0 0 4px; font-family: var(--font-px); font-size: 12px; color: var(--red-d); }
.a-form label { font-weight: 600; font-size: 16px; }
.a-form small { color: #6b5845; font-size: 14px; }
.a-info { font-size: 15px; color: #cfc6ea; margin: 0 0 16px; }

/* Editor */
.ed { display: grid; grid-template-columns: minmax(300px, 420px) minmax(380px, 1fr) minmax(300px, 360px); gap: 22px; align-items: start; }
@media (max-width: 1250px) { .ed { grid-template-columns: 1fr 1fr; } .ed-right { grid-column: 1 / -1; } }
@media (max-width: 820px) { .ed { grid-template-columns: 1fr; } }
.ed .px-panel { padding: 16px 18px; }
.ed h3 { margin: 0 0 12px; font-family: var(--font-px); font-size: 12px; color: var(--red-d); }
.ed-drop {
  display: grid; place-items: center; gap: 8px; text-align: center;
  min-height: 140px; padding: 16px;
  background: repeating-linear-gradient(-45deg, #f6ead0 0 10px, #f1e2c2 10px 20px);
  box-shadow: inset 0 0 0 3px #c9b38a;
  cursor: pointer;
  font-size: 16px;
}
.ed-drop.is-over { box-shadow: inset 0 0 0 3px var(--red); }
.ed-crop { display: grid; gap: 10px; }
.ed-crop__frame { position: relative; justify-self: center; background: #1a1230; box-shadow: 0 0 0 3px var(--ink); touch-action: none; cursor: grab; }
.ed-crop__frame:active { cursor: grabbing; }
.ed-crop__frame canvas { display: block; image-rendering: auto; }
.ed-aspects { display: flex; flex-wrap: wrap; gap: 2px; }
.ed-aspects .px-btn { font-size: 13px; padding: 5px 8px; }
.ed-row { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 6px; }
.ed-row output { text-align: right; font-weight: 700; }
.ed-preview { display: grid; place-items: center; min-height: 360px; background: #1a1230; box-shadow: 0 0 0 3px var(--ink), inset 4px 4px 0 rgba(0, 0, 0, .5); padding: 14px; }
.ed-preview canvas { max-width: 100%; box-shadow: 4px 4px 0 rgba(0, 0, 0, .5); image-rendering: pixelated; }
.ed-tabs { display: flex; gap: 2px; margin-bottom: 10px; flex-wrap: wrap; }
.ed-tabs .px-btn { font-size: 13px; padding: 6px 10px; }
.ed-stats { margin: 12px 0 8px; font-size: 16px; }
.ed-stats b { color: var(--red-d); }
.ed-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-chip { width: 34px; height: 34px; display: grid; place-items: center; font-size: 13px; font-weight: 700; box-shadow: 0 0 0 2px var(--ink); position: relative; }
.ed-chip small { position: absolute; bottom: -16px; font-size: 10px; color: #6b5845; font-weight: 400; }
.ed-palette { padding-bottom: 14px; }
.ed-warn { color: var(--red-d); font-size: 14px; margin: 8px 0 0; }
.ed-save { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ed-save .status { font-size: 15px; }
.ed-spinner { font-size: 14px; color: #6b5845; min-height: 1.3em; }
