:root {
  color-scheme: dark;
  --ink: #ecfeff;
  --muted: #a7f3d0;
  --panel: rgba(7, 47, 61, 0.82);
  --panel-strong: rgba(8, 77, 92, 0.94);
  --line: rgba(165, 243, 252, 0.24);
  --gold: #fde68a;
  --green: #86efac;
  --bad: #fda4af;
  --water: #0e7490;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(125, 211, 252, 0.32), transparent 28rem),
    radial-gradient(circle at 80% 5%, rgba(45, 212, 191, 0.22), transparent 24rem),
    linear-gradient(160deg, #063142 0%, #042f2e 55%, #111827 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: repeating-radial-gradient(circle at 50% 0%, transparent 0 23px, rgba(186, 230, 253, 0.22) 24px 25px, transparent 26px 54px);
  mask-image: linear-gradient(#000, transparent 85%);
}

.shell {
  width: min(94vw, 680px);
  margin: 0 auto;
  padding: 18px 0 32px;
  position: relative;
}

.top-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.top-links a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 800;
  padding: 8px 12px;
  border: 1px solid rgba(253, 230, 138, 0.35);
  border-radius: 999px;
  background: rgba(8, 47, 73, 0.58);
}

.hero { text-align: center; padding: 12px 10px 6px; }
.eyebrow, .label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
  font-weight: 800;
}

h1 {
  margin: 4px 0;
  font-size: clamp(2.35rem, 13vw, 4.6rem);
  line-height: 0.92;
  text-shadow: 0 8px 36px rgba(15, 23, 42, 0.55);
}

h2 { margin: 4px 0 8px; font-size: 1.25rem; }
.lede { margin: 0 auto; max-width: 42rem; color: #cffafe; font-size: 1.05rem; }

.panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.scorebar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.scorebar strong { display: block; font-size: 1.25rem; }

.puzzle-card { background: linear-gradient(180deg, var(--panel-strong), rgba(7, 47, 61, 0.74)); }
.puzzle-copy { text-align: center; }
.puzzle-copy p { margin: 0 0 14px; color: #cffafe; }

.board {
  display: grid;
  grid-template-columns: 42px repeat(5, minmax(42px, 1fr));
  gap: 7px;
  align-items: stretch;
  max-width: 540px;
  margin: 0 auto;
}

.clue, .cell, .corner {
  min-height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
}
.corner { opacity: 0; }

.clue {
  border: 1px solid rgba(165, 243, 252, 0.24);
  background: rgba(15, 23, 42, 0.38);
  color: #bae6fd;
  line-height: 1.05;
}
.clue small { display: block; font-size: 0.66rem; opacity: 0.82; }
.clue.good { color: #14532d; background: linear-gradient(180deg, #fde68a, #86efac); }
.clue.hot { color: #7f1d1d; background: rgba(253, 164, 175, 0.2); border-color: rgba(253, 164, 175, 0.55); }

.cell {
  position: relative;
  min-height: clamp(48px, 13vw, 70px);
  border: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 48%, rgba(186, 230, 253, 0.24), transparent 46%),
    linear-gradient(145deg, rgba(14, 116, 144, 0.92), rgba(8, 145, 178, 0.6));
  box-shadow: inset 0 0 0 1px rgba(207, 250, 254, 0.18), inset 0 -14px 26px rgba(8, 47, 73, 0.45);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}
.cell:hover, .cell:focus-visible { transform: translateY(-2px); outline: none; box-shadow: 0 0 0 3px rgba(253, 230, 138, 0.34), inset 0 0 0 1px rgba(207, 250, 254, 0.18); }
.cell.rock { cursor: not-allowed; color: #d9f99d; background: linear-gradient(145deg, rgba(20, 83, 45, 0.8), rgba(63, 98, 18, 0.72)); }
.cell.rock::after { content: "♒"; font-size: 1.45rem; opacity: 0.9; }
.cell.pebble { background: radial-gradient(circle, rgba(253, 230, 138, 0.95) 0 20%, rgba(20, 184, 166, 0.7) 21% 45%, rgba(8, 145, 178, 0.5) 46%); }
.cell.pebble::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff7ed, #a16207 38%, #422006 82%);
  box-shadow: 0 0 0 10px rgba(253, 230, 138, 0.16), 0 0 0 19px rgba(125, 211, 252, 0.11);
}
.cell.flash { animation: ripple 540ms ease; }
@keyframes ripple { 0% { filter: brightness(1.6); transform: scale(0.97); } 100% { filter: brightness(1); transform: scale(1); } }

.legend { margin: 12px 0 0; text-align: center; color: #cffafe; font-size: 0.9rem; }
.legend-pebble { color: var(--gold); }
.legend-rock { color: #bef264; }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
button {
  border: 0;
  border-radius: 16px;
  padding: 13px 10px;
  color: #042f2e;
  background: linear-gradient(180deg, #fde68a, #facc15);
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}
button.secondary { color: var(--ink); background: rgba(15, 118, 110, 0.58); border: 1px solid rgba(153, 246, 228, 0.28); }
button[hidden] { display: none; }
button:active { transform: translateY(1px); }

.message { margin: 0; text-align: center; color: #e0f2fe; font-weight: 800; }
.message.win { color: var(--gold); }
.message.warn { color: var(--bad); }
.how ul { margin: 10px 0 0; padding-left: 20px; color: #d1fae5; }
.how li + li { margin-top: 6px; }

@media (max-width: 560px) {
  .panel { padding: 13px; border-radius: 20px; }
  .board { grid-template-columns: 34px repeat(5, 1fr); gap: 5px; }
  .clue, .cell, .corner { min-height: 40px; border-radius: 12px; font-size: 0.92rem; }
  .controls { grid-template-columns: 1fr 1fr; }
}
