/* Game layout: HUD on top, calendar left, request queue right + all the juice.
   16-bit skin: wooden HUD plank, parchment paper panels, hard pixel shadows. */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 1080px;
  min-height: 600px;
  /* bottom padding reserves a dock strip for the ❓/🏆 corner pills,
     so they never cover the utility buttons in the side panel */
  padding: 12px 16px 60px;
  gap: 12px;
}
#app.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 2px); }
}

/* ---------- Parchment panels with wood trim ---------- */
#calendar, #side {
  background: linear-gradient(180deg, var(--paper-light), var(--paper) 70%);
  border: 4px solid var(--wood-dark);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 3px var(--outline),
    inset 0 0 0 3px var(--bevel),
    var(--px-shadow);
}

/* HUD is a wooden plank — light text on dark wood */
#hud {
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood) 55%, #76431d 100%);
  border: 4px solid var(--wood-dark);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 3px var(--outline),
    inset 0 3px 0 rgba(255, 233, 179, 0.3),
    inset 0 -4px 0 rgba(46, 21, 5, 0.35),
    var(--px-shadow);
  color: var(--ink-on-wood);
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 20px;
  flex: 0 0 auto;
}
#hud-week { min-width: 150px; }
#week-label {
  font-family: var(--font-pixel);
  font-size: 15px;
  color: var(--gold-light);
  text-shadow: 2px 2px 0 var(--outline);
}
#day-time { font-size: 17px; color: #f4d8a0; font-variant-numeric: tabular-nums; text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.5); }

.hud-title {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: #e8c27c;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
  text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.5);
}

#hud-quota { flex: 1; max-width: 400px; }
#quota-bar {
  position: relative;
  height: 24px;
  background: #4a2a10;
  border: 3px solid var(--outline);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.4);
}
#quota-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, #e08a12 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: width 0.25s;
}
#quota-fill.met {
  background: linear-gradient(180deg, var(--green-bright) 0%, var(--green) 55%, #3d7d18 100%);
}
#quota-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #fff;
  text-shadow: 1px 1px 0 var(--outline), -1px -1px 0 var(--outline), 1px -1px 0 var(--outline), -1px 1px 0 var(--outline);
}

#hud-score { text-align: center; min-width: 130px; }
#score {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: #fff;
  text-shadow: 2px 2px 0 var(--outline);
  font-variant-numeric: tabular-nums;
}
#combo { font-family: var(--font-pixel); font-size: 9px; color: var(--gold-light); min-height: 16px; text-shadow: 1px 1px 0 var(--outline); }

/* pinned right and sized to mirror the queue panel below it */
#hud-energy { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: 0 0 300px; }
#clin-face { width: 46px; height: 46px; flex: 0 0 auto; filter: drop-shadow(2px 3px 0 rgba(46, 21, 5, 0.4)); }
#clin-face .exp { display: none; }
#clin-face.happy .exp-happy { display: block; }
#clin-face.tired .exp-tired { display: block; }
#clin-face.low .exp-low { display: block; }

#meters { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter-label {
  font-family: var(--font-pixel);
  font-size: 7.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e8c27c;
  width: 64px;
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
  text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.5);
}
.meter .bar {
  flex: 1;
  height: 13px;
  background: #4a2a10;
  border: 2px solid var(--outline);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4);
}
#energy-fill {
  height: 100%;
  transition: width 0.3s, background 0.3s;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
#energy-fill.high { background: linear-gradient(180deg, #8ae040, var(--green) 70%); }
#energy-fill.mid  { background: linear-gradient(180deg, var(--gold-light), #e08a12 70%); }
#energy-fill.low  { background: linear-gradient(180deg, #ff7a5c, var(--red) 70%); animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { filter: brightness(1.3); } }
#rep-fill {
  height: 100%;
  background: linear-gradient(180deg, #ffe27a, #d9a514 70%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transition: width 0.3s;
}
#rep-fill.low { background: linear-gradient(180deg, #b39127, #8c6f1e 70%); animation: pulse 0.9s infinite; }

/* ---------- Layout ---------- */
#play-area {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

#calendar {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  min-width: 0;
  overflow: hidden; /* power-ups spawn above the top edge and clip cleanly */
}

/* "Get ready" countdown shown before the sweep starts moving */
#countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: clamp(60px, 10vw, 110px);
  color: var(--gold-light);
  text-shadow:
    4px 4px 0 var(--outline), -4px -4px 0 var(--outline),
    4px -4px 0 var(--outline), -4px 4px 0 var(--outline),
    8px 8px 0 rgba(46, 21, 5, 0.3);
  pointer-events: none;
  z-index: 8;
}
#countdown[hidden] { display: none; }
#countdown.pop { animation: countdown-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes countdown-pop {
  0% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#cal-head { display: flex; flex: 0 0 auto; }
.time-gutter-head { width: 48px; flex: 0 0 auto; }
#day-heads { display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; }
.day-head {
  text-align: center;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  padding: 5px 0 8px;
  border-radius: 6px 6px 0 0;
  transition: color 0.2s, background 0.2s;
}
.day-head.weekend { color: #b8895a; }
.fatigue-tag { font-size: 9px; margin-left: 2px; }

/* Focus slow-mo: the sweep line goes cyan while time is dilated */
#app.slowmo #sweep {
  border-top-color: var(--sky);
  filter: drop-shadow(2px 2px 0 rgba(46, 21, 5, 0.4));
}
#app.slowmo .sweep-dot {
  background: var(--sky);
  border-color: #d6f0ff;
}

.ot-tag {
  font-size: 7px;
  letter-spacing: 0.06em;
  color: #a05e10;
  background: rgba(255, 196, 0, 0.25);
  border: 2px solid #c98c1e;
  border-radius: 4px;
  padding: 0 4px;
  vertical-align: 1px;
}
.day-head.today {
  color: var(--wood-dark);
  background: linear-gradient(180deg, var(--gold) 0%, rgba(255, 196, 0, 0.25) 100%);
  text-shadow: 1px 1px 0 rgba(255, 243, 209, 0.6);
}
.day-head.past { opacity: 0.4; }

#cal-body { display: flex; flex: 1; min-height: 0; }
#time-gutter {
  width: 48px;
  flex: 0 0 auto;
  position: relative;
}
.time-label {
  position: absolute;
  right: 0;
  width: 100%;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: right;
  padding-right: 8px;
  transform: translateY(-50%);
}

#days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  border-radius: 4px;
  overflow: hidden;
  border: 3px solid var(--wood-dark);
  background: var(--paper-light);
  box-shadow: inset 0 0 0 2px rgba(217, 156, 82, 0.5);
}
.day-col {
  position: relative;
  border-right: 2px solid rgba(91, 43, 10, 0.18);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(100% / 11 - 2px),
      rgba(91, 43, 10, 0.14) calc(100% / 11 - 2px),
      rgba(91, 43, 10, 0.14) calc(100% / 11)
    );
  transition: filter 0.4s, opacity 0.4s;
}
.day-col:last-child { border-right: none; }
.day-col.weekend { background-color: rgba(232, 150, 63, 0.12); }
.day-col.past { filter: sepia(0.5) contrast(0.85) brightness(0.78); }
.day-col.today {
  box-shadow: inset 0 0 0 3px rgba(255, 196, 0, 0.65), inset 0 0 0 100vmax rgba(255, 196, 0, 0.06);
}

.blocks { position: absolute; inset: 0; }

/* ---------- Appointment blocks (chunky sprite tiles) ---------- */
.appt {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 13px;
  line-height: 1.15;
  overflow: hidden;
  background: var(--c1);
  border: 2px solid rgba(46, 21, 5, 0.55);
  box-shadow:
    0 3px 0 rgba(46, 21, 5, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.55);
  animation: pop-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
}
@keyframes pop-in {
  0% { transform: scale(0.5, 0.3); opacity: 0; }
  60% { transform: scale(1.08, 1.12); }
  100% { transform: scale(1); opacity: 1; }
}
.appt .appt-line1 { display: block; white-space: nowrap; position: relative; }
.appt .appt-client { display: block; opacity: 0.9; font-size: 12px; white-space: nowrap; position: relative; }
.appt.fired { filter: saturate(0.45) brightness(0.85); }
.appt.fired::after {
  content: "✓";
  position: absolute;
  right: 5px;
  top: 2px;
  font-size: 11px;
  color: #fff;
}
.appt.noshow { filter: grayscale(1) opacity(0.45); }
.appt.noshow::after { content: "👻"; }
.appt.kind-break, .appt.kind-lunch, .appt.kind-marketing, .appt.kind-focus {
  border: 2px dashed rgba(91, 43, 10, 0.5);
  box-shadow: none;
  text-shadow: none;
}

/* ---------- Ghost preview ---------- */
#ghost {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: top 0.07s, height 0.07s;
}
#ghost.valid {
  background: color-mix(in srgb, var(--ghost-color, #52a821) 30%, transparent);
  border: 3px dashed var(--green);
  color: #1d4d0a;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}
#ghost.invalid {
  background: rgba(232, 72, 44, 0.18);
  border: 3px dashed var(--red);
  color: #8e1d0c;
}
#ghost.shake-x { animation: shake-x 0.25s; }
@keyframes shake-x {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -5px; }
  75% { margin-left: 5px; }
}

/* ---------- Sweep line ---------- */
#sweep {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 3px solid var(--red);
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(2px 2px 0 rgba(46, 21, 5, 0.35));
}
.sweep-dot {
  position: absolute;
  left: -5px;
  top: -8px;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: var(--red);
  border: 2px solid #ffd9c2;
  box-shadow: 0 0 0 2px var(--outline);
  animation: dot-pulse 1s infinite;
}
@keyframes dot-pulse {
  50% { transform: scale(1.3) rotate(45deg); }
}

/* ---------- Floating power-ups ---------- */
.powerup {
  position: absolute;
  z-index: 9;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  animation: pu-sway 2.6s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255, 224, 130, 0.95)) drop-shadow(2px 3px 0 rgba(46, 21, 5, 0.45));
  transition: scale 0.15s;
}
.powerup:hover { scale: 1.25; }
.powerup.missed { animation: pu-fade 0.4s forwards; pointer-events: none; }
@keyframes pu-sway {
  0%, 100% { transform: translateX(-50%) rotate(-8deg); }
  50% { transform: translateX(calc(-50% + 12px)) rotate(8deg); }
}
@keyframes pu-fade {
  to { opacity: 0; transform: translateX(-50%) scale(0.4); }
}

/* ⏰ power-up: frozen time turns the sweep icy white */
#app.frozen #sweep {
  border-top-color: #eaf6ff;
  filter: drop-shadow(2px 2px 0 rgba(46, 92, 130, 0.5));
}
#app.frozen .sweep-dot {
  background: #eaf6ff;
  border-color: #6fb6e8;
  animation: none;
}
.floater.freeze {
  color: #2a7ab8;
  font-size: 20px;
  text-shadow: 2px 2px 0 rgba(214, 240, 255, 0.9);
}

/* ---------- Side panel / queue ---------- */
#side {
  width: 312px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  min-height: 0;
}
.panel-title {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-shadow: 1px 1px 0 rgba(255, 243, 209, 0.7);
}

#queue-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* gutter for the selected card's ring + scale-up; the negative margins
     cancel it out visually so cards keep their width */
  padding: 5px 7px;
  margin: -5px -7px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--paper-light);
  border: 3px solid var(--wood);
  border-radius: 6px;
  padding: 7px 9px 7px 17px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(46, 21, 5, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.6);
  animation: card-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex: 0 0 auto;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
/* service-color accent as an inset stripe, so the card border stays uniform */
.card::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  bottom: 9px;
  width: 5px;
  border-radius: 2px;
  border: 1px solid rgba(46, 21, 5, 0.4);
  background: var(--card-color, var(--grape));
}
@keyframes card-in {
  0% { transform: translateX(60px) scale(0.7); opacity: 0; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}
.card.selected {
  border-color: #c9302c;
  box-shadow: 0 0 0 3px var(--gold), 0 3px 0 rgba(46, 21, 5, 0.3);
  transform: scale(1.02);
  background: #fff7dd;
}
.card.converted { box-shadow: 0 0 0 3px var(--gold), 0 3px 0 rgba(46, 21, 5, 0.3); border-color: #c98c1e; }
.card-key {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--ink-on-wood);
  background: var(--wood);
  border: 2px solid var(--wood-dark);
  border-radius: 4px;
  padding: 2px 5px;
  flex: 0 0 auto;
}
.card .avatar { width: 40px; height: 40px; flex: 0 0 auto; }
.card-mid { flex: 1; min-width: 0; }
.card-client { font-size: 17px; color: var(--ink); line-height: 1.05; }
.card-svc { font-size: 14px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-chips { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.chip {
  font-size: 12px;
  line-height: 1.2;
  background: rgba(91, 43, 10, 0.1);
  border: 2px solid rgba(91, 43, 10, 0.35);
  border-radius: 4px;
  padding: 0 6px;
  color: var(--ink-soft);
}
.chip.energy { color: #a05e10; border-color: #c98c1e; background: rgba(255, 196, 0, 0.18); }
.chip.constraint { color: #5f3da8; border-color: rgba(138, 95, 208, 0.55); background: rgba(138, 95, 208, 0.12); }
.chip.vip {
  color: #8a5800;
  border-color: #d9a514;
  background: linear-gradient(180deg, #ffe9a8, #ffd95e);
}
.card-price {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: #2c7a12;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.6);
  flex: 0 0 auto;
}

#tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool {
  background: linear-gradient(180deg, var(--paper), var(--paper-dark));
  border: 3px solid var(--wood);
  border-radius: 6px;
  padding: 9px 4px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(46, 21, 5, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.tool.selected {
  border-color: #2c7a12;
  background: linear-gradient(180deg, #d8f0b8, #b8e088);
  box-shadow: 0 0 0 2px rgba(82, 168, 33, 0.5), 0 3px 0 rgba(46, 21, 5, 0.3);
}

/* ---------- FX layers ---------- */
/* Above the overlays (z 100) so confetti rains over celebration modals. */
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 110;
  image-rendering: pixelated;
}

.floater {
  position: fixed;
  z-index: 95;
  font-family: var(--font-pixel);
  font-size: 14px;
  pointer-events: none;
  animation: float-up 1.1s ease-out forwards;
  transform: translateX(-50%);
}
.floater.money { color: #3f9e14; text-shadow: 2px 2px 0 rgba(255, 243, 209, 0.9); }
.floater.energy { color: #2a7ab8; text-shadow: 2px 2px 0 rgba(255, 243, 209, 0.9); }
.floater.combo { color: #e08a12; font-size: 11px; text-shadow: 2px 2px 0 rgba(255, 243, 209, 0.9); }
.floater.intro { color: #7748c9; font-size: 11px; text-shadow: 2px 2px 0 rgba(255, 243, 209, 0.9); }
@keyframes float-up {
  0% { opacity: 0; margin-top: 6px; scale: 0.6; }
  15% { opacity: 1; scale: 1.15; }
  100% { opacity: 0; margin-top: -52px; scale: 1; }
}

#toasts {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 96;
  pointer-events: none;
}
.toast {
  background: var(--paper-light);
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  font-size: 17px;
  border-radius: 6px;
  padding: 7px 18px;
  animation: toast-in 2.6s ease forwards;
  box-shadow: 0 0 0 2px var(--outline), 0 4px 0 rgba(46, 21, 5, 0.35);
}
.toast.good { border-color: #2c7a12; }
.toast.bad { border-color: #b8261c; }
@keyframes toast-in {
  0% { opacity: 0; transform: translateY(-12px) scale(0.8); }
  8%, 80% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-8px) scale(0.92); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(43, 24, 6, 0.55);
  z-index: 100;
}
.overlay.show { display: grid; }

.panel {
  background: linear-gradient(180deg, var(--paper-light), var(--paper) 75%);
  border: 4px solid var(--wood-dark);
  border-radius: 10px;
  padding: 34px 44px;
  text-align: center;
  box-shadow:
    0 0 0 3px var(--outline),
    inset 0 0 0 3px var(--bevel),
    0 10px 0 rgba(20, 10, 2, 0.4);
  max-width: 580px;
  animation: panel-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes panel-in {
  0% { transform: scale(0.7) translateY(30px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ---------- Title page (full screen) ---------- */
/* Title screen: opaque cover so the game board never bleeds through —
   same pixel-damask office wallpaper as the body behind it */
#title-screen {
  overflow-y: auto;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' shape-rendering='crispEdges'%3E%3Cg fill='%23fff7dd'%3E%3Cg opacity='0.20'%3E%3Crect x='10' y='2' width='4' height='4'/%3E%3Crect x='6' y='6' width='12' height='4'/%3E%3Crect x='2' y='10' width='20' height='4'/%3E%3Crect x='6' y='14' width='12' height='4'/%3E%3Crect x='10' y='18' width='4' height='4'/%3E%3C/g%3E%3Cg opacity='0.20'%3E%3Crect x='34' y='26' width='4' height='4'/%3E%3Crect x='30' y='30' width='12' height='4'/%3E%3Crect x='26' y='34' width='20' height='4'/%3E%3Crect x='30' y='38' width='12' height='4'/%3E%3Crect x='34' y='42' width='4' height='4'/%3E%3C/g%3E%3Cg opacity='0.12'%3E%3Crect x='34' y='10' width='4' height='4'/%3E%3Crect x='10' y='34' width='4' height='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat fixed,
    repeating-linear-gradient(90deg,
      rgba(255, 247, 221, 0.05) 0px, rgba(255, 247, 221, 0.05) 24px,
      rgba(46, 21, 5, 0.04) 24px, rgba(46, 21, 5, 0.04) 48px) fixed,
    linear-gradient(180deg, #a3b08a 0%, #97a57d 55%, #8a9970 100%) fixed;
  background-size: 96px 96px, auto, auto;
}
#title-screen.show { display: flex; }
#title-page {
  margin: auto;
  width: min(960px, 94vw);
  padding: 56px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#game-logo {
  font-family: var(--font-pixel);
  font-size: clamp(28px, 4.4vw, 46px);
  line-height: 1.25;
  color: var(--gold-light);
  letter-spacing: 0.01em;
  word-spacing: -0.5em; /* Press Start 2P's space is a full glyph cell — pull it back to a natural gap */
  text-shadow:
    3px 3px 0 #8a3c0f, -3px -3px 0 #8a3c0f, 3px -3px 0 #8a3c0f, -3px 3px 0 #8a3c0f,
    3px 0 0 #8a3c0f, -3px 0 0 #8a3c0f, 0 3px 0 #8a3c0f, 0 -3px 0 #8a3c0f,
    7px 7px 0 rgba(20, 10, 2, 0.45);
  animation: logo-bob 2.8s ease-in-out infinite;
}
@keyframes logo-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.tagline { color: #fff3d1; font-size: 21px; margin: 14px 0 10px; text-shadow: 2px 2px 0 rgba(46, 21, 5, 0.6); }
#best-score { font-family: var(--font-pixel); color: var(--gold-light); font-size: 10px; min-height: 18px; text-shadow: 2px 2px 0 rgba(46, 21, 5, 0.6); }

#title-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  margin: 26px 0 44px;
}

/* flex + center so the odd card out (7th) sits centered on its row */
#how-to {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  width: 100%;
}
.how-card { flex: 0 1 calc((100% - 28px) / 3); }
@media (max-width: 760px) {
  .how-card { flex-basis: calc((100% - 14px) / 2); }
}
.how-card {
  background: linear-gradient(180deg, var(--paper-light), var(--paper));
  border: 3px solid var(--wood-dark);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  box-shadow: 0 0 0 2px var(--outline), inset 0 0 0 2px var(--bevel), 0 5px 0 rgba(20, 10, 2, 0.35);
  transition: transform 0.15s;
}
.how-card:hover { transform: translateY(-3px); }
.how-icon { font-size: 26px; display: block; margin-bottom: 8px; filter: drop-shadow(2px 2px 0 rgba(46, 21, 5, 0.25)); }
.how-card b { display: block; font-family: var(--font-pixel); color: var(--ink); font-size: 10px; margin-bottom: 7px; letter-spacing: 0.01em; }
.how-card p { margin: 0; color: var(--ink-soft); font-size: 16px; line-height: 1.3; }
.how-card em { color: #b8261c; font-style: normal; }

#key-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: center;
  margin-top: 34px;
  color: #fff3d1;
  font-size: 16px;
  text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.6);
}
#key-hints kbd {
  background: linear-gradient(180deg, var(--paper-light), var(--paper-dark));
  border: 2px solid var(--wood-dark);
  border-bottom-width: 4px;
  border-radius: 4px;
  padding: 1px 7px;
  font-family: inherit;
  color: var(--ink);
  font-size: 14px;
  text-shadow: none;
}

#week-select {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.week-btn {
  background: linear-gradient(180deg, var(--paper-light), var(--paper-dark));
  border: 3px solid var(--wood-dark);
  color: var(--ink);
  font-size: 9px;
  padding: 9px 14px;
  box-shadow: 0 3px 0 var(--outline);
}
.week-btn.selected {
  background: linear-gradient(180deg, var(--gold-light), #f08c1e);
  border-color: #8a3c0f;
  color: var(--wood-dark);
  box-shadow: 0 3px 0 #6e2f0a, inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.week-btn.endless {
  border-color: #6e2f0a;
  color: #a05e10;
}
.week-btn.endless.selected {
  background: linear-gradient(180deg, #ffb74a, #e8482c);
  color: #fff3d1;
  text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.5);
  box-shadow: 0 3px 0 #6e2f0a;
}

#intro-week {
  font-family: var(--font-pixel);
  color: #2a7ab8;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
#intro-title { font-family: var(--font-pixel); font-size: 20px; line-height: 1.4; margin: 10px 0 10px; color: var(--ink); }
#intro-text { color: var(--ink-soft); font-size: 19px; line-height: 1.35; margin-bottom: 16px; }
.quota-callout {
  display: inline-block;
  background: linear-gradient(180deg, #ffe9a8, #ffd95e);
  border: 3px solid #c98c1e;
  border-radius: 6px;
  padding: 8px 22px;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: #8a5800;
  box-shadow: 0 3px 0 rgba(46, 21, 5, 0.3);
  margin-bottom: 24px;
}

.penalty-note[hidden] { display: none; }
.penalty-note {
  background: rgba(232, 72, 44, 0.12);
  border: 3px solid #c9302c;
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 16px;
  color: #8e1d0c;
  margin: -8px 0 22px;
  display: inline-block;
}

#end-title { font-family: var(--font-pixel); font-size: 24px; line-height: 1.35; }
#end-title.good { color: #2c7a12; text-shadow: 2px 2px 0 rgba(111, 206, 46, 0.35); }
#end-title.bad { color: #b8261c; text-shadow: 2px 2px 0 rgba(232, 72, 44, 0.25); }
#end-sub { color: var(--ink-soft); margin: 12px 0 20px; font-size: 19px; }
#end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 30px;
  text-align: left;
  margin-bottom: 26px;
  background: var(--paper-light);
  border: 3px solid var(--wood);
  border-radius: 6px;
  padding: 16px 22px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6);
}
#end-stats div { display: flex; justify-content: space-between; font-size: 17px; }
#end-stats span { color: var(--ink-soft); }
#end-stats b { color: var(--ink); }
.btn-row { display: flex; gap: 12px; justify-content: center; align-items: center; }

/* ---------- Achievements ---------- */
/* SNES-style unlock banner, bottom center */
#ach-popups {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 120;
  cursor: pointer;
}
.ach-pop {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, var(--paper-light), var(--paper));
  border: 3px solid #c98c1e;
  border-radius: 8px;
  padding: 8px 22px 8px 9px;
  box-shadow: 0 0 0 3px var(--outline), 0 5px 0 rgba(20, 10, 2, 0.4);
  /* ~0.25s pop in, hold ≈2s, then fade out */
  animation: ach-pop 2.7s ease forwards;
}
.ach-pop-icon {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: linear-gradient(180deg, #ffe39a, #e09c1a);
  border: 2px solid #8a5800;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55);
  animation: ach-icon-spin 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ach-pop-text { display: flex; flex-direction: column; text-align: left; }
.ach-pop-text b {
  font-family: var(--font-pixel);
  font-size: 7.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a05e10;
}
.ach-pop-text span { font-family: var(--font-pixel); font-size: 11px; color: var(--ink); margin-top: 3px; }
@keyframes ach-pop {
  0% { opacity: 0; transform: translateY(36px) scale(0.7); }
  9%, 83% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(14px) scale(0.9); }
}
@keyframes ach-icon-spin {
  0% { transform: rotate(-200deg) scale(0.2); }
  100% { transform: rotate(0) scale(1); }
}

/* Corner pills, always available bottom-right */
#corner-tabs {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 106;
  display: flex;
  gap: 8px;
}
.corner-tab {
  background: linear-gradient(180deg, var(--wood-light), var(--wood));
  border: 3px solid var(--wood-dark);
  color: var(--gold-light);
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 9px 14px;
  box-shadow: 0 0 0 2px var(--outline), 0 4px 0 rgba(20, 10, 2, 0.4);
  text-shadow: 1px 1px 0 rgba(46, 21, 5, 0.6);
}
.corner-tab:hover { filter: brightness(1.12); }
#help-tab { color: #cdeaff; }
/* Plain glyph instead of the red ❓ emoji — inherits the parchment accent */
.q-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--paper-light);
  border: 2px solid var(--wood-dark);
  color: var(--ink);
  font-size: 11px;
  vertical-align: -4px;
  text-shadow: none;
}
#ach-count { color: var(--ink-on-wood); font-size: 8px; }

/* Bottom drawers: trophy cabinet + help */
.drawer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 103%);
  width: min(940px, 96vw);
  max-height: 64vh;
  display: flex;
  flex-direction: column;
  z-index: 110;
  background: linear-gradient(180deg, var(--paper-light), var(--paper) 60%);
  border: 4px solid var(--wood-dark);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 0 0 3px var(--outline), inset 0 3px 0 var(--bevel);
  transition: transform 0.38s cubic-bezier(0.32, 1.25, 0.5, 1);
}
.drawer.open { transform: translate(-50%, 0); }
.drawer-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 12px;
  border-bottom: 3px solid rgba(91, 43, 10, 0.3);
}
.drawer-head h2 { font-family: var(--font-pixel); font-size: 13px; color: var(--ink); white-space: nowrap; }
.drawer-note { flex: 1; text-align: right; font-size: 15px; color: var(--ink-soft); }
#ach-progress {
  flex: 1;
  height: 14px;
  border-radius: 4px;
  background: #4a2a10;
  border: 2px solid var(--outline);
  overflow: hidden;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4);
}
#ach-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, var(--gold-light), #e08a12 70%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: width 0.4s ease;
}
#ach-progress-text { font-family: var(--font-pixel); font-size: 9px; color: #a05e10; white-space: nowrap; }
.drawer-close {
  background: linear-gradient(180deg, var(--paper), var(--paper-dark));
  border: 2px solid var(--wood-dark);
  color: var(--ink);
  font-size: 12px;
  padding: 6px 12px;
  box-shadow: 0 2px 0 var(--outline);
}
#ach-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 16px 20px 22px;
}
.ach-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--paper-light);
  border: 3px solid #c98c1e;
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6);
}
.ach-item.locked { border-color: rgba(91, 43, 10, 0.3); opacity: 0.55; filter: grayscale(0.9); }
.ach-item .ach-icon { font-size: 26px; line-height: 1.2; filter: drop-shadow(2px 2px 0 rgba(46, 21, 5, 0.25)); }
.ach-body { min-width: 0; }
.ach-name { font-size: 17px; color: var(--ink); }
.ach-desc { font-size: 14px; color: var(--ink-soft); margin-top: 1px; line-height: 1.2; }
.ach-date { font-size: 13px; color: #a05e10; margin-top: 3px; display: inline-block; }

/* Help drawer content */
#help-body {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
  padding: 16px 20px 22px;
}
.help-card {
  background: var(--paper-light);
  border: 3px solid var(--wood);
  border-radius: 6px;
  padding: 12px 14px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6);
}
.help-card h3 { font-family: var(--font-pixel); font-size: 9px; color: var(--ink); margin: 0 0 9px; }
.help-card p { font-size: 15px; color: var(--ink-soft); line-height: 1.3; margin: 0 0 8px; }
.help-card p:last-child { margin-bottom: 0; }
.help-card b { color: var(--ink); }
.help-card em.red { color: #b8261c; font-style: normal; }
.key-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.35;
  margin-bottom: 6px;
}
.key-row:last-child { margin-bottom: 0; }
.key-row .keys { flex: 0 0 118px; text-align: right; }
.drawer kbd {
  background: linear-gradient(180deg, #fffaf0, var(--paper-dark));
  border: 2px solid var(--wood-dark);
  border-bottom-width: 3px;
  border-radius: 4px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}
