/* Bloomfall — style.css
   Palette: Okabe-Ito accents on a deep garden ground.
   Spring easing per game-feel contract; reduced-motion degrades to opacity. */

:root {
  --ground-0: #0c1a14;
  --ground-1: #10231c;
  --ground-2: #18342a;
  --chrome: #0a1410;
  --ink: #eef6f0;
  --ink-dim: #9db8aa;
  --alga: #56B4E9;     /* Okabe-Ito sky   */
  --fungus: #E69F00;   /* Okabe-Ito orange*/
  --leaf: #009E73;     /* Okabe-Ito green */
  --petal: #CC79A7;    /* Okabe-Ito pink  */
  --sun: #F0E442;      /* Okabe-Ito yellow*/
  --deep: #0072B2;     /* Okabe-Ito blue  */
  --ember: #D55E00;    /* Okabe-Ito verm. */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ground-0);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app { height: 100%; display: flex; flex-direction: column; }

/* ---------- screens ---------- */
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; align-items: center; }
.screen.visible { display: flex; }

/* ---------- title ---------- */
#screen-title { justify-content: center; gap: 14px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 30%, var(--ground-2) 0%, var(--ground-0) 75%); }

.logo { font-size: clamp(2.4rem, 9vw, 4rem); letter-spacing: 0.02em; font-weight: 800;
  background: linear-gradient(135deg, var(--sun) 0%, var(--petal) 55%, var(--alga) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }

.tagline { color: var(--ink-dim); font-size: 1.05rem; letter-spacing: 0.25em; }

.title-bloom { position: relative; width: 92px; height: 92px; animation: bloomspin 24s linear infinite; }
.title-bloom .petal { position: absolute; width: 38px; height: 38px; border-radius: 50%; opacity: 0.85; left: 27px; top: 27px; }
.p1 { background: var(--petal); transform: translate(0,-30px); }
.p2 { background: var(--alga); transform: translate(26px,-15px); }
.p3 { background: var(--leaf); transform: translate(26px,15px); }
.p4 { background: var(--sun); transform: translate(0,30px); }
.p5 { background: var(--deep); transform: translate(-26px,15px); }
.p6 { background: var(--ember); transform: translate(-26px,-15px); }
.title-core { position: absolute; left: 26px; top: 26px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--fungus); box-shadow: 0 0 24px rgba(230,159,0,0.5); }
@keyframes bloomspin { to { transform: rotate(360deg); } }

.menu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 86vw); }
.menu-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.footnote { color: var(--ink-dim); font-size: 0.78rem; margin-top: 6px; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; color: var(--ink);
  background: var(--ground-2); border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius); padding: 13px 22px; cursor: pointer;
  transition: transform 0.25s var(--spring), background 0.2s ease, border-color 0.2s ease;
}
.btn:hover, .btn:focus-visible { transform: scale(1.045); border-color: var(--alga); outline: none; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, #1d4435, #16382b); border-color: rgba(86,180,233,0.35); font-size: 1.08rem; }
.btn-small { padding: 9px 14px; font-size: 0.88rem; font-weight: 600; }
.btn-danger { border-color: rgba(213,94,0,0.6); color: #f3b48f; }
.btn-icon { font: inherit; background: rgba(255,255,255,0.06); color: var(--ink); border: none;
  border-radius: 10px; width: 42px; height: 42px; font-size: 1rem; cursor: pointer; }
.btn-icon:focus-visible { outline: 2px solid var(--alga); }
.badge { background: var(--ember); color: #fff; border-radius: 8px; font-size: 0.7rem; padding: 2px 7px; vertical-align: middle; }

/* ---------- game screen / figure-ground ---------- */
#screen-game { background: var(--chrome); }

#hud {
  width: 100%; max-width: 560px; display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 8px 14px; gap: 8px;
}
.hud-left { display: flex; flex-direction: column; }
.hud-label { display: block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-dim); }
.hud-score span:last-child { font-size: 1.7rem; font-weight: 800; line-height: 1.05; }
.hud-best { color: var(--ink-dim); font-size: 0.85rem; }
.hud-best span { color: var(--ink); font-weight: 700; }
.ghost-line { font-size: 0.78rem; font-weight: 700; }
.ghost-line.ahead { color: #57c79e; }
.ghost-line.behind { color: #E69F00; }
.hud-right { display: flex; align-items: center; gap: 10px; }
.next-wrap { text-align: center; }
#next-canvas { display: block; width: 40px; height: 110px; margin-top: 2px; }
.hold-wrap { text-align: center; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 3px 5px 4px; cursor: pointer; color: var(--ink-dim); font: inherit; }
.hold-wrap:hover, .hold-wrap:focus-visible { border-color: var(--alga); outline: none; }
.hold-wrap:active { transform: scale(0.95); }
#hold-canvas { display: block; width: 44px; height: 44px; }

.combo-pop { font-weight: 800; font-size: 1.25rem; color: var(--sun); min-width: 70px; text-align: center;
  opacity: 0; transform: scale(0.6); }
.combo-pop.show { opacity: 1; transform: scale(1); transition: transform 0.3s var(--spring), opacity 0.15s ease; }
.combo-pop.fade { opacity: 0; transform: scale(0.85); transition: opacity 0.5s ease, transform 0.5s ease; }

#field-wrap { position: relative; flex: 1; min-height: 0; width: 100%; max-width: 560px;
  display: flex; justify-content: center; padding: 0 8px max(8px, env(safe-area-inset-bottom)) 8px; }
#game-canvas { display: block; border-radius: 18px 18px 12px 12px; background: var(--ground-1);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.05), 0 12px 40px rgba(0,0,0,0.45);
  touch-action: none; max-width: 100%; max-height: 100%; }

#tutorial { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; text-align: center; pointer-events: none;
  color: var(--ink); text-shadow: 0 2px 8px rgba(0,0,0,0.8); font-weight: 700; font-size: 1.05rem; }
.tut-hand { font-size: 2.6rem; animation: handsway 1.6s var(--spring) infinite alternate; }
@keyframes handsway { from { transform: translateX(-26px); } to { transform: translateX(26px); } }

/* ---------- modals ---------- */
#modal-backdrop { position: fixed; inset: 0; background: rgba(5,10,8,0.72); z-index: 40; }
.modal { z-index: 50; border: none; border-radius: 18px; background: var(--ground-2); color: var(--ink);
  padding: 22px 22px 18px; width: min(420px, 92vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6); }
.modal::backdrop { background: rgba(5,10,8,0.72); }
.modal[open] { animation: modalin 0.35s var(--spring); }
@keyframes modalin { from { transform: translateY(22px) scale(0.96); opacity: 0; } }
.modal h2 { margin-bottom: 12px; text-align: center; }
.modal h3 { margin: 14px 0 8px; text-align: center; font-size: 0.95rem; color: var(--ink-dim); }
.modal-wide { width: min(560px, 94vw); }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.center { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

.over-score { text-align: center; font-size: 1.1rem; }
.over-score strong { font-size: 1.9rem; display: block; }
.over-best { text-align: center; color: var(--sun); font-weight: 700; }
.over-recap { background: var(--ground-1); border-radius: 10px; padding: 8px 12px; margin: 4px 0; }
.recap-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 3px 0; }
.recap-row span:last-child { font-weight: 700; color: var(--ink); }
.recap-row span:first-child { color: var(--ink-dim); }
.recap-poem { text-align: center; font-style: italic; font-size: 0.78rem; color: var(--ink-dim); margin-top: 6px; }
.over-disc, .over-daily { text-align: center; color: var(--ink-dim); }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 2px; font-weight: 600; }
.setting-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--leaf); cursor: pointer; }

.help-body p { line-height: 1.45; }
.kbd-note { color: var(--ink-dim); font-size: 0.85rem; }

/* ---------- codex ---------- */
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.codex-card { background: var(--ground-1); border-radius: 12px; padding: 10px 6px; text-align: center;
  border: 1px solid rgba(255,255,255,0.06); }
.codex-card canvas { width: 56px; height: 56px; display: block; margin: 0 auto 6px; }
.codex-card .cname { font-size: 0.78rem; font-weight: 700; }
.codex-card .ccount { font-size: 0.68rem; color: var(--ink-dim); }
.codex-card.locked { opacity: 0.45; filter: grayscale(1); }
.codex-card.mastery-sketch { opacity: 0.82; }
.codex-card.mastery-colored { border-color: rgba(86,180,233,0.4); }
.codex-card.mastery-bloomed { border-color: rgba(240,228,66,0.55); box-shadow: 0 0 14px rgba(240,228,66,0.15); }
.cflavor2 { color: var(--sun); opacity: 0.85; margin-top: 4px; }
.log-summary { text-align: center; font-size: 0.82rem; font-weight: 700; color: var(--ink); margin: 10px 0 2px; }

/* ---------- gardener level + perks ---------- */
.level-head { text-align: center; margin-bottom: 10px; }
.level-num { font-size: 1.6rem; font-weight: 800; color: var(--leaf); }
.level-bar-wrap { height: 9px; background: rgba(255,255,255,0.08); border-radius: 6px; overflow: hidden; margin: 6px 0 3px; }
.level-bar { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--sun)); border-radius: 6px; transition: width 0.5s var(--spring); }
.level-xp { font-size: 0.74rem; color: var(--ink-dim); }
.perk-note { text-align: center; font-size: 0.74rem; color: var(--ink-dim); margin-bottom: 10px; }
.perk-list { display: flex; flex-direction: column; gap: 8px; }
.perk { display: flex; align-items: center; gap: 10px; background: var(--ground-1); border-radius: 10px; padding: 9px 11px; }
.perk.locked { opacity: 0.5; }
.perk-txt { flex: 1; }
.perk-txt b { display: block; font-size: 0.9rem; }
.perk-txt span { font-size: 0.74rem; color: var(--ink-dim); }
.perk-toggle { width: 44px; height: 24px; border-radius: 12px; border: none; cursor: pointer; flex-shrink: 0;
  background: rgba(255,255,255,0.15); position: relative; transition: background 0.2s ease; }
.perk-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform 0.2s var(--spring); }
.perk-toggle.on { background: var(--leaf); }
.perk-toggle.on::after { transform: translateX(20px); }
.perk-lock { font-size: 0.74rem; color: var(--ink-dim); flex-shrink: 0; }

/* ---------- stats + achievements ---------- */
.stats-body { font-size: 0.92rem; }
.stat-row { display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(255,255,255,0.08); padding: 5px 2px; }
.stat-row span:last-child { font-weight: 700; }
.ach-grid { display: flex; flex-direction: column; gap: 6px; }
.ach { display: flex; gap: 10px; align-items: center; background: var(--ground-1); border-radius: 10px; padding: 8px 10px; }
.ach.locked { opacity: 0.45; }
.ach .aicon { font-size: 1.3rem; }
.ach .atext b { display: block; font-size: 0.88rem; }
.ach .atext span { font-size: 0.75rem; color: var(--ink-dim); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 9%; transform: translateX(-50%) translateY(0);
  background: var(--ground-2); border: 1px solid rgba(240,228,66,0.5); color: var(--ink);
  border-radius: 12px; padding: 11px 18px; font-weight: 700; z-index: 60;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5); transition: transform 0.4s var(--spring), opacity 0.3s ease; }
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(24px); pointer-events: none; }

.hidden { display: none !important; }

/* ---------- home ribbon ---------- */
.home-ribbon { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 8px 16px; color: var(--ink-dim); font-size: 0.85rem; font-weight: 600; }
#rib-streak { color: var(--sun); }
#rib-mod { color: var(--alga); }

/* ---------- juice ---------- */
.hud-score span:last-child { display: inline-block; }
#score.bump { animation: scorebump 0.3s var(--spring); }
@keyframes scorebump { 50% { transform: scale(1.22); } }
.next-wrap.pop #next-canvas { animation: nextpop 0.35s var(--spring); }
@keyframes nextpop { 0% { transform: scale(0.45); } }

/* ---------- garden log calendar ---------- */
.log-month { text-align: center; color: var(--ink-dim); margin-bottom: 10px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { aspect-ratio: 1; border-radius: 9px; background: var(--ground-1);
  display: flex; align-items: center; justify-content: center; font-size: 0.72rem;
  color: var(--ink-dim); border: 1px solid rgba(255,255,255,0.05); }
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.played { background: #1d4435; color: var(--ink); font-size: 0.95rem; }
.cal-cell.played.t2 { background: #25634a; }
.cal-cell.played.t3 { background: #2f8a60; }
.cal-cell.today { outline: 2px solid var(--sun); }
.log-note { text-align: center; font-size: 0.75rem; color: var(--ink-dim); margin-top: 10px; }

/* ---------- palette select + codex flavor ---------- */
.setting-row select { font: inherit; background: var(--ground-1); color: var(--ink);
  border-radius: 8px; padding: 6px 8px; border: 1px solid rgba(255,255,255,0.1); max-width: 58%; }
.cflavor { font-size: 0.64rem; color: var(--ink-dim); margin-top: 3px; font-style: italic; line-height: 1.25; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .title-bloom, .tut-hand { animation: none; }
  #score.bump, .next-wrap.pop #next-canvas { animation: none; }
  .btn, .btn:hover, .btn:focus-visible, .btn:active { transition: none; transform: none; }
  .modal[open] { animation: none; }
  .combo-pop.show, .combo-pop.fade { transition: opacity 0.4s ease; transform: none; }
  .toast { transition: opacity 0.3s ease; }
}
body.reduce-motion .title-bloom, body.reduce-motion .tut-hand { animation: none; }
body.reduce-motion .btn { transition: none; }
body.reduce-motion .btn:hover, body.reduce-motion .btn:active, body.reduce-motion .btn:focus-visible { transform: none; }
body.reduce-motion .modal[open] { animation: none; }
body.reduce-motion .combo-pop.show, body.reduce-motion .combo-pop.fade { transition: opacity 0.4s ease; transform: none; }
body.reduce-motion #score.bump, body.reduce-motion .next-wrap.pop #next-canvas { animation: none; }
