:root {
  --bg: #16221c;
  --bg-soft: #1c2c24;
  --panel: #203025;
  --line: #2c3f33;
  --ink: #eef3ee;
  --ink-soft: #9fb3a6;
  --accent: #8fd6c4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body.tideweave-page {
  background:
    radial-gradient(120% 80% at 50% -10%, #1f3027 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.tide-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.tide-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
}

.tide-top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  width: 34px;
  height: 30px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.icon-button[aria-pressed="true"] {
  opacity: 0.6;
}

.tide-head {
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.tide-head h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.tide-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 10px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-item small {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hud-item span {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-item span i {
  font-style: normal;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.85rem;
}

.tide-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.tide-board {
  display: grid;
  gap: 3px;
  padding: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 18px;
  touch-action: manipulation;
}

.tide-cell {
  border-radius: 5px;
  transition: background 0.18s ease;
}

.tide-cell.tide-origin {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.tide-solved {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  background: rgba(16, 34, 28, 0.86);
  border-radius: 18px;
  backdrop-filter: blur(2px);
}

/* `hidden` 属性必须胜过上面的 display，否则胜利横幅会常驻显示。 */
.tide-solved[hidden] {
  display: none;
}

.tide-solved h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--accent);
}

.tide-solved p {
  margin: 0;
  max-width: 22em;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.tide-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.tide-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.tide-swatch {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  position: relative;
}

.tide-swatch.tide-available {
  box-shadow: 0 0 0 3px rgba(143, 214, 196, 0.35);
}

.tide-swatch.tide-current {
  cursor: default;
  opacity: 0.45;
}

.tide-swatch:disabled {
  cursor: default;
}

.tide-swatch:not(:disabled):hover {
  transform: translateY(-2px) scale(1.04);
}

.tide-swatch:not(:disabled):active {
  transform: scale(0.96);
}

.tide-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--accent);
  color: #10231c;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

.button[hidden] {
  display: none;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 8px 10px;
}

.text-button:hover {
  color: var(--ink);
}

.tide-foot {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.74rem;
}

@media (max-width: 380px) {
  .tide-swatch {
    width: 42px;
    height: 42px;
  }
  .tide-head h1 {
    font-size: 1.15rem;
  }
}
