:root {
  --bg: #1b2326;
  --panel: rgba(28, 22, 18, 0.82);
  --panel-solid: #2a211b;
  --ink: #f6ead8;
  --muted: #c9b79e;
  --accent: #f0b54a;
  --accent-ink: #2a1a08;
  --wood: #d9a46a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#ui button, #ui .screen, #ui .card { pointer-events: auto; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button.big {
  min-width: 12rem;
  padding: 0.85rem 1.6rem;
  border-radius: 14px;
  /* Solid enough to read over any floor (the menu's moving background included). */
  background: rgba(46, 33, 24, 0.9);
  border: 1px solid rgba(255, 240, 220, 0.14);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 1.15rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 8px rgba(0, 0, 0, 0.35);
}
button.big.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.big:active { transform: translateY(1px) scale(0.99); }
button.link { background: none; color: var(--muted); text-decoration: underline; padding: 0.5rem; }

button.icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  padding: 0;
}
button.icon svg { width: 26px; height: 26px; }
button.icon:disabled { opacity: 0.35; cursor: default; }
button.icon:not(:disabled):active { transform: scale(0.94); }
button.icon.big-icon { width: 60px; height: 60px; background: var(--accent); color: var(--accent-ink); }
button.icon.big-icon:disabled { background: var(--panel); color: var(--ink); }
button.icon.big-icon svg { width: 32px; height: 32px; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.menu { justify-content: center; gap: 2rem; background: radial-gradient(ellipse at center, rgba(20, 15, 12, 0.35), rgba(20, 15, 12, 0.8)); }
.title-card { text-align: center; }
.title-card h1 {
  font-size: clamp(3rem, 13vw, 5.5rem);
  margin: 0;
  letter-spacing: 0.02em;
  position: relative;
  display: inline-block;
  filter: drop-shadow(0 3px 0 #6e4120) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.55));
}
/* The word in planed wood: grain stripes and a warm sheen, clipped to the letters. */
.logo-word {
  color: var(--wood);
  background:
    repeating-linear-gradient(176deg, rgba(110, 60, 25, 0) 0 5px, rgba(110, 60, 25, 0.28) 5px 7px, rgba(110, 60, 25, 0) 7px 13px),
    linear-gradient(180deg, #f3cf98 0%, #e0a764 55%, #c6834a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
/* A saw biting into the last letters. */
.logo-saw {
  position: absolute;
  width: 1.25em;
  right: -0.86em;
  top: -0.42em;
  transform: rotate(-32deg);
  transform-origin: 70% 60%;
  pointer-events: none;
}
.tagline { color: var(--muted); margin: 0.5rem 0 0; font-size: 1.05rem; text-shadow: 0 1px 3px #000, 0 0 10px rgba(0, 0, 0, 0.8); }
.menu-buttons { display: flex; flex-direction: column; gap: 0.9rem; }
.progress { color: var(--muted); margin: 0; text-shadow: 0 1px 3px #000, 0 0 10px rgba(0, 0, 0, 0.8); }
.corner { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; display: flex; gap: 10px; }

.levels { background: rgba(20, 15, 12, 0.88); }
.levels header, .settings header { width: 100%; max-width: 760px; display: flex; align-items: center; gap: 1rem; }
.levels h2 { margin: 0; font-size: 1.5rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; max-width: 760px; margin: 1rem 0; }
.chapter-dots { display: none; justify-content: center; flex-wrap: wrap; gap: 0; margin: 0.2rem 0 0.7rem; flex-shrink: 0; }
.chapter-dots .dot { width: 26px; height: 26px; padding: 0; background: none; position: relative; }
.chapter-dots .dot::after { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 999px; background: rgba(255, 240, 220, 0.35); transition: width 0.2s, margin 0.2s, background 0.2s; }
.chapter-dots .dot.shut::after { background: rgba(255, 240, 220, 0.14); }
.chapter-dots .dot.on::after { width: 20px; margin-left: -10px; background: var(--accent); }
.tab { padding: 0.55rem 0.9rem; border-radius: 999px; background: rgba(46, 33, 24, 0.9); border: 1px solid rgba(255, 240, 220, 0.12); color: #d9c9b6; }
.tab.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tab .count { opacity: 0.7; font-size: 0.85em; margin-left: 0.2rem; }
.grid {
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}
.level-btn {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: #4a3626;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06), 0 2px 6px rgba(0, 0, 0, 0.4);
  padding: 6px;
}
.level-btn.done { box-shadow: inset 0 0 0 2px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.4); }
.level-btn .num { position: absolute; left: 8px; top: 6px; font-weight: 700; font-size: 0.95rem; text-shadow: 0 1px 2px #000; }
.level-btn .tick { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.level-btn .tick svg { width: 16px; height: 16px; }
.preview { width: 100%; height: 100%; display: block; }
.pv-hole { fill: #1d1410; stroke: #0c0806; stroke-width: 0.08; }
.pv-plank { fill: var(--wood); stroke: #6d4321; stroke-width: 0.08; }

.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top, .hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}
.hud-top { top: 0; padding-top: max(10px, env(safe-area-inset-top)); }
.hud-bottom { bottom: 0; justify-content: center; gap: 18px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.hud-title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.1rem; text-shadow: 0 1px 3px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) {
  .hud-title { font-size: 0.95rem; line-height: 1.1; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .hud-top { gap: 0.4rem; }
}
.slices { background: var(--panel); padding: 0.45rem 0.8rem; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hint {
  position: absolute;
  left: 50%;
  top: calc(max(10px, env(safe-area-inset-top)) + 64px);
  transform: translateX(-50%);
  width: min(92%, 520px);
  box-sizing: border-box;
  background: var(--panel);
  padding: 0.7rem 1rem;
  border-radius: 12px;
  text-align: center;
  line-height: 1.35;
  animation: hint-in 0.4s ease-out;
}
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, -6px); } }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 6, 0.45);
  pointer-events: auto;
  animation: fade-in 0.35s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.card {
  background: var(--panel-solid);
  border-radius: 18px;
  padding: 1.6rem 1.8rem;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  width: min(88vw, 360px);
  box-sizing: border-box;
}
.card h2 { margin: 0 0 0.3rem; font-size: 1.9rem; color: var(--accent); }
.card p { color: var(--muted); margin: 0 0 1.2rem; }
.card-buttons { display: flex; flex-direction: column; gap: 0.7rem; align-items: center; }
.error { color: #ffb4a0; max-width: 28rem; text-align: center; margin-top: 30vh; }
.level-btn.next { box-shadow: inset 0 0 0 2px #fff6, 0 0 0 0 var(--accent); animation: next-pulse 1.8s ease-in-out infinite; }
@keyframes next-pulse { 50% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 14px 2px rgba(240, 181, 74, 0.45); } }

/* Stars and locks */
.star { display: inline-grid; color: #fff3; vertical-align: -0.15em; }
.star svg { width: 1em; height: 1em; }
.star.on { color: #ffc94a; filter: drop-shadow(0 1px 1px #0008); }
.progress .star { font-size: 1.1em; }
.tab .count .star { margin-right: 0.15rem; }
.lock { display: inline-grid; margin-right: 0.3rem; vertical-align: -0.12em; opacity: 0.8; }
.lock svg { width: 0.95em; height: 0.95em; }
.lock.big svg { width: 1.6em; height: 1.6em; }
.locked-note { display: flex; gap: 0.6rem; align-items: center; justify-content: center; color: var(--muted); padding: 0.6rem 1rem; }
.grid.locked { opacity: 0.35; filter: grayscale(0.7); }
.tile-stars { position: absolute; right: 6px; top: 5px; display: flex; gap: 1px; font-size: 0.95rem; }
.slices .par { opacity: 0.6; font-weight: 500; }
.big-stars { display: flex; justify-content: center; gap: 0.4rem; font-size: 2.6rem; margin: 0.2rem 0 0.4rem; }
.big-stars .star { animation: star-pop 0.45s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(0.25s + var(--i) * 0.28s); }
.big-stars .star:nth-child(2) { transform: translateY(-0.25rem); }
@keyframes star-pop { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.cuts-line .par { color: var(--muted); }
.cuts-line .best { color: #ffc94a; font-weight: 700; margin-left: 0.3rem; }
.card .note { color: var(--muted); font-size: 0.92rem; margin: 0.2rem 0 0.6rem; }

/* Daily floor */
.daily-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; position: relative; }
.daily-btn .muted { opacity: 0.65; font-weight: 500; }
.badge { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; padding: 0.1rem 0.4rem; border-radius: 999px; }
.badge.new { background: #e8553a; color: #fff; }
.badge.done { background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; padding: 0; }
.badge.done svg { width: 0.9rem; height: 0.9rem; }
.streak { font-size: 0.85rem; font-weight: 700; }
.daily-share { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.streak-line { margin: 0; font-weight: 700; }

/* Settings */
.settings-body { width: min(30rem, 100%); display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; padding-bottom: 2rem; }
.settings section, .settings details.section { background: var(--panel); border-radius: 14px; padding: 0.4rem 1rem; }
.settings details.section summary { list-style: none; cursor: pointer; }
.settings details.section summary::-webkit-details-marker { display: none; }
.settings details.section .chev { display: inline-block; margin-left: 0.4rem; transition: transform 0.2s; opacity: 0.7; }
.settings details.section[open] .chev { transform: rotate(90deg); }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3rem; border-bottom: 1px solid #fff1; }
.settings .row:last-child, .settings details.section:not([open]) > summary.row { border-bottom: none; }
.settings input[type=range] { width: 45%; accent-color: var(--accent); }
.switch { width: 3rem; height: 1.7rem; border-radius: 999px; border: none; background: #ffffff26; position: relative; cursor: pointer; padding: 0; transition: background 0.2s; }
.switch span { position: absolute; top: 0.2rem; left: 0.2rem; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--ink); transition: transform 0.2s; }
.switch.on { background: var(--accent); }
.switch.on span { transform: translateX(1.3rem); background: var(--accent-ink); }
button.small { font: inherit; font-size: 0.9rem; padding: 0.4rem 0.8rem; border-radius: 999px; border: none; background: #ffffff1f; color: var(--ink); cursor: pointer; }
button.small.danger { background: #c0392b; color: #fff; }
.confirm { display: flex; gap: 0.4rem; }
.about h3 { margin: 0.6rem 0 0.2rem; }
.about p { margin: 0.4rem 0; line-height: 1.4; }
.about .muted { color: var(--muted); font-size: 0.85rem; }
.settings { background: rgba(20, 15, 12, 0.72); }

/* Woods */
.swatch { display: inline-block; width: 2.2rem; height: 2.2rem; border-radius: 8px; box-shadow: inset 0 0 0 1px #0005, 0 1px 3px #0008; }
.woods { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr)); gap: 0.5rem; padding: 0.2rem 0 0.8rem; }
.wood { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; background: none; border: 2px solid transparent; border-radius: 10px; color: var(--ink); font: inherit; font-size: 0.8rem; padding: 0.35rem 0.2rem; cursor: pointer; }
.wood.on { border-color: var(--accent); }
.wood:disabled { opacity: 0.45; cursor: default; }
.wood:disabled .swatch { filter: grayscale(0.8) brightness(0.6); }
.settings .muted { color: var(--muted); }
.unlock { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin: 0 0 0.7rem; }
.unlock .swatch { width: 1.8rem; height: 1.8rem; }
.unlock .muted { color: var(--muted); font-size: 0.85rem; }
.lock.open { color: var(--accent); }
.menu-buttons .muted { opacity: 0.65; font-weight: 500; margin-left: 0.3rem; }
.random-pick h2 { margin: 0; font-size: 2rem; }

/* Floor maker */
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; margin-top: 0.5rem; pointer-events: auto; }
.chip { font: inherit; font-size: 0.85rem; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid #fff3; background: rgba(46, 33, 24, 0.9); color: var(--ink); cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.maker .hud-bottom .big { width: auto; padding-left: 1.1rem; padding-right: 1.1rem; }
.maker .hud-bottom { gap: 8px; }
.maker .hud-bottom .big { flex: 0 1 11rem; min-width: 0; padding-left: 0.5rem; padding-right: 0.5rem; white-space: nowrap; }
@media (max-width: 420px) { .maker .hud-bottom .big { font-size: 0.95rem; } }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 4px 0 8px; }
.badge-cell { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(255, 240, 220, 0.05); opacity: 0.55; }
.badge-cell.got { opacity: 1; background: rgba(240, 180, 80, 0.12); }
.badge-cell .badge-ico { grid-row: span 2; }
.badge-ico { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.badge-ico.got { background: var(--accent); color: var(--accent-ink); }
.badge-ico svg { width: 15px; height: 15px; }
.bname { font-weight: 600; font-size: 0.92rem; }
.bnote { font-size: 0.78rem; color: var(--muted); }
.howto dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 4px 0 10px; font-size: 0.9rem; }
.howto dt { font-weight: 700; color: var(--wood); }
.howto dd { margin: 0; color: var(--muted); }
@media (max-width: 600px) {
  /* Phones: no sideways-scrolling tab row (sideways swipes change chapter); the header's
     title and ‹ › plus a row of dots stand in for it. */
  .tabs { display: none; }
  .chapter-dots { display: flex; }
}
.slices { transition: background 0.3s, color 0.3s; }
.slices.over { background: rgba(190, 70, 40, 0.75); color: #fff4ea; }
.slices.over .par { opacity: 0.85; }
.play-btn { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.play-note { font-size: 0.78rem; font-weight: 600; opacity: 0.7; margin-top: 2px; }

/* Desktop hover: a soft lift and warm glow on everything you can click. Only for a real
   mouse (touch screens have no hover, and would keep a stuck highlight after a tap). */
button, .level-btn, .switch, .chip, .tab, summary {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}
@media (hover: hover) and (pointer: fine) {
  button.big:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(240, 180, 80, 0.55); background-color: rgba(70, 50, 34, 0.95); }
  button.big.primary:not(:disabled):hover { background-color: var(--accent); filter: brightness(1.08); }
  button.icon:not(:disabled):hover { transform: scale(1.08); box-shadow: 0 0 0 2px rgba(240, 180, 80, 0.6), 0 4px 12px rgba(0, 0, 0, 0.45); }
  button.icon.big-icon:not(:disabled):hover { filter: brightness(1.08); }
  .tab:hover:not(.on) { background-color: rgba(70, 50, 34, 0.95); color: var(--ink); box-shadow: 0 0 0 1px rgba(240, 180, 80, 0.5); }
  .chip:hover:not(.on) { background-color: rgba(70, 50, 34, 0.95); border-color: rgba(240, 180, 80, 0.6); }
  .level-btn:not(:disabled):hover { transform: translateY(-3px); box-shadow: 0 0 0 2px rgba(240, 180, 80, 0.7), 0 8px 18px rgba(0, 0, 0, 0.5); }
  .switch:hover { filter: brightness(1.15); box-shadow: 0 0 0 2px rgba(240, 180, 80, 0.45); }
  button.link:hover, button.small:hover { color: var(--ink); filter: brightness(1.15); }
  .settings details.section > summary:hover { color: var(--accent); }
  button.wood:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 0 0 2px rgba(240, 180, 80, 0.5); }
}
/* The hint says a cut went wrong: the undo-cut button calls for attention. */
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(240, 180, 80, 0.75); } 70% { box-shadow: 0 0 0 14px rgba(240, 180, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(240, 180, 80, 0); } }
button.icon.pulse { animation: pulse-ring 1.4s ease-out infinite; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { button.icon.pulse { animation: none; box-shadow: 0 0 0 3px rgba(240, 180, 80, 0.8); } }
.tile { position: relative; display: grid; }
.tile > .level-btn { width: 100%; }
.tile-remove { position: absolute; top: 6px; right: 6px; padding: 0; border: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 14, 10, 0.75); color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .tile-remove:hover { color: #fff; background: rgba(160, 60, 40, 0.9); } }
.shift-line { margin: 0.2rem 0 0.6rem; font-size: 1.05rem; }
.shift-line .muted { opacity: 0.7; }
/* Level select header: the chapter's name, and ‹ › to step through the chapters. */
.screen.levels header .chapter-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-step { display: flex; gap: 0.4rem; margin-left: auto; }
.chapter-step .icon { font-size: 1.7rem; line-height: 1; padding-bottom: 4px; }
.tabs { flex-shrink: 0; } /* (on a phone the row was squeezed to nothing) */
/* Move your progress (Settings) */
.move .bnote { margin: 0.2rem 0 0.6rem; }
.move .bnote.err { color: #ff9b85; }
.move-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.4rem 0; }
.move-code { width: 100%; box-sizing: border-box; background: rgba(0, 0, 0, 0.3); color: var(--ink); border: 1px solid #fff2; border-radius: 10px; padding: 0.5rem; font: 0.8rem/1.3 ui-monospace, monospace; resize: vertical; }
/* A short note at the bottom of the screen */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px);
  background: rgba(46, 33, 24, 0.96); color: var(--ink); border: 1px solid rgba(240, 180, 80, 0.5); border-radius: 12px; padding: 0.7rem 1rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); transition: opacity 0.5s; }
.toast.out { opacity: 0; }
/* Level select: the grid slides in from the side a swipe (or ‹ ›) came from */
.grid.slide-from-right { animation: grid-in-right 0.22s ease-out; }
.grid.slide-from-left { animation: grid-in-left 0.22s ease-out; }
@keyframes grid-in-right { from { transform: translateX(60vw); opacity: 0.3; } }
@keyframes grid-in-left { from { transform: translateX(-60vw); opacity: 0.3; } }
.screen.levels { touch-action: pan-y; overflow-x: hidden; }
@media (prefers-reduced-motion: reduce) { .grid.slide-from-right, .grid.slide-from-left { animation: none; } }
