:root {
  /* Mootsmog cream-teal - matches hub / Linewire / One Stroke */
  --bg: #FDF0D5;
  --bg-deep: #F5E4C4;
  --panel: #ffffff;
  --panel-2: #F7EBD0;
  --text: #2C2416;
  --muted: #7A6A52;
  --accent: #249D8F;
  --accent-2: #1A7A6F;
  --gold: #E9C46A;
  --coral: #E76F51;
  --border: rgba(36, 157, 143, 0.35);
  --border-strong: rgba(26, 122, 111, 0.42);
  --ok: #249D8F;
  --danger: #E76F51;
  --warn: #c4882a;
  --grid-line: #c5dde3;
  --cell: #eef6f7;
  --board-bg: #FFF8EB;
  --path: #249D8F;
  --player: #1A7A6F;
  --start: #249D8F;
  --finish: #d4893a;
  --radius: 16px;
  --shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 10px 30px rgba(36, 157, 143, 0.12),
    0 2px 8px rgba(44, 36, 22, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-deep);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  min-height: 100dvh;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  line-height: 1.4;
  background-color: var(--bg-deep);
  /* Page paper from /shared/notebook-bg.css */
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 12px 28px;
}

header.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.nav-home {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.nav-home:hover {
  color: var(--accent-2);
}

header.hero h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  font-weight: 750;
  background: linear-gradient(120deg, #1A7A6F 0%, #249D8F 45%, #E9C46A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header.hero .sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(255, 255, 255, 0.55) 42%,
    rgba(253, 240, 213, 0.45) 100%
  );
  border: 1px solid var(--border);
  color: var(--accent-2);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
}

.layout {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.82) 50%,
    rgba(240, 250, 252, 0.9) 100%
  );
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 10px 12px;
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.board-wrap {
  min-width: 0;
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.stat-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 72px;
}

.stat-chip .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat-chip .value {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-chip.phase-memorize .value {
  color: var(--accent);
}

.stat-chip.phase-draw .value {
  color: var(--accent-2);
}

.stat-chip.phase-result .value {
  color: var(--ok);
}

.hint-bar {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
  min-height: 1.3em;
}

.progress {
  height: 6px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #3DB5A3);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.board-frame {
  position: relative;
  width: 100%;
  max-width: min(100%, calc(min(92vh, 920px) * 8 / 12));
  max-height: min(92vh, 920px);
  margin: 0 auto;
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 50% 40%, rgba(36, 157, 143, 0.06), transparent 55%),
    var(--board-bg);
  border-radius: 12px;
  border: 1px solid rgba(36, 157, 143, 0.28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 24px rgba(36, 157, 143, 0.1);
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Ready gate: hides path until the player starts (and the timer) */
.ready-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    linear-gradient(
      160deg,
      rgba(243, 249, 249, 0.97) 0%,
      rgba(232, 244, 245, 0.98) 100%
    );
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ready-gate[hidden] {
  display: none !important;
}

.ready-gate-card {
  width: min(100%, 300px);
  text-align: center;
  padding: 8px 4px;
}

.ready-gate-emoji {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.ready-gate-title {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-family: "Waukegan LDO", "Eurostile", "Arial Narrow", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.ready-gate-text {
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}

.ready-gate-text.muted,
.ready-gate-text .muted {
  color: var(--muted);
}

.ready-gate-text.muted {
  font-size: 0.86rem;
  margin-bottom: 16px;
}

.ready-gate-btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--accent, #249D8F);
  color: #fff;
  box-shadow: 0 4px 14px rgba(36, 157, 143, 0.35);
}

.ready-gate-btn:hover {
  filter: brightness(1.05);
}

.ready-gate-btn:active {
  transform: scale(0.98);
}

.board-frame.gated {
  cursor: default;
}

.board-frame.gated canvas {
  pointer-events: none;
}

.stat-chip.phase-ready .value {
  color: var(--muted);
}

@media (max-width: 820px) {
  .board-frame {
    max-width: min(100%, calc(min(88vh, 920px) * 8 / 12));
    max-height: min(88vh, 920px);
  }
}

.board-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.board-frame.anim-win {
  border-color: rgba(36, 157, 143, 0.55);
  box-shadow:
    0 0 0 1px rgba(36, 157, 143, 0.2),
    0 0 28px rgba(36, 157, 143, 0.22),
    0 8px 24px rgba(36, 157, 143, 0.1);
  animation: board-win-pulse 1.1s ease-out;
}

.board-frame.anim-fail {
  border-color: rgba(231, 111, 81, 0.45);
  box-shadow:
    0 0 0 1px rgba(231, 111, 81, 0.15),
    0 0 16px rgba(231, 111, 81, 0.15),
    0 8px 24px rgba(36, 157, 143, 0.1);
  animation: board-fail-blink 1s ease-in-out;
}

@keyframes board-win-pulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(36, 157, 143, 0.4),
      0 8px 24px rgba(36, 157, 143, 0.1);
  }
  40% {
    box-shadow:
      0 0 0 6px rgba(36, 157, 143, 0.12),
      0 0 28px rgba(36, 157, 143, 0.28),
      0 8px 24px rgba(36, 157, 143, 0.1);
  }
  100% {
    box-shadow:
      0 0 0 1px rgba(36, 157, 143, 0.2),
      0 0 16px rgba(36, 157, 143, 0.18),
      0 8px 24px rgba(36, 157, 143, 0.1);
  }
}

@keyframes board-fail-blink {
  0%,
  100% {
    border-color: rgba(231, 111, 81, 0.2);
  }
  35%,
  70% {
    border-color: rgba(231, 111, 81, 0.55);
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

a.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

a.btn-link:hover {
  background: #fff;
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px rgba(36, 157, 143, 0.12);
}

button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease,
    box-shadow 0.12s ease;
}

button:hover {
  background: #fff;
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px rgba(36, 157, 143, 0.12);
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: linear-gradient(135deg, #249D8F, #1A7A6F);
  border-color: rgba(36, 157, 143, 0.55);
  color: #fff;
  box-shadow: 0 4px 14px rgba(36, 157, 143, 0.28);
}

button.primary:hover {
  background: linear-gradient(135deg, #3DB5A3, #249D8F);
  border-color: #249D8F;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

button[hidden] {
  display: none !important;
}

.status {
  margin-top: 10px;
  min-height: 1.4em;
  font-size: 0.9rem;
  color: var(--muted);
}

.status.ok { color: var(--ok); }

.status.bad { color: var(--coral, var(--danger)); }

.status.warn { color: #B8860B; }

.side-panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--text);
}

.howto {
  margin: 0 0 14px;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.9rem;
}

.howto li {
  margin-bottom: 8px;
}

.howto strong {
  color: var(--text);
}

.howto em {
  color: var(--accent-2);
  font-style: normal;
  font-weight: 650;
}

.side-meta {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.side-meta strong {
  color: var(--text);
  font-weight: 600;
}

.footnote {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.95;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 58, 68, 0.35);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(240, 250, 252, 0.96) 100%
  );
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 8px;
}

.modal-card h2.ok {
  color: var(--ok);
}

.modal-card h2.bad {
  color: var(--danger);
}

.win-stats {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.win-stats strong {
  color: var(--text);
}

.result-detail {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}


/* Headings: Waukegan LDO (see /fonts/waukegan-ldo.css) */
h1, h2 {
  font-family: "Waukegan LDO", "Eurostile", "Arial Narrow", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Puzzle info box under How to play (matches One Stroke) */
.side-meta {
  background: var(--panel-2, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--muted, #5a6a72);
  margin: 0 0 12px;
}
.side-meta dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
}
.side-meta dt {
  color: var(--muted, #5a6a72);
  font-weight: 500;
}
.side-meta dd {
  margin: 0;
  color: var(--text, #1a2a30);
  font-weight: 600;
}


/* PALETTE-RICH OVERRIDES */
button.primary,
.btn-primary,
#btn-check.primary {
  background: linear-gradient(180deg, #3DB5A3 0%, var(--accent) 55%, var(--accent-2) 100%) !important;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: #fff !important;
  box-shadow: 0 6px 16px rgba(36, 157, 143, 0.28);
}
button.primary:hover,
.btn-primary:hover {
  filter: brightness(1.05);
}
#btn-share-x,
#btn-share-x-win,
#btn-share,
.btn-x-share {
  background: linear-gradient(180deg, var(--gold) 0%, #D4A84A 100%) !important;
  border-color: color-mix(in srgb, var(--gold) 60%, #8a6a20) !important;
  color: #2C2416 !important;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(233, 196, 106, 0.35);
}
.status.bad,
.bad {
  color: var(--coral, #E76F51) !important;
}
.status.ok,
.ok {
  color: var(--accent) !important;
}
.progress > span,
.progress-bar,
#progress-bar,
#question-timer-fill {
  background: linear-gradient(90deg, var(--accent), var(--gold)) !important;
}
.hero .badge,
.badge {
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--gold) 45%, var(--border));
  background: color-mix(in srgb, var(--gold) 18%, var(--panel));
}
a.nav-home {
  color: var(--accent-2);
}
a.nav-home:hover {
  color: var(--coral);
}


/* CORAL-EMPHASIS */
button:not(.primary):not(.btn-primary):hover {
  border-color: #E76F51 !important;
  color: #C9543A !important;
}
#btn-clear,
#btn-skip,
#btn-reset,
button[id*="clear"],
button[id*="reset"],
button[id*="skip"] {
  border-color: color-mix(in srgb, #E76F51 40%, var(--border)) !important;
  color: #C9543A !important;
}
#btn-clear:hover,
#btn-reset:hover,
#btn-skip:hover {
  background: color-mix(in srgb, #E76F51 14%, var(--panel)) !important;
}
.cell.wrong,
.wrong,
.is-wrong,
[data-wrong="1"] {
  background: #F8C4B4 !important;
  box-shadow: inset 0 0 0 2px #E76F51 !important;
}
.timer,
#timer,
.stat-chip .value {
  color: #C9543A;
}
.clue-current,
.hint-bar {
  border-left: 3px solid #E76F51;
}
.modal-actions #btn-close-modal,
#btn-close-modal,
#btn-close-win {
  border-color: color-mix(in srgb, #E76F51 45%, var(--border)) !important;
  color: #C9543A !important;
}
a.btn-link {
  border-color: color-mix(in srgb, #E76F51 35%, var(--border)) !important;
  color: #C9543A !important;
}
a.btn-link:hover {
  background: color-mix(in srgb, #E76F51 12%, #FFFBF3) !important;
}
