/* Theme — mirrors Pictok/Views/Theme.swift */
:root {
  --pk-paper:  #FEF3D9;
  --pk-ink:    #1A1A1A;
  --pk-yellow: #FFD60A;
  --pk-red:    #E63946;
  --pk-green:  #06D6A0;
  --pk-blue:   #118AB2;

  --font-rounded: system-ui, -apple-system, "SF Pro Rounded", "Segoe UI", sans-serif;
  --font-mono:    ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #ECDDB3;
  background-image:
    radial-gradient(circle at 20% 25%, rgba(255,214,10,0.10) 0, transparent 35%),
    radial-gradient(circle at 80% 75%, rgba(6,214,160,0.08) 0, transparent 35%),
    radial-gradient(circle at 50% 95%, rgba(17,138,178,0.06) 0, transparent 40%);
  color: var(--pk-ink);
  font-family: var(--font-rounded);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Outer "desk" — three-column layout (left rail, game, right rail).
   Rails collapse away on viewports < 1100px so the column-only experience is preserved. */
.desk {
  max-width: 1180px;
  margin: 28px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 24px;
}
@media (min-width: 1100px) {
  .desk {
    grid-template-columns: 260px 520px 280px;
    justify-items: stretch;
    align-items: start;
  }
}

#app {
  width: 100%;
  max-width: 520px;
  padding: 22px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--pk-paper);
  border: 3px solid var(--pk-ink);
  border-radius: 22px;
  box-shadow: 8px 8px 0 0 var(--pk-ink);
  position: relative;
}

/* Side rails — hidden by default, shown alongside the game on wide screens. */
.rail {
  display: none;
  background: var(--pk-paper);
  border: 3px solid var(--pk-ink);
  border-radius: 22px;
  box-shadow: 6px 6px 0 0 var(--pk-ink);
  padding: 22px 18px;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 1100px) {
  .rail { display: flex; }
}
.rail-title {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-bottom: 4px;
}
.rail-footer {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.45;
  margin-top: auto;
  letter-spacing: 0.02em;
}

/* Left rail — How to Pictok */
.rail-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rail-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.rail-step-num {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--pk-ink);
  color: var(--pk-paper);
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rail-step-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-step-emoji { font-size: 20px; line-height: 1; }
.rail-step-text { font-size: 13px; line-height: 1.4; font-weight: 700; }

/* Right rail — Today */
.rail-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.55);
  border: 2px dashed rgba(0,0,0,0.18);
  border-radius: 12px;
}
.rail-block-eyebrow {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}
.rail-block-value {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.rail-block-sub {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.6;
}
.rail-yesterday-emoji { font-size: 32px; line-height: 1.2; margin-top: 2px; }
.rail-yesterday-blanks {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.5;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

/* Mobile: full-bleed game, no surround/border. */
@media (max-width: 600px) {
  body { background: var(--pk-paper); background-image: none; }
  .desk { padding: 0; margin: 0; max-width: 100%; }
  #app {
    max-width: 100%;
    padding: 16px;
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-height: 100dvh;
  }
}

#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#top-bar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

#top-bar nav {
  display: flex;
  gap: 8px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--pk-ink);
  opacity: 0.5;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 10px;
}
.tab[aria-current="page"] { opacity: 1; background: rgba(0,0,0,0.06); }

.screen { display: flex; flex-direction: column; gap: 16px; }
.screen[hidden] { display: none; }

/* Sticker — mirrors StickerModifier (hard offset shadow, no blur) */
.sticker {
  background: #fff;
  border: 3px solid var(--pk-ink);
  border-radius: 14px;
  box-shadow: 4px 4px 0 0 var(--pk-ink);
  padding: 12px 16px;
}
.sticker--soft { border-width: 2px; box-shadow: 2px 2px 0 0 var(--pk-ink); border-radius: 12px; }

/* Sticker button — interactive variant */
.btn-sticker {
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: var(--pk-ink);
  background: #fff;
  border: 3px solid var(--pk-ink);
  border-radius: 14px;
  box-shadow: 4px 4px 0 0 var(--pk-ink);
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 60ms ease, box-shadow 60ms ease;
}
.btn-sticker:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--pk-ink);
}
.btn-sticker[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-sticker--yellow { background: var(--pk-yellow); }
.btn-sticker--green  { background: var(--pk-green); color: var(--pk-ink); }
.btn-sticker--red    { background: var(--pk-red); color: #fff; }
.btn-sticker--blue   { background: var(--pk-blue); color: #fff; }

/* Emoji header */
.emoji-header {
  font-size: 72px;
  text-align: center;
  line-height: 1;
  padding: 8px 0;
}

/* Hearts */
.hearts-row { display: flex; gap: 4px; justify-content: center; }
.heart { font-size: 22px; }
.heart--lost { opacity: 0.2; filter: grayscale(1); }

/* Category chip */
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  align-self: center;
  padding: 6px 12px;
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
}

/* Blanks (the word(s) being guessed) */
.blanks {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  font-family: var(--font-mono);
}
.blank-word { display: flex; gap: 6px; }
.blank-letter {
  width: 22px;
  height: 28px;
  border-bottom: 3px solid var(--pk-ink);
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 28px;
}
.blank-letter--revealed { color: var(--pk-ink); }
.blank-letter--empty    { color: transparent; }

/* Keyboard */
.keyboard { display: flex; flex-direction: column; gap: 6px; }
.keyboard-row { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1;
  max-width: 36px;
  height: 46px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  background: #fff;
  border: 2px solid var(--pk-ink);
  border-radius: 6px;
  cursor: pointer;
  color: var(--pk-ink);
}
.key--correct { background: var(--pk-green); color: var(--pk-ink); }
.key--wrong   { background: var(--pk-red);   color: #fff; opacity: 0.6; }
.key[disabled] { cursor: not-allowed; }

/* Modal */
#modal-root .modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--pk-paper);
  border: 3px solid var(--pk-ink);
  border-radius: 18px;
  padding: 24px;
  width: min(420px, 92vw);
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 6px 6px 0 0 var(--pk-ink);
}

/* Toast */
#toast-root .toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--pk-ink);
  color: var(--pk-paper);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  z-index: 60;
  animation: toast-in 200ms ease-out;
}
@keyframes toast-in {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0);     opacity: 1; }
}

/* Celebration canvas */
canvas.celebration {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 40;
}

/* Action row (Hint and similar) */
.action-row { display: flex; justify-content: flex-end; gap: 8px; }

.btn-sticker--sm { font-size: 14px; padding: 8px 12px; border-width: 2px; box-shadow: 2px 2px 0 0 var(--pk-ink); }
.btn-sticker--sm:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 0 var(--pk-ink); }

.btn-block { width: 100%; padding: 14px; font-size: 16px; }

/* Continue Playing CTA — subtle, sits below the keyboard */
.continue-row { display: flex; justify-content: center; margin-top: 4px; }
.btn-sticker--continue {
  background: var(--pk-paper);
  border-width: 2px;
  box-shadow: 3px 3px 0 0 var(--pk-ink);
  font-size: 14px;
  padding: 10px 18px;
  color: var(--pk-ink);
  opacity: 0.85;
}
.btn-sticker--continue:hover { opacity: 1; }

/* Endless top bar */
.endless-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.endless-counter {
  font-size: 13px;
  opacity: 0.6;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Next puzzle overlay */
.next-overlay {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  padding: 48px 16px;
}
.next-overlay-text { opacity: 0.7; margin: 0; }

/* Result modal — editorial style */
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.55;
  text-align: center;
}
.modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
}
.modal-body-text {
  margin: 0;
  font-size: 15px;
  opacity: 0.75;
  text-align: center;
  line-height: 1.45;
}
.result-modal { gap: 10px; }
.result-modal .category-chip { align-self: center; }
.result-answer {
  margin: 0 0 4px;
  font-size: 38px;
  font-weight: 900;
  text-align: center;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.result-divider {
  height: 1px;
  background: rgba(0,0,0,0.1);
  margin: 8px 0 4px;
}
.result-status {
  margin: 0;
  font-size: 15px;
  opacity: 0.8;
  text-align: center;
}
.result-streak {
  margin: 0;
  font-size: 14px;
  opacity: 0.55;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}
.share-preview {
  margin: 8px 0 4px;
  padding: 14px;
  background: rgba(255,255,255,0.55);
  border: 2px dashed rgba(0,0,0,0.18);
  border-radius: 12px;
}
.share-preview-line { margin: 0; text-align: center; }
.share-preview-bold { font-size: 17px; }
.modal-close-link {
  background: transparent;
  border: none;
  color: var(--pk-ink);
  opacity: 0.45;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  margin-top: 4px;
  cursor: pointer;
  align-self: center;
}
.modal-close-link:hover { opacity: 0.75; }

/* Stats screen */
.stats-screen { display: flex; flex-direction: column; gap: 14px; }
.stats-pair {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  gap: 0;
  padding: 18px;
}
.stats-pair-divider {
  width: 1px;
  background: rgba(0,0,0,0.1);
  height: 48px;
  justify-self: center;
}
.stats-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stats-value { font-size: 32px; font-weight: 900; }
.stats-label {
  font-size: 12px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
}

/* Calendar heatmap */
.calendar-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.calendar-eyebrow { text-align: center; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-day-label {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.45;
  text-align: center;
  letter-spacing: 0.06em;
}
.calendar-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid var(--pk-ink);
  background: rgba(0,0,0,0.05);
  position: relative;
}
.calendar-cell--perfect { background: var(--pk-green); }
.calendar-cell--solved  { background: var(--pk-yellow); }
.calendar-cell--failed  { background: var(--pk-red); }
.calendar-cell--empty   { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.18); }
.calendar-cell--future  { background: transparent; border-style: dashed; border-color: rgba(0,0,0,0.18); }
.calendar-cell--today {
  outline: 3px solid var(--pk-ink);
  outline-offset: 2px;
}
.calendar-cell--legend {
  width: 14px;
  height: 14px;
  aspect-ratio: auto;
  border-width: 2px;
}
.calendar-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.75;
}
.legend-item { display: flex; align-items: center; gap: 10px; }
