:root {
  --navy: #0B3D62;
  --navy-deep: #072A44;
  --teal: #0E7C7B;
  --coral: #E85D4C;
  --sand: #EFE3C3;
  --sand-dark: #D9C89A;
  --yellow: #F2C744;
  --green: #3FA34D;
  --blue: #2E6FBA;
  --red: #E85D4C;
  --ink: #12222B;
  --paper: #FBF7EC;
  --touch-min: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% -10%, #123a55 0%, var(--navy-deep) 55%, #051a29 100%);
  color: var(--paper);
  font-family: "Verdana", "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 12px 48px;
  max-width: 100vw;
  overflow-x: hidden;
}

.brand {
  text-align: center;
  margin: 6px 0 16px;
}

.brand h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 7vw, 2.5rem);
  margin: 0;
  letter-spacing: 0.5px;
  color: var(--sand);
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.brand p {
  margin: 4px 0 0;
  color: var(--coral);
  font-weight: 700;
  letter-spacing: 1.2px;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.panel {
  width: 100%;
  max-width: 520px;
  background: rgba(251, 247, 236, 0.08);
  border: 1px solid rgba(239, 227, 195, 0.28);
  border-radius: 16px;
  padding: 18px 20px;
  backdrop-filter: blur(4px);
}

.panel + .panel { margin-top: 14px; }

h2 {
  margin: 0 0 10px;
  font-family: Georgia, serif;
  color: var(--sand);
  border-bottom: 1px solid rgba(239,227,195,0.22);
  padding-bottom: 8px;
  font-size: 1.15rem;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.9rem;
  color: var(--sand-dark);
  font-weight: 600;
}

input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid rgba(239,227,195,0.45);
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  font-size: 1.05rem;
  min-height: var(--touch-min);
}

input[type="text"]:focus, select:focus {
  outline: 3px solid var(--teal);
  outline-offset: 1px;
}

.color-picker {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.swatch:hover { transform: scale(1.08); }
.swatch.selected {
  border-color: var(--sand);
  box-shadow: 0 0 0 3px rgba(239,227,195,0.4);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 14px 24px;
  font-weight: 700;
  letter-spacing: 0.3px;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  transition: transform 0.12s ease, filter 0.12s, opacity 0.12s;
  touch-action: manipulation;
}

button:active:not(:disabled) { transform: scale(0.96); }

.btn-primary {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 4px 0 #b83d30;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-secondary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 4px 0 #0a5c5b;
}

.btn-ghost {
  background: transparent;
  color: var(--sand);
  border: 2px solid rgba(239,227,195,0.55);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  align-items: center;
}

.help-text {
  color: var(--sand-dark);
  font-size: 0.9rem;
  line-height: 1.4;
  margin: 0 0 8px;
}

.player-list { list-style: none; padding: 0; margin: 10px 0 0; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.5);
}

/* Game layout */
.game-layout {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 820px) {
  .game-layout {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}

.board-wrap {
  position: relative;
  width: min(92vw, 460px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #0a4a6e 0%, #062538 70%);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.4);
}

.space {
  position: absolute;
  width: 8.5%;
  height: 8.5%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  z-index: 2;
  transition: box-shadow 0.2s;
}

.space.shore {
  border: 3px solid var(--sand);
  box-shadow: 0 0 10px rgba(239,227,195,0.45);
}

.space.safe {
  box-shadow: 0 0 0 3px rgba(63,163,77,0.7);
}

.space .type-icon {
  pointer-events: none;
  line-height: 1;
}

.pawn {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.55);
  transform: translate(-50%, -50%);
  transition: left 0.5s cubic-bezier(0.22, 1, 0.36, 1), top 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 6;
  cursor: pointer;
}

.pawn.current-turn {
  box-shadow: 0 0 0 4px var(--yellow), 0 2px 8px rgba(0,0,0,0.5);
  z-index: 8;
}

.pawn.selected {
  box-shadow: 0 0 0 5px #fff, 0 0 12px var(--coral);
}

.board-center {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle, #0d4a6e 0%, var(--navy-deep) 85%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4%;
  z-index: 4;
  border: 3px solid rgba(239,227,195,0.15);
}

.die-display {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 3px solid var(--sand);
}

.pop-btn {
  font-size: 1.1rem;
  padding: 12px 28px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.turn-banner {
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.09);
  border-left: 6px solid var(--coral);
  font-size: 1rem;
  line-height: 1.35;
}

.log-box {
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.88rem;
  background: rgba(0,0,0,0.28);
  border-radius: 12px;
  padding: 10px 12px;
  scroll-behavior: smooth;
}

.log-box p {
  margin: 5px 0;
  color: var(--sand-dark);
  line-height: 1.35;
}

.log-box p:last-child {
  color: var(--sand);
  font-weight: 600;
}

/* Homes */
.homes-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.home-box {
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  min-width: 90px;
}

.home-box .home-label {
  font-size: 0.75rem;
  color: var(--sand-dark);
  margin-bottom: 4px;
}

.home-pieces {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.home-piece {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 15, 25, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 18px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  animation: popIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-card h3 {
  font-family: Georgia, serif;
  margin: 0 0 12px;
  font-size: 1.35rem;
}

.shark-reveal {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--coral);
  margin: 8px 0;
}

.swimmer-reveal {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--teal);
  margin: 8px 0;
}

.hidden { display: none !important; }

footer.note {
  margin-top: 28px;
  font-size: 0.72rem;
  color: rgba(239,227,195,0.45);
  text-align: center;
  max-width: 480px;
  line-height: 1.4;
}

.howto-list {
  text-align: left;
  padding-left: 1.2em;
  margin: 10px 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
}
.howto-list li { margin-bottom: 6px; }

.sound-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(239,227,195,0.35);
  color: var(--sand);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
  min-height: 44px;
}

.chant-box {
  text-align: center;
  margin-top: 12px;
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
}
.chant-box strong {
  color: var(--coral);
  font-size: 1.1rem;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 2.8s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242,199,68,0.5); }
  50% { box-shadow: 0 0 0 10px rgba(242,199,68,0); }
}
.pulse-once {
  animation: pulseGlow 0.9s ease-out 2;
}

@media (max-width: 420px) {
  .panel { padding: 14px; }
  .board-wrap { width: min(94vw, 360px); }
  .die-display { width: 52px; height: 52px; font-size: 1.6rem; }
  button { padding: 12px 18px; }
}

button:focus-visible,
.swatch:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}
