/* tidecaller-r4: filled buttons use --bg on --accent so the label stays readable. Panel text stays --ink. tidecaller-r3.css stays in place. */
:root {
  --tc-water: #4a9abe;
  --tc-water-dark: #2d5f78;
  --tc-land: #8b9d7a;
  --tc-boat: #d4a574;
  --tc-fish: #e8a040;
  --tc-ui-bg: rgba(255, 255, 255, 0.95);
  --tc-ui-text: #1a1a1a;
}

[data-theme="dark"] {
  --tc-water: #1a3a4a;
  --tc-water-dark: #0d1f28;
  --tc-land: #6d8a55;
  --tc-boat: #e0b27a;
  --tc-fish: #f0b15a;
  --tc-ui-bg: rgba(20, 24, 28, 0.94);
  --tc-ui-text: #e8e8e8;
}

.tc-page {
  background: var(--tc-water);
  transition: background 0.2s;
}

header.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: max(0.35rem, env(safe-area-inset-top));
  padding-bottom: 0.35rem;
  background: var(--bg);
  z-index: 40;
}

header.top h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
  flex: 1;
}

#stage {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 4.5rem;
  width: auto;
  max-width: none;
  height: auto;
  aspect-ratio: auto;
  margin: 0;
  background: var(--tc-water-dark);
  border-radius: 0;
  overflow: hidden;
  touch-action: none;
  z-index: 5;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(44px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
  background: color-mix(in srgb, var(--tc-ui-bg) 88%, transparent);
}

#stage.menu #hud { visibility: hidden; }

.stat {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  color: var(--tc-ui-text);
  font-size: 0.85rem;
  white-space: nowrap;
  height: 44px;
  min-height: 44px;
  pointer-events: none;
}

.stat .k {
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.75;
}

.stat b {
  font-size: 0.95rem;
  font-weight: 700;
}

.gap { flex: 1; min-width: 0; height: 44px; }

.hud-btn {
  background: var(--tc-ui-bg);
  color: var(--tc-ui-text);
  border: 0;
  min-width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  flex: 0 0 auto;
}

.cast-btn { min-width: 64px; }

#toast {
  position: absolute;
  left: 50%;
  top: calc(52px + env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--tc-ui-bg);
  color: var(--tc-ui-text);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
  max-width: min(92%, 420px);
  text-align: center;
}

#toast.show { opacity: 1; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.overlay.open { display: flex; }

.panel {
  background: var(--bg, #f4f7f8);
  color: var(--ink);
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 520px;
  width: 100%;
  margin: 0 auto 12px;
}

.kicker {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  margin: 0 0 0.35rem;
}

.panel h2 { font-size: 1.6rem; margin: 0 0 0.6rem; }

.sub { font-size: 1rem; line-height: 1.5; margin: 0 0 1rem; }

.actions, .shop-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.actions button, .shop-actions button, .upgrade-btn {
  min-height: 44px;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--accent, #1f6f6a);
  background: var(--accent, #1f6f6a);
  color: var(--bg);
  border-radius: 8px;
  cursor: pointer;
}

.actions button.ghost {
  background: transparent;
  color: inherit;
  border-color: color-mix(in srgb, currentColor 35%, transparent);
}

.actions .games-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  justify-content: center;
  color: inherit;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
}

.howto { margin: 0; padding-left: 1.2rem; line-height: 1.45; }
.howto li { margin: 0.4rem 0; }

.upgrades { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }

.upgrade-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
  border-radius: 8px;
}

.upgrade-name { font-weight: 700; }
.upgrade-desc { font-size: 0.85rem; opacity: 0.75; }
.upgrade-btn { white-space: nowrap; }
.upgrade-btn:disabled, .shop-actions button:disabled {
  opacity: 1;
  background: var(--muted);
  color: var(--bg);
  border-color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 900px), (max-height: 500px) {
  header.wrap.top { display: none; }
  #stage { top: 0; height: 100dvh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0s !important; }
}
