:root {
  --ink: #0f2740;
  --muted: #5b738c;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(255, 255, 255, 0.55);
  --accent: #00b4d8;
  --accent-2: #0077b6;
  --coral: #ff6b6b;
  --sand: #ffd166;
  --forest: #2ec4b6;
  --mountain: #8d99ae;
  --water-1: #48cae4;
  --water-2: #0077b6;
  --safe: #ffb703;
  --font-d: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  --font-b: "Noto Sans SC", system-ui, sans-serif;
  --hex-size: 28px;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(8, 40, 70, 0.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-b);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  background: #e8f6fc;
}
.scene {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 70% 45% at 15% -5%, rgba(72, 202, 228, 0.45), transparent 55%),
    radial-gradient(ellipse 55% 40% at 90% 10%, rgba(0, 180, 216, 0.28), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(46, 196, 182, 0.2), transparent 55%),
    linear-gradient(165deg, #f3fbff 0%, #dff3fa 45%, #cceef8 100%);
}
.topbar {
  max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 0.4rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.back {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 119, 182, 0.15);
}
.brand { display: flex; gap: 0.75rem; align-items: center; flex: 1; }
.mark {
  width: 2.75rem; height: 2.75rem; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #90e0ef, #00b4d8);
  color: #023e8a; font-family: var(--font-d); font-size: 1.3rem;
  box-shadow: 0 8px 20px rgba(0, 180, 216, 0.35);
}
.brand h1 {
  margin: 0; font-family: var(--font-d); font-size: 1.55rem;
  color: var(--ink); letter-spacing: 0.02em;
}
.brand p { margin: 0; font-size: 0.85rem; color: var(--muted); }
main { max-width: 1280px; margin: 0 auto; padding: 0.5rem 1.25rem 2.8rem; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.4rem 1.35rem;
  max-width: 440px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 0.9rem; font-family: var(--font-d); font-size: 1.75rem; color: var(--ink); }
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 0.5rem; }
.row input {
  flex: 1; border: 1px solid #c5dde8; border-radius: 14px;
  padding: 0.7rem 0.9rem; font: inherit; background: #fff;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.2);
}
.name-list { list-style: none; margin: 0.8rem 0; padding: 0; display: grid; gap: 0.35rem; }
.name-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.55rem 0.75rem; background: #eef9fc; border-radius: 12px; font-weight: 700;
}
.name-list button {
  border: 0; background: transparent; color: var(--coral);
  cursor: pointer; font: inherit; font-weight: 700;
}
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.75rem 0 0; }

.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 700;
  border-radius: 14px; padding: 0.7rem 1.2rem;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(145deg, #48cae4, #0077b6);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 119, 182, 0.28);
}
.btn.secondary {
  background: #fff; color: var(--ink);
  border: 1px solid #c5dde8;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent-2);
  border: 1px solid rgba(0, 119, 182, 0.18);
}
.btn.wide { width: 100%; margin-top: 0.45rem; }

.layout { display: grid; gap: 1rem; }
@media (min-width: 1100px) { .layout { grid-template-columns: 1fr 260px; align-items: start; } }

.status {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  padding: 0;
}
.status > span {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(8, 40, 70, 0.06);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}
.status strong { color: var(--ink); font-size: 1.05rem; }

.board-wrap {
  margin-top: 0.75rem;
  overflow: auto;
  border-radius: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(72, 202, 228, 0.35), transparent 70%),
    linear-gradient(180deg, #90e0ef 0%, #48cae4 40%, #0096c7 100%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  max-width: 100%;
}
.board {
  position: relative;
  margin: 0.65rem auto;
}

.hex {
  position: absolute;
  width: calc(var(--hex-size) * 1.732);
  height: calc(var(--hex-size) * 2);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: default;
  transition: transform 0.15s, filter 0.15s;
  border: 0;
  padding: 0;
  font: inherit;
  color: #fff;
}
.hex::after {
  content: "";
  position: absolute;
  inset: 2px;
  clip-path: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.hex.water {
  background: linear-gradient(165deg, #7bdff2, #00a8e8);
}
.hex.beach {
  background: linear-gradient(165deg, #ffe8a3, #ffd166);
  color: #5c4810;
}
.hex.forest {
  background: linear-gradient(165deg, #80ed99, #2ec4b6);
}
.hex.mountain {
  background: linear-gradient(165deg, #cfd6e0, #8d99ae);
}
.hex.safe {
  background: linear-gradient(165deg, #ffe566, #ffb703);
  color: #5c3d00;
}
.hex.sunk {
  background: linear-gradient(165deg, #5ec8f0, #1a8fc4);
  opacity: 1;
}
.hex.valid {
  cursor: pointer;
  z-index: 5;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.85));
  animation: hexPulse 1.1s ease-in-out infinite;
}
@keyframes hexPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
.hex-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: center;
  align-items: flex-end;
  max-width: 92%;
  pointer-events: none;
}
.hex-stack > * { pointer-events: auto; }

.hex .meeple {
  gap: 0;
  cursor: pointer;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
}
.hex .meeple .meeple-fig {
  width: 1.05rem;
  height: 1.25rem;
}
.hex .meeple .meeple-name { display: none; }
.hex .meeple.hidden-score .meeple-fig::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.58rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  z-index: 1;
}
.hex .meeple.revealed .meeple-fig {
  display: grid;
  place-items: center;
  -webkit-mask: none;
  mask: none;
  border-radius: 5px;
  width: 1rem;
  height: 1rem;
  font-size: 0.58rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}
.hex .meeple.is-sel {
  filter: drop-shadow(0 0 6px #fff) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
  transform: translateY(-4px);
}
.hex .meeple.swimming {
  animation: swimBob 1.4s ease-in-out infinite;
}
.hex .meeple.swimming::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 0.9rem;
  height: 0.28rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}
@keyframes swimBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.boat-token {
  --b: #c77d3a;
  position: relative;
  width: 1.55rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
}
.boat-token::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 0;
  height: 52%;
  background: linear-gradient(180deg, #e9b872, var(--b));
  clip-path: polygon(0 0, 100% 0, 90% 100%, 10% 100%);
  border-radius: 2px;
}
.boat-token::after {
  content: "";
  position: absolute;
  left: 44%;
  top: -1px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 13px solid #f8fafc;
}
.boat-token.is-sel {
  filter: drop-shadow(0 0 6px #fff) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
  transform: translateY(-2px);
}
.boat-token .boat-cap {
  position: absolute;
  right: -4px;
  top: -8px;
  min-width: 1.1rem;
  padding: 0 3px;
  border-radius: 6px;
  font-size: 0.52rem;
  font-weight: 900;
  color: #023e8a;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  z-index: 2;
}

.creature-tok {
  font-size: 0.95rem;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
  animation: floaty 2.2s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.msg {
  text-align: center;
  font-family: var(--font-d);
  font-size: 1.4rem;
  color: var(--accent-2);
  min-height: 1.5em;
  margin: 0.85rem 0 0.15rem;
}
.submsg {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 1.25em;
  margin: 0 0 0.55rem;
}
.controls {
  display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; min-height: 2.8rem;
}
.legend {
  display: flex; flex-wrap: wrap; gap: 0.45rem 0.75rem; justify-content: center;
  margin-top: 0.7rem; font-size: 0.8rem; color: var(--muted);
}
.legend span {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}
.legend i.lg {
  display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 3px;
}
.lg.beach { background: var(--sand); }
.lg.forest { background: var(--forest); }
.lg.mountain { background: var(--mountain); }
.lg.safe { background: var(--safe); }
.lg.water { background: var(--water-2); }

.side {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.1rem;
  color: var(--ink);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0.6rem;
}
.side h2 { margin: 0; font-family: var(--font-d); font-size: 1.35rem; }
.scores { list-style: none; margin: 0.75rem 0; padding: 0; display: grid; gap: 0.4rem; }
.scores li {
  display: grid; grid-template-columns: 1fr auto; gap: 0.15rem;
  padding: 0.55rem 0.7rem;
  background: #f0fafc;
  border-radius: 14px;
  border-left: 4px solid transparent;
}
.scores li.is-turn {
  background: #e6f7fb;
  box-shadow: inset 0 0 0 1px rgba(0, 180, 216, 0.35);
}
.scores li.c0 { border-left-color: #e03131; }
.scores li.c1 { border-left-color: #1c7ed6; }
.scores li.c2 { border-left-color: #2f9e44; }
.scores li.c3 { border-left-color: #e8590c; }
.scores .nm { font-weight: 700; display: flex; align-items: center; gap: 0.3rem; }
.scores .pts { font-weight: 800; font-size: 1.25rem; color: var(--accent-2); }
.scores .sub { grid-column: 1 / -1; font-size: 0.78rem; color: var(--muted); }
.rules { border-top: 1px solid #d7eaf2; padding-top: 0.7rem; }
.rules .t { margin: 0 0 0.35rem; font-weight: 700; }
.rules ul {
  margin: 0; padding-left: 1.05rem;
  font-size: 0.84rem; color: var(--muted); line-height: 1.5;
}
.meeple-sm.c0 { --m: #e03131; }
.meeple-sm.c1 { --m: #1c7ed6; }
.meeple-sm.c2 { --m: #2f9e44; }
.meeple-sm.c3 { --m: #e8590c; }
[hidden] { display: none !important; }

@media (max-width: 700px) {
  :root { --hex-size: 22px; }
  .brand h1 { font-size: 1.25rem; }
}
@media (min-width: 1200px) {
  :root { --hex-size: 30px; }
}
