/* Bramble: Sparkle Journey — local, offline styling. No external fonts or assets. */
:root {
  --sky: #f1f7f2;
  --sky-2: #e5eff3;
  --ink: #35473e;
  --ink-soft: #6b7d72;
  --pink: #9bcdb0;
  --pink-deep: #5d9774;
  --cream: #fbfdf8;
  --mint: #d3e8da;
  --line: #d7e6dc;
  --shadow: 0 10px 24px rgba(65, 96, 78, 0.14);
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--sky) 0%, var(--sky-2) 55%, #f6f8ea 100%);
  min-height: 100vh;
}
.sky { max-width: 1040px; margin: 0 auto; padding: 18px 18px 30px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.78); border: 2px solid #fff; border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 48px; height: 48px; flex: none; display: block; }
.brand-icon svg { width: 100%; height: 100%; }
.brand h1 { margin: 0; font-size: clamp(1.15rem, 3vw, 1.6rem); letter-spacing: 0.3px; }
.brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.86rem; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.pill, .level-card, .tile, .close {
  font: inherit; color: var(--ink); cursor: pointer;
  border: 2px solid var(--line); background: var(--cream);
  border-radius: 999px; padding: 8px 15px; transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.pill:hover, .level-card:hover:not(:disabled), .tile:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(65, 96, 78, 0.18); }
.pill:active, .level-card:active, .tile:active { transform: translateY(0); }
.pill.round { width: 40px; height: 40px; padding: 0; font-weight: 800; }
.pill.primary { background: var(--pink); border-color: var(--pink-deep); color: #263c2e; font-weight: 700; }
:focus-visible { outline: 3px solid #4b8f6b; outline-offset: 2px; }

.view { margin-top: 18px; }
.intro h2 { margin: 0 0 6px; font-size: 1.5rem; }
.intro p, .message { margin: 0 0 14px; color: var(--ink-soft); }
.soft { color: var(--ink-soft); font-size: 0.86rem; }
.center { text-align: center; }
kbd { background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; font-size: 0.82em; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 16px 0; }
.level-card {
  border-radius: 18px; padding: 14px; text-align: left; display: grid; gap: 4px;
  background: linear-gradient(150deg, #fff, #eef6f0); min-height: 112px;
}
.level-card .level-num { font-size: 1.35rem; font-weight: 800; color: var(--pink-deep); }
.level-card strong { font-size: 1rem; }
.level-goal { font-size: 0.82rem; color: var(--ink-soft); }
.level-stars { color: #c99634; letter-spacing: 2px; font-size: 1.05rem; }
.level-card.daily { background: linear-gradient(150deg, #eef6f8, #f7f6e6); border-color: #cfe0d8; }
.level-card.locked { opacity: 0.5; cursor: not-allowed; }

.hud {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px;
  background: rgba(255, 255, 255, 0.8); border: 2px solid #fff; border-radius: 18px;
  padding: 12px 16px; box-shadow: var(--shadow);
}
.hud-cell { display: grid; gap: 2px; }
.hud-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.hud-cell strong { font-size: 1.15rem; }
.goal-cell { grid-column: span 2; }
.bar { height: 8px; background: #e4efe6; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--mint), var(--pink)); transition: width 0.2s ease; }

.board-wrap { display: flex; justify-content: center; margin: 18px 0 12px; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: clamp(3px, 1vw, 7px);
  width: min(100%, 580px); padding: 12px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.72); border: 3px solid #fff; box-shadow: var(--shadow);
}
.tile {
  position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: linear-gradient(150deg, #fdfffb, #eff7f1); border: 2px solid #e2eee5;
}
.tile-art { width: 100%; height: 100%; display: block; pointer-events: none; }
.tile.selected { border-color: var(--pink-deep); box-shadow: inset 0 0 0 3px var(--pink); }
.tile.cursor { outline: 3px solid #4b8f6b; outline-offset: -3px; }
.tile.special { background: linear-gradient(150deg, #fafff0, #e7f6dd); }
.tile.frosted { background: linear-gradient(150deg, #edf6fa, #dfeef5); }
.tile.popping .tile-art { animation: pop 0.18s ease; }
.tile.hint { animation: hint 0.6s ease infinite alternate; border-color: #c99634; }
@keyframes pop { 50% { transform: scale(1.18); } }
@keyframes hint { to { box-shadow: 0 0 0 5px rgba(201, 150, 52, 0.4); } }

.game-foot { background: rgba(255, 255, 255, 0.62); border-radius: 18px; padding: 14px 18px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.footer { text-align: center; color: var(--ink-soft); font-size: 0.8rem; margin-top: 24px; }

.overlay {
  position: fixed; inset: 0; z-index: 10; background: rgba(53, 71, 62, 0.38);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.dialog {
  position: relative; width: min(100%, 520px); max-height: 88vh; overflow: auto;
  background: var(--cream); border: 3px solid #fff; border-radius: 24px;
  padding: 24px; box-shadow: 0 24px 60px rgba(53, 71, 62, 0.28);
}
.dialog h2 { margin: 0 0 12px; }
.dialog p { line-height: 1.55; }
.dialog ul { line-height: 1.6; padding-left: 20px; }
.close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; padding: 0; line-height: 1; font-size: 1.4rem; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.stars-big { font-size: 2.4rem; color: #c99634; text-align: center; margin: 4px 0 10px; letter-spacing: 6px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 1rem; }
.toggle input { width: 20px; height: 20px; accent-color: var(--pink-deep); }

body.high-contrast { --ink: #1d2b22; --ink-soft: #35473e; --line: #5c7a67; --cream: #fff; }
body.high-contrast .tile { border-color: #4b8f6b; }
body.high-contrast .soft { color: #35473e; }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation: none !important; transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 620px) {
  .sky { padding: 10px; }
  .topbar { padding: 10px 12px; }
  .brand p { display: none; }
  .board { padding: 7px; gap: 3px; border-radius: 16px; }
  .tile { border-radius: 9px; border-width: 1px; }
  .goal-cell { grid-column: span 2; }
}
