.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-bottom: 48px;
}
.game-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 18px;
}
.hud, .mode-switch { display: flex; gap: 8px; align-items: center; }
.hud { justify-content: space-between; margin-bottom: 12px; }
.hud p, .mode-switch { color: var(--muted); font-size: 0.85rem; }
.hud strong { color: var(--text); font-size: 1.4rem; margin-left: 6px; }
.mode-switch { margin-bottom: 12px; }
.mode-switch button, .game-actions button { min-height: 44px; }
.mode-switch button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
}
.mode-switch button[aria-selected="true"] {
  background: var(--lime);
  color: var(--lime-ink);
  border-color: transparent;
}
.game-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.status-line { min-height: 3.2em; color: var(--muted); margin-top: 12px; }

.pearl-board, .memory-board, .tide-grid, .signal-pads { display: grid; gap: 10px; }
.pearl-board { grid-template-columns: repeat(3, 1fr); }
.memory-board { grid-template-columns: repeat(4, 1fr); }
.tide-grid { grid-template-columns: repeat(4, 1fr); }
.signal-pads { grid-template-columns: 1fr 1fr; }

.pearl-cell, .memory-card, .tide-cell, .pad {
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #0c2230;
  color: var(--text);
  touch-action: manipulation;
  transition: transform 120ms var(--ease, ease), background 160ms ease, border-color 160ms ease;
}
.pearl-cell:active, .memory-card:active, .tide-cell:active, .pad:active {
  transform: scale(0.97);
}
.pearl-cell { display: grid; align-content: center; justify-items: center; gap: 2px; }
.pearl-cell small { color: var(--muted); font-size: 0.72rem; }
.pearl-cell b { font-size: 1.6rem; line-height: 1; }
.pearl-cell[data-kind="pearl"] { background: #14584d; border-color: var(--mint); color: var(--gold); }
.pearl-cell[data-kind="coral"] { background: #5a2e32; border-color: var(--coral); color: var(--coral); }
.pearl-cell:disabled { opacity: 0.85; }

.memory-card { font-size: 1.8rem; font-weight: 750; color: var(--mint); }
.memory-card svg { width: 48px; height: 48px; margin: auto; }
.memory-card[data-state="closed"] { color: #8eb0b4; }
.memory-card[data-state="open"] { background: #123746; border-color: #3e7480; }
.memory-card[data-state="matched"] {
  background: #14584d;
  border-color: var(--mint);
  color: var(--mint);
  animation: match-settle 420ms var(--ease, ease);
}

.tide-cell { font-size: 1.8rem; font-weight: 750; background: #1d4a28; color: #d7f5a4; }
.tide-cell[data-on="true"] { background: var(--lime); color: var(--lime-ink); border-color: transparent; }
.tide-cell[data-on="false"] { background: #143022; color: #6ea37a; }

.pad { font-weight: 750; font-size: 1.1rem; }
.pad[data-pad="0"] { background: #14685f; }
.pad[data-pad="1"] { background: #8a6a22; }
.pad[data-pad="2"] { background: #8a3d42; }
.pad[data-pad="3"] { background: #4d3d93; }
.pad[data-lit="true"] { filter: brightness(1.45); outline: 3px solid white; }

.how-card h2 { margin: 8px 0 12px; }
.how-card p + p { margin-top: 10px; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.keys kbd { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--muted); }

.mode-switch .mode-switch-btn,
.mode-switch button[data-proto] {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
}
.mode-switch .mode-switch-btn[aria-selected="true"],
.mode-switch button[data-proto][aria-selected="true"] {
  background: var(--lime);
  color: var(--lime-ink);
  border-color: transparent;
}

.latch-meter { margin: 18px 0 8px; }
.latch-track {
  position: relative;
  height: 28px;
  border-radius: 999px;
  background: #0a1c26;
  border: 1px solid var(--line);
  overflow: hidden;
}
.latch-band {
  position: absolute;
  top: 0; bottom: 0;
  background: #8ef6c955;
  border-left: 2px solid var(--mint);
  border-right: 2px solid var(--mint);
}
.latch-needle {
  position: absolute;
  left: 0; /* start position; was an inline style the CSP blocks */
  top: 2px; bottom: 2px;
  width: 4px;
  margin-left: -2px;
  border-radius: 4px;
  background: var(--gold);
}

.echo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.echo-cell {
  min-height: 84px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #0c2230;
  color: var(--text);
  touch-action: manipulation;
}
.echo-cell[data-lit="true"] {
  background: #14584d;
  border-color: var(--mint);
  box-shadow: inset 0 0 0 2px #8ef6c9aa;
}

.sort-row, .fold-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.sort-shell, .fold-cell {
  min-height: 96px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #123746;
  color: var(--mint);
  font-size: 1.8rem;
  font-weight: 800;
  touch-action: manipulation;
}
.sort-shell[aria-pressed="true"] {
  background: var(--lime);
  color: var(--lime-ink);
  border-color: transparent;
}
.fold-cell[data-on="true"] {
  background: var(--lime);
  color: var(--lime-ink);
  border-color: transparent;
}
.fold-cell[data-on="false"] {
  background: #143022;
  color: #6ea37a;
}
.pulse-band {
  background: #c7b4ff55;
  border-left-color: var(--violet);
  border-right-color: var(--violet);
}
#proto-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 148px;
  overflow: auto;
  padding-bottom: 4px;
}
.proto-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: end;
  margin-bottom: 12px;
}
.proto-toolbar label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.proto-toolbar input {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid #3d6470;
  background: #0c1c26;
  padding: 10px 12px;
}
.proto-toolbar .result-count {
  min-height: 48px;
  display: grid;
  align-items: center;
  margin: 0;
}
.stack-lanes, .balance-pans {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.stack-lanes { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.balance-pans { grid-template-columns: 1fr 1fr; }
.stack-lane, .balance-pan {
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #123746;
  color: var(--mint);
  font-size: 1.4rem;
  font-weight: 800;
  touch-action: manipulation;
}
.stack-lane:disabled, .balance-pan:disabled { opacity: 0.45; }
.balance-pan {
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
}
.balance-pan strong { font-size: 2.2rem; letter-spacing: -0.04em; }
.orbit-ring {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.orbit-cell {
  min-height: 72px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #0c2230;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
}
.orbit-cell[data-target="true"] {
  border-color: var(--violet);
  color: var(--violet);
  box-shadow: inset 0 0 0 2px #c7b4ff66;
}
.orbit-cell[data-marker="true"] {
  background: #14584d;
  border-color: var(--mint);
  color: var(--mint);
}
.brew-vials, .mask-row {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.brew-vials { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mask-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.brew-vial, .mask-face {
  min-height: 96px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #123746;
  color: var(--mint);
  font-weight: 800;
  touch-action: manipulation;
}
.brew-vial {
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
}
.brew-vial strong { font-size: 1.6rem; }
.brew-vial:disabled { opacity: 0.45; }
.mask-face {
  display: grid;
  place-items: center;
  font-size: 2rem;
}
.mask-preview {
  grid-column: 1 / -1;
  background: #14584d;
  border-color: var(--mint);
}
.shear-tile[data-kind="1"] { color: var(--mint); }
.shear-tile[data-kind="2"] { color: var(--coral); }
.shear-tile[data-kind="3"] { color: var(--gold); }
.guard-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.guard-post {
  min-height: 96px;
  border-radius: 12px;
  border: 1px solid #2c5560;
  background: #123746;
  color: var(--muted);
  font-size: 2rem;
  font-weight: 800;
  touch-action: manipulation;
}
.guard-post[data-threat="true"] {
  background: #5a2e32;
  border-color: var(--coral);
  color: var(--coral);
}
.guard-post[data-blocked="true"] {
  background: #14584d;
  border-color: var(--mint);
  color: var(--mint);
}
.mirror-tile[data-kind="0"] { color: var(--muted); }
.mirror-tile[data-kind="1"] { color: var(--mint); background: #14584d; border-color: var(--mint); }
@media (prefers-reduced-motion: reduce) {
  .latch-needle { transition: none; }
}

@keyframes match-settle {
  0% { transform: scale(0.94); }
  55% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (max-width: 860px) {
  .game-shell { grid-template-columns: 1fr; }
  .memory-board { grid-template-columns: repeat(3, 1fr); }
  .pearl-cell, .memory-card, .tide-cell, .pad, .echo-cell, .sort-shell, .fold-cell { min-height: 72px; }
  .sort-row, .fold-row { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .proto-toolbar {
    grid-template-columns: 1fr;
  }
  .proto-toolbar .result-count {
    min-height: 0;
  }
  #proto-picker {
    max-height: 120px;
  }
}
@media (max-width: 380px) {
  .memory-board { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .pearl-cell, .memory-card, .tide-cell, .pad { transition: none; }
  .pearl-cell:active, .memory-card:active, .tide-cell:active, .pad:active { transform: none; }
  .memory-card[data-state="matched"] { animation: none; }
}
.reduce-motion .pearl-cell,
.reduce-motion .memory-card,
.reduce-motion .tide-cell,
.reduce-motion .pad {
  transition: none !important;
  animation: none !important;
}
.reduce-motion .pearl-cell:active,
.reduce-motion .memory-card:active,
.reduce-motion .tide-cell:active,
.reduce-motion .pad:active {
  transform: none !important;
}

/* Pearl Gamble */
.gamble-well {
  display: grid; gap: 6px; margin: 12px 0; padding: 18px;
  border-radius: 12px; border: 1px solid #2c5560;
  background: linear-gradient(180deg, #123746 0%, #0a2230 100%);
}
.gamble-well p { margin: 0; }
.gamble-depth strong, .gamble-haul strong { color: var(--gold); font-size: 1.4rem; }
.gamble-risk strong { color: var(--coral); }

/* Pearl Gamble water column */
.gamble-column { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 2px; }
.gamble-row {
  display: grid; grid-template-columns: 64px 1fr; align-items: center; min-height: 30px;
  border-radius: 8px; padding: 0 8px; background: rgba(142, 246, 201, 0.04);
}
.gamble-row:nth-child(n+4) { background: rgba(10, 34, 48, 0.6); }
.gamble-row:nth-child(n+7) { background: rgba(4, 14, 22, 0.8); }
.gamble-mark { color: var(--muted); font-size: 0.75rem; }
.gamble-art { display: block; width: 28px; height: 28px; }
.gamble-row.is-here { outline: 2px solid var(--mint); }
.gamble-row.is-here .gamble-art { width: 34px; height: 34px; }
.gamble-row.is-eel { background: rgba(122, 92, 255, 0.25); }
.gamble-row.is-eel .gamble-art { width: 48px; }

/* Shell Sets */
.sets-offer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.sets-shell {
  display: grid; justify-items: center; gap: 4px; min-height: 112px; padding: 10px 6px;
  border-radius: 14px; border: 2px solid #2c5560; background: #123746;
  font: inherit; font-weight: 800; text-transform: capitalize;
  touch-action: manipulation; cursor: pointer;
}
.sets-shell .sprite { width: 64px; height: 64px; }
.sets-shell span { color: var(--text); }
.sets-shell:hover { border-color: currentColor; }
.shell-mint { color: var(--mint); }
.shell-coral { color: var(--coral); }
.shell-gold { color: var(--gold); }
.shell-violet { color: var(--violet); }
.sets-tray { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sets-tray-row { display: flex; align-items: center; gap: 2px; min-height: 28px; }
.sets-tray-row .sprite { width: 26px; height: 26px; }
.sets-tray-name { width: 56px; color: var(--muted); font-size: 0.78rem; text-transform: capitalize; }

/* ---------- Shared sprites (js/sprites.js) ---------- */
.sprite { display: block; width: 100%; height: 100%; }
.tile-art-slot { display: grid; place-items: center; width: 40px; height: 40px; }
.pearl-cell b.tile-art-slot { font-size: 0; }
.pearl-cell[data-kind="pearl"] .sprite-pearl { animation: sprite-pop 0.25s var(--ease) both; }
.pearl-cell[data-kind="coral"] .sprite-coral { animation: sprite-pop 0.25s var(--ease) both; }
@keyframes sprite-pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sprite { animation: none !important; } }
html.reduce-motion .sprite { animation: none !important; }
@media (max-width: 600px) {
  .gamble-row { min-height: 24px; }
  .gamble-art { width: 22px; height: 22px; }
  .gamble-row.is-here .gamble-art { width: 28px; height: 28px; }
}

/* ---------- Pearl Gamble (full game) ---------- */
.gamble-app { display: grid; gap: 18px; padding-bottom: 24px; }
.gamble-wallet { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; }
.gamble-wallet p { margin: 0; display: grid; }
.gamble-wallet strong { font-size: 1.8rem; color: var(--gold); }
.gamble-daily { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.gamble-daily h2 { margin: 4px 0; font-size: 1.4rem; }
.gamble-daily p { margin: 0; }
.gamble-subhead { margin: 10px 0 0; font-size: 1.3rem; }
.gamble-reefs, .gamble-shop { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gamble-reef {
  display: grid; gap: 6px; align-content: start; padding: 18px;
  border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, #0f2a38, #0a1d28);
}
.gamble-reef h3, .gamble-reef p, .gamble-item h3, .gamble-item p { margin: 0; }
.gamble-reef > p:not(.eyebrow):not(.gamble-reef-stars):not(.gamble-reef-meta) { color: var(--muted); font-size: 0.92rem; }
.gamble-reef-stars { color: var(--gold); font-size: 1.3rem; letter-spacing: 2px; }
.gamble-reef-meta { color: var(--muted); font-size: 0.8rem; }
.gamble-reef .button { justify-self: start; margin-top: 6px; }
.gamble-reef.is-locked { opacity: 0.55; }
.gamble-item { display: grid; gap: 6px; }
.gamble-item p { color: var(--muted); font-size: 0.92rem; }
.gamble-level { color: var(--mint) !important; letter-spacing: 3px; }
.gamble-help ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.gamble-help summary { cursor: pointer; font-weight: 700; }

.gamble-board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.gamble-run .gamble-column { margin: 0; }
.gamble-row { grid-template-columns: 64px 1fr 36px; }
.gamble-val { color: var(--muted); font-size: 0.75rem; text-align: right; }
.gamble-row.is-done .gamble-val { color: var(--gold); }
.gamble-side { display: grid; gap: 8px; }
.gamble-side p { margin: 0; }
.gamble-haul strong { color: var(--gold); font-size: 2rem; }
.gamble-risk strong { color: var(--coral); font-size: 1.3rem; }
.gamble-peek { padding: 8px 12px; border-radius: 10px; font-weight: 700; }
.gamble-peek[data-kind="safe"] { background: rgba(142, 246, 201, 0.15); color: var(--mint); }
.gamble-peek[data-kind="eel"] { background: rgba(255, 143, 120, 0.18); color: var(--coral); }
.gamble-actions .button { min-width: 140px; }
.gamble-quit { justify-self: start; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.gamble-result { display: grid; gap: 10px; justify-items: start; }
.gamble-result h2, .gamble-result p { margin: 0; }
.gamble-res-stars { font-size: 2.4rem; color: var(--gold); letter-spacing: 4px; }
@media (max-width: 720px) {
  .gamble-board { grid-template-columns: 1fr; }
  .gamble-side { order: -1; }
}
