/* Tidy Nest — local, offline styling. No external fonts, images or assets. */
:root {
  --sky: #fdf3fa;
  --sky-2: #eaf6ff;
  --ink: #4b3a44;
  --ink-soft: #7d6c78;
  --pink: #ff9bb4;
  --pink-deep: #e77498;
  --cream: #fffaf2;
  --mint: #b9e8ce;
  --line: #f0d9e5;
  --shadow: 0 10px 24px rgba(123, 84, 107, 0.13);
  --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%, #f4fbe9 100%);
  min-height: 100vh;
}
.sky { max-width: 1120px; 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: 52px; height: 52px; 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, .scene-card, .tray-piece, .cell, .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, .scene-card:hover, .tray-piece:hover:not(.placed) { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(123, 84, 107, 0.16); }
.pill:active, .scene-card:active, .tray-piece: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: #4a2735; font-weight: 700; }
:focus-visible { outline: 3px solid #7b5cff; 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; }

.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 16px 0; }
.scene-card {
  border-radius: 18px; padding: 14px; text-align: left; display: grid; gap: 4px;
  background: linear-gradient(150deg, #fff, #fff4f8); min-height: 118px; position: relative;
}
.scene-card.perfect { border-color: #e8c46a; background: linear-gradient(150deg, #fffdf4, #fff2dd); }
.scene-card.daily { background: linear-gradient(150deg, #f0eaff, #eaf6ff); border-color: #d9cdf5; }
.scene-card.locked { opacity: 0.5; }
.scene-num { font-size: 1.35rem; font-weight: 800; color: var(--pink-deep); }
.scene-card strong { font-size: 1rem; }
.scene-goal { font-size: 0.82rem; color: var(--ink-soft); }
.scene-stars { color: #e9a23b; letter-spacing: 2px; font-size: 1.05rem; }
.scene-again { position: absolute; right: 12px; top: 12px; font-size: 0.7rem; color: var(--ink-soft); }

.hud {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 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.12rem; }
.goal-cell { grid-column: span 2; }
.bar { height: 9px; background: #f3e4ee; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--mint), var(--pink)); transition: width 0.2s ease; }

.play-area { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(240px, 0.85fr); gap: 16px; margin: 18px 0 12px; align-items: start; }
.board-wrap { display: flex; justify-content: center; }
.board {
  display: grid; grid-template-columns: repeat(var(--cols, 6), 1fr); gap: clamp(3px, 0.8vw, 7px);
  width: min(100%, 560px); padding: 12px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.72); border: 3px solid #fff; box-shadow: var(--shadow);
}
.cell {
  position: relative; aspect-ratio: 1 / 1; min-width: 0; padding: 0; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: linear-gradient(150deg, #fffdf9, #fff1f6); border: 2px solid #f7e4ee;
}
.cell .cell-dot { width: 5px; height: 5px; border-radius: 50%; background: #efd9e6; }
.cell.filled { background: var(--piece-color, #ffe9c9); border-color: rgba(75, 58, 68, 0.22); box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.6); }
.cell .piece-motif { width: 100%; height: 100%; display: block; opacity: 0.5; pointer-events: none; padding: 6%; }
.cell .piece-motif.anchor { opacity: 1; }
.cell .piece-motif svg { width: 100%; height: 100%; display: block; }
.cell.blocked { background: repeating-linear-gradient(45deg, #f6ecfb, #f6ecfb 7px, #efe1f8 7px, #efe1f8 14px); border-color: #d9c1e8; cursor: default; }
.cell.blocked svg { width: 78%; height: 78%; }
.cell.cursor { outline: 3px solid #7b5cff; outline-offset: -3px; }
.cell.preview { box-shadow: inset 0 0 0 4px rgba(255, 155, 180, 0.85); background: #fff3d9; }
.cell.preview.bad { box-shadow: inset 0 0 0 4px rgba(224, 92, 92, 0.65); background: #ffe9e9; }
.cell.hint { animation: hint 0.6s ease infinite alternate; border-color: #e9a23b; }
@keyframes hint { to { box-shadow: 0 0 0 5px rgba(233, 162, 59, 0.45); } }

.side { display: grid; gap: 14px; }
.panel {
  background: rgba(255, 255, 255, 0.72); border: 2px solid #fff; border-radius: 18px;
  padding: 14px; box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 10px; font-size: 1rem; }
.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tray-piece {
  border-radius: 14px; padding: 8px 6px; display: grid; justify-items: center; gap: 2px;
  background: linear-gradient(150deg, #fff, #fff6fb); touch-action: none;
}
.tray-piece.selected { border-color: var(--pink-deep); box-shadow: inset 0 0 0 3px var(--pink); }
.tray-piece.placed { opacity: 0.55; cursor: default; }
.shape-art { width: 100%; height: 54px; display: block; }
.piece-num { font-size: 0.7rem; color: var(--ink-soft); justify-self: start; }
.piece-name { font-size: 0.8rem; font-weight: 700; text-align: center; line-height: 1.2; }
.piece-state { font-size: 0.68rem; color: var(--ink-soft); }
.rule-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rule-item { display: flex; gap: 8px; align-items: flex-start; font-size: 0.82rem; padding: 5px 7px; border-radius: 9px; background: #fffaf2; }
.rule-item.fits { background: #f0fbf1; }
.rule-item.nudge { background: #fff3e4; }
.rule-mark { font-weight: 800; color: var(--pink-deep); }
.rule-item.fits .rule-mark { color: #4f9d68; }

.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(75, 58, 68, 0.38);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.dialog {
  position: relative; width: min(100%, 560px); max-height: 88vh; overflow: auto;
  background: var(--cream); border: 3px solid #fff; border-radius: 24px;
  padding: 24px; box-shadow: 0 24px 60px rgba(75, 58, 68, 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: #e9a23b; 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: #241820; --ink-soft: #4b3a44; --line: #8a6478; --cream: #fff; }
body.high-contrast .cell { border-color: #7b5cff; }
body.high-contrast .soft { color: #4b3a44; }
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: 860px) {
  .play-area { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .sky { padding: 10px; }
  .topbar { padding: 10px 12px; }
  .brand p { display: none; }
  .board { padding: 7px; gap: 3px; border-radius: 16px; }
  .cell { border-radius: 8px; border-width: 1px; }
  .goal-cell { grid-column: span 2; }
}
