/* Moonpath Garden — cozy 2-player. Inherits site vars from ../style.css */
:root {
  --lavender: #a78bca;
  --lavender-bg: #ece4f6;
  --ivy: #5fae7d;
  --ivy-bg: #dcefe2;
  --sunflower: #eab73a;
  --sunflower-bg: #fbeec6;
  --moonflower: #e98fc0;
  --moonflower-bg: #fbe1ee;
  --cell-empty: #fff9f3;
}

.moon-main { max-width: 720px; }

.title-moon { font-size: 2.4rem; line-height: 1; }

.subtitle {
  color: var(--muted);
  margin: 0.35rem 0 1.5rem;
  max-width: 60ch;
}

/* ---------- shared buttons ---------- */
button {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--btn);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.primary-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.primary-btn:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: var(--shadow-hover); }

/* ---------- toast ---------- */
.notice {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(0);
  background: #2b2440;
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 50;
  max-width: 90vw;
  text-align: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.notice.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(10px); }

.screen.hidden { display: none; }

/* ---------- cheat sheet ---------- */
.cheat-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  background: var(--btn);
  border: 2px solid var(--primary);
  color: var(--primary-dark);
  box-shadow: var(--shadow);
}
.cheat-btn:hover { background: var(--pick-bg); }

/* A side panel docked to the right — never covers the board, and the container
   lets clicks pass through to the tiles behind it. */
.cheat-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 1rem;
  pointer-events: none; /* clicks pass through to the board */
}
.cheat-modal.hidden { display: none; }
.cheat-card {
  pointer-events: auto; /* …but the panel itself is interactive */
  position: relative;
  background: var(--card);
  border: 2px solid var(--primary);
  border-radius: 18px;
  box-shadow: var(--shadow-hover);
  padding: 1.4rem 1.5rem;
  width: min(340px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}
.cheat-card h2 { margin: 0 0 0.5rem; font-size: 1.3rem; }
.cheat-card h3 { margin: 0.75rem 0 0.3rem; font-size: 0.95rem; color: var(--primary-dark); }
.cheat-lead { margin: 0 0 0.4rem; font-size: 0.95rem; }
.cheat-score { margin: 0.3rem 0 0; padding-left: 1.15rem; }
.cheat-score li { margin-bottom: 0.3rem; font-size: 0.9rem; line-height: 1.35; }
.cheat-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
}
.cheat-turn { margin: 0.2rem 0; padding-left: 1.1rem; }
.cheat-turn li { margin-bottom: 0.3rem; }
.cheat-note { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 0; }
.cheat-flowers { display: grid; gap: 0.55rem; }
.cf { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.9rem; line-height: 1.35; }
.cf .chip { margin-top: 0.05rem; }

/* ---------- lobby ---------- */
.lobby-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
}
.lobby-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 1.3rem;
  box-shadow: var(--shadow);
}
.lobby-card h2 { margin: 0 0 0.3rem; font-size: 1.15rem; }
.lobby-hint { color: var(--muted); margin: 0 0 1rem; font-size: 0.9rem; }
.lobby-or {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
  font-style: italic;
}
.field { display: block; margin-bottom: 0.8rem; }
.field span { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 0.3rem; }
.field input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--cell-empty);
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--primary); }
.lobby-card .primary-btn { width: 100%; }
.lobby-error { color: var(--primary-dark); font-weight: 600; min-height: 1.2rem; text-align: center; }

/* ---------- waiting ---------- */
.waiting-card, .finish-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.code-badge {
  display: inline-block;
  font-family: "Fredoka", sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--primary-dark);
  background: var(--pick-bg);
  border-radius: 14px;
  padding: 0.5rem 1.3rem;
  margin: 0.6rem 0 1.1rem;
}
.share-row { display: flex; gap: 0.5rem; max-width: 460px; margin: 0 auto; }
.share-row input {
  flex: 1;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--cell-empty);
  color: var(--muted);
}
.waiting-status { color: var(--muted); margin-top: 1.2rem; font-weight: 600; }
.dots::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

/* ---------- scoreboard ---------- */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}
.player-tag {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}
.player-tag.active { border-color: var(--primary); box-shadow: var(--shadow); }
#tag-opp { text-align: center; }
.pt-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pt-score { font-family: "Fredoka", sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }
.turn-banner {
  text-align: center;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--pick-bg);
  border-radius: 12px;
  padding: 0.5rem 0.4rem;
}
.turn-banner.theirs { background: var(--border); color: var(--muted); }

/* ---------- gardens ---------- */
.garden-block { margin-bottom: 1.1rem; }
.garden-block h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.garden {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 340px;
}
.garden.small { max-width: 200px; gap: 4px; opacity: 0.95; }
.me-block .garden { margin: 0 auto; }
.opp-block { text-align: center; }
.opp-block .garden { margin: 0 auto; }

.cell {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--cell-empty);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  user-select: none;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.garden.small .cell { font-size: 1.1rem; border-radius: 9px; }
.cell.lavender { background: var(--lavender-bg); border-color: var(--lavender); }
.cell.ivy { background: var(--ivy-bg); border-color: var(--ivy); }
.cell.sunflower { background: var(--sunflower-bg); border-color: var(--sunflower); }
.cell.moonflower { background: var(--moonflower-bg); border-color: var(--moonflower); }
.cell.plantable { cursor: pointer; border-style: dashed; border-color: var(--primary); }
.cell.plantable:hover { transform: translateY(-2px); box-shadow: var(--shadow); background: var(--pick-bg); }
.cell.just-placed { animation: pop 0.25s ease; }

/* hover a planted tile to see what it's currently worth */
.cell[data-tip] { position: relative; }
.cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 5px;
  background: #2b2440;   /* fixed dark — must NOT use var(--ink), which flips light in dark mode */
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 30;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ---------- moonpath ---------- */
.moonpath-block, .hand-block { margin-bottom: 1.1rem; }
.moonpath-block h3, .hand-block h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.block-hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.5rem; }
.hand-count { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.moonpath, .hand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 64px;
  padding: 0.5rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
}
.hand { background: linear-gradient(0deg, var(--pick-bg), var(--card)); }

/* The Moonpath looks like a moonlit garden lane; tiles are stepping stones. */
.moonpath {
  background: linear-gradient(160deg, #eef0ff 0%, #dfe3fb 100%);
  border: 2px dashed #c3c9ee;
  border-radius: 40px;
  box-shadow: inset 0 0 14px rgba(123, 138, 216, 0.14);
  align-items: center;
  justify-content: center;
}

.tile {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--cell-empty);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.tile.lavender { background: var(--lavender-bg); border-color: var(--lavender); }
.tile.ivy { background: var(--ivy-bg); border-color: var(--ivy); }
.tile.sunflower { background: var(--sunflower-bg); border-color: var(--sunflower); }
.tile.moonflower { background: var(--moonflower-bg); border-color: var(--moonflower); }
.tile.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile.selected { border-color: var(--primary); border-width: 3px; box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.tile.disabled { cursor: default; opacity: 0.85; }
.empty-note { color: var(--muted); font-style: italic; align-self: center; padding: 0 0.5rem; }

/* ---------- actions ---------- */
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.actions .primary-btn { flex: 1; min-width: 140px; }
#rest-btn { margin-left: auto; }
.log-line { color: var(--muted); font-size: 0.9rem; min-height: 1.4rem; font-style: italic; }

/* ---------- how-to ---------- */
.how-to {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.4rem 1.1rem;
  margin-top: 0.5rem;
}
.how-to summary { cursor: pointer; padding: 0.6rem 0; font-size: 1rem; }
.how-to ul { padding-left: 1.2rem; }
.how-to li { margin-bottom: 0.5rem; }
.legend { display: grid; gap: 0.6rem; margin: 0.6rem 0 1rem; }
.legend-item { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.92rem; line-height: 1.4; }
.chip {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  border: 2px solid var(--border);
}
.chip.lavender { background: var(--lavender-bg); border-color: var(--lavender); }
.chip.ivy { background: var(--ivy-bg); border-color: var(--ivy); }
.chip.sunflower { background: var(--sunflower-bg); border-color: var(--sunflower); }
.chip.moonflower { background: var(--moonflower-bg); border-color: var(--moonflower); }

/* ---------- finished ---------- */
.final-scores { display: grid; gap: 0.8rem; margin: 1.2rem 0; }
.fs-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
  background: var(--cell-empty);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem 1rem;
}
.fs-row.winner { border-color: var(--primary); background: var(--pick-bg); }
.fs-name { font-weight: 700; font-size: 1.05rem; text-align: left; }
.fs-total { font-family: "Fredoka", sans-serif; font-size: 1.8rem; font-weight: 700; color: var(--primary-dark); }
.fs-breakdown { grid-column: 1 / -1; display: flex; gap: 0.8rem; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.fs-breakdown span { white-space: nowrap; }
.finish-gardens { display: flex; gap: 1.4rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0; }
.finish-gardens .mini { text-align: center; }
.finish-gardens .mini h4 { margin: 0 0 0.4rem; font-size: 0.9rem; }

/* ---------- lavender, a touch more floral ---------- */
.cell.lavender, .tile.lavender, .chip.lavender {
  background: linear-gradient(155deg, #e6d8f6 0%, #c4a7e6 52%, #9d7ccc 100%);
  border-color: #8a6cb4;
}
/* ivy — soft green tile; the leaf glyph itself is darkened to read as deep ivy */
.cell.ivy, .tile.ivy, .chip.ivy {
  background: linear-gradient(160deg, #d8eede 0%, #aedbbd 100%);
  border-color: #3f8c5d;
}
.glyph, .ivy-mark { display: inline-block; line-height: 1; }
.ivy .glyph, .ivy-mark { filter: brightness(0.55) saturate(1.7) contrast(1.1); }
/* grass — a soft, light groundcover green, clearly lighter than ivy */
.cell.grass, .tile.grass, .chip.grass {
  background: linear-gradient(160deg, #eaf6d6 0%, #cae79f 100%);
  border-color: #c4dd96;
}

/* ---------- compact header in-game so the board fits without scrolling ---------- */
body[data-screen="game"] { padding-top: 1rem; padding-bottom: 1.2rem; }
body[data-screen="game"] .subtitle { display: none; }
body[data-screen="game"] .header { margin-bottom: 0.4rem; }
body[data-screen="game"] .title-moon { font-size: 1.5rem; }
body[data-screen="game"] h1 { font-size: 1.4rem; }

/* ---------- arena (two gardens, facing each other) + sidebar (scores + path) ---------- */
#screen-game:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
}
.game-arena { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }
.game-side  { display: flex; flex-direction: column; gap: 0.9rem; }

/* hand + action buttons live in the sidebar so they're always on screen */
.game-side .hand-block { text-align: center; margin: 0; }
.game-side .hand { justify-content: center; gap: 6px; }
.game-side .hand .tile { width: 46px; height: 46px; font-size: 1.4rem; }
.game-side .actions { flex-wrap: wrap; gap: 0.5rem; margin: 0; }
.game-side #confirm-btn, .game-side #reset-btn { flex: 1 1 100%; margin: 0; }
.game-side .log-line { margin: 0; text-align: center; font-size: 0.85rem; }

/* the two gardens stack and face each other; sized to stay big but fit the screen */
.game-arena .opp-block, .game-arena .me-block { text-align: center; margin: 0; }
/* a dividing line between the neighbor's garden (top) and yours (bottom) */
.game-arena .me-block { border-top: 2px dashed var(--border); padding-top: 0.8rem; }
/* "Your garden" label sits below your grid */
.game-arena .me-block h3 { margin: 0.5rem 0 0; }
.game-arena .garden { margin: 0 auto; max-width: min(440px, 92vw, 44vh); }
.game-arena .hand { justify-content: center; }
.game-arena .hand-block, .game-arena .log-line { text-align: center; }
.game-arena .log-line { margin: 0; }

/* compact scores: the two tags sit side by side, turn banner as a thin strip below */
.game-side .scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "opp me"
    "turn turn";
  gap: 0.4rem;
  margin: 0;
}
.game-side #tag-opp     { grid-area: opp; }
.game-side #tag-me      { grid-area: me; }
.game-side #turn-banner { grid-area: turn; }
.game-side .player-tag  { padding: 0.3rem 0.4rem; gap: 0; }
.game-side .pt-name     { font-size: 0.72rem; }
.game-side .pt-score    { font-size: 1.3rem; }
.game-side .turn-banner { font-size: 0.8rem; padding: 0.35rem; }

/* the Moonpath is a vertical moonlit lane in the sidebar; tiles are stepping stones */
.game-side .moonpath-block { text-align: center; margin: 0; }
.game-side .moonpath-block h3 { font-size: 0.9rem; }
.game-side .moonpath-block .block-hint { display: none; }
.game-side .moonpath {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  width: 84px;
  min-height: 220px;
  margin: 0 auto;
  border-radius: 56px;
}

@media (min-width: 760px) {
  .moon-main { max-width: 980px; }
  #screen-game:not(.hidden) {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.8rem;
  }
  .game-arena { flex: 1; }
  .game-side  {
    width: 252px;
    flex-shrink: 0;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .lobby-or { padding: 0.2rem 0; }
  .garden { max-width: 100%; }
  .tile { width: 46px; height: 46px; font-size: 1.4rem; }
}

/* solo (vs computer) option in the lobby */
.solo-divider { text-align: center; color: var(--muted); font-weight: 700; font-style: italic; font-size: 0.82rem; margin: 0.7rem 0 0.5rem; }
.solo-btn { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; }
.solo-btn:hover:not(:disabled) { filter: brightness(0.96); box-shadow: var(--shadow-hover); transform: translateY(-1px); }

/* difficulty toggle above the solo button */
.solo-level { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin: 0 0 0.6rem; }
.solo-level-label { font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.seg { display: inline-flex; border: 2px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--btn); }
.seg-btn { padding: 0.35rem 0.85rem; border: none; border-radius: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.seg-btn:hover { background: var(--pick-bg); }
.seg-btn.is-active { background: var(--primary); color: #fff; }

/* the other gardener's hand — backs in versus (count only), face-up in co-op */
.opp-hand { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 0.28rem; margin-top: 0.55rem; }
.opp-hand-label { font-size: 0.76rem; font-weight: 700; color: var(--muted); margin-right: 0.15rem; }
.oh-tile { width: 30px; height: 30px; font-size: 0.95rem; border-radius: 8px; flex-shrink: 0; }
.tile-back { display: flex; align-items: center; justify-content: center; border: 2px solid var(--card); background: linear-gradient(145deg, var(--moonflower) 0%, var(--lavender) 100%); box-shadow: var(--shadow); }
.tile-back .glyph { font-size: 0.8rem; opacity: 0.85; }

/* ---------- co-op (one shared garden) ---------- */
.mode-note { font-size: 0.8rem; color: var(--muted); margin: 0.55rem 0 0; line-height: 1.4; }
.coop-bar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: space-between;
  margin-bottom: 1.1rem; background: var(--card); border: 2px solid var(--border);
  border-radius: 16px; padding: 0.7rem 1.1rem; box-shadow: var(--shadow);
}
.coop-score-box { display: flex; flex-direction: column; align-items: center; }
.coop-score-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.coop-score-num { font-family: "Fredoka", sans-serif; font-size: 2rem; font-weight: 700; color: var(--primary-dark); line-height: 1; }
.coop-goal-box { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
.coop-tier { font-weight: 700; font-size: 1.05rem; }
.coop-goal { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.coop-bar .turn-banner { margin: 0; }

.coop-arena { display: flex; gap: 1.4rem; flex-wrap: wrap; align-items: flex-start; }
.coop-arena .garden-block { flex: 1 1 320px; }
.coop-garden { grid-template-columns: repeat(6, 1fr); max-width: 408px; margin: 0 auto; }
.coop-garden.small { max-width: 264px; }

.partner-block { opacity: 0.95; }
.partner-block .hand .tile { cursor: default; }
.coop-best-line { text-align: center; color: var(--muted); font-weight: 600; margin: 0.5rem 0 0; }
