/* Island Links — calm Hashi UI */

:root,
html.day-tide {
  --bg: #eef5f3;
  --bg2: #f7f4ef;
  --surface: #ffffff;
  --surface-2: #f3efe8;
  --border: #e0d8cc;
  --text: #0f332f;
  --muted: rgba(15, 51, 47, 0.55);
  --tide-500: #2a9d8f;
  --tide-600: #1f7a6f;
  --tide-700: #1a6158;
  --tide-200: #a8e0d4;
  --island: #e8dcc8;
  --island-edge: #c4b49a;
  --island-done: #d5ebe4;
  --bridge: #1f7a6f;
  --bridge-soft: rgba(31, 122, 111, 0.85);
  --water: #d8ebe7;
  --shadow: 0 16px 44px -26px rgba(15, 51, 47, 0.28);
  --font: Inter, system-ui, sans-serif;
  --display: "Cormorant Garamond", Georgia, serif;
  --radius: 1.2rem;
  --cell: 2.65rem;
  --island-size: 2.15rem;
  --num-size: 0.95rem;
}

html.night-tide {
  --bg: #0a2220;
  --bg2: #0f332f;
  --surface: #12352f;
  --surface-2: #164e47;
  --border: rgba(168, 224, 212, 0.16);
  --text: #e8f5f2;
  --muted: rgba(232, 245, 242, 0.55);
  --island: #2a4a44;
  --island-edge: #3d6b62;
  --island-done: #1a6158;
  --bridge: #a8e0d4;
  --bridge-soft: rgba(168, 224, 212, 0.9);
  --water: #0c2a26;
  --shadow: 0 18px 48px -18px rgba(0, 0, 0, 0.55);
}

html.large-type {
  --island-size: 2.45rem;
  --num-size: 1.1rem;
  --cell: 2.95rem;
}

html.high-contrast {
  --bridge: #0a5c54;
  --island: #f5efe4;
  --island-edge: #0f332f;
  --text: #06201c;
}

html.night-tide.high-contrast {
  --bridge: #e8f5f2;
  --island: #1a403a;
  --island-edge: #e8f5f2;
  --text: #f5fffc;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

.bg-wash {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 50% at 50% 40%, rgba(42, 157, 143, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
}

html.night-tide .bg-wash {
  background:
    radial-gradient(ellipse 80% 45% at 50% 50%, rgba(42, 157, 143, 0.12), transparent 55%),
    linear-gradient(180deg, #071816, #0a2220 55%, #0f332f);
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.brand img {
  height: 1.8rem;
  width: auto;
}

.brand strong {
  display: block;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.1;
}

.brand span {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.icon-btn,
.btn,
.mode-btn,
.tool-btn {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 0.75rem;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}

.icon-btn {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
}

.btn-sm {
  min-height: 2.15rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--tide-700);
  border-color: var(--tide-700);
  color: #fff;
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover,
.icon-btn:hover {
  background: color-mix(in srgb, var(--tide-500) 10%, var(--surface));
}

.main {
  flex: 1;
  width: 100%;
  max-width: 88rem;
  margin: 0 auto;
  padding: 1rem 0.85rem 2rem;
  display: grid;
  gap: 1rem;
}

.side-left { order: 1; }
.play-panel { order: 2; }
.side-right { order: 3; }

@media (min-width: 1100px) {
  .main {
    grid-template-columns: 15rem minmax(0, 1fr) 16rem;
    gap: 1.1rem;
    padding: 1.25rem 1.25rem 2.5rem;
    align-items: start;
  }

  .side-left,
  .side-right {
    position: sticky;
    top: 4.25rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    align-self: start;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.play-panel {
  padding: 1.1rem 1rem 1.35rem;
}

.tagline {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--muted);
  max-width: 36rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.pill.accent {
  background: color-mix(in srgb, var(--tide-500) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--tide-500) 30%, var(--border));
  color: var(--tide-700);
}

html.night-tide .pill.accent {
  color: var(--tide-200);
}

/* Board */
.board-shell {
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 0.5rem;
  -webkit-user-select: none;
  user-select: none;
}

.board-frame {
  position: relative;
  background: var(--water);
  border-radius: 1rem;
  border: 1px solid var(--border);
  padding: 0.65rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.board-frame.complete {
  animation: net-pulse 1.1s ease;
}

@keyframes net-pulse {
  0% {
    box-shadow: inset 0 0 0 0 rgba(42, 157, 143, 0.25);
  }
  45% {
    box-shadow: inset 0 0 0 10px rgba(42, 157, 143, 0);
  }
  100% {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  }
}

.board-grid {
  display: grid;
  position: relative;
  z-index: 2;
}

.bridges-svg {
  position: absolute;
  inset: 0.65rem;
  width: calc(100% - 1.3rem);
  height: calc(100% - 1.3rem);
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.bridges-svg line {
  stroke: var(--bridge-soft);
  stroke-linecap: round;
  transition: stroke 0.2s ease, opacity 0.2s ease;
}

.bridges-svg line.preview {
  stroke: color-mix(in srgb, var(--tide-500) 55%, transparent);
  stroke-dasharray: 4 4;
  opacity: 0.85;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.island {
  width: var(--island-size);
  height: var(--island-size);
  border-radius: 46% 54% 48% 52% / 52% 46% 54% 48%;
  border: 1.5px solid var(--island-edge);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.45), transparent 45%),
    var(--island);
  color: var(--text);
  font-weight: 700;
  font-size: var(--num-size);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px -2px rgba(15, 51, 47, 0.2);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.island:hover {
  transform: scale(1.05);
}

.island.selected {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tide-500) 45%, transparent);
  transform: scale(1.08);
}

.island.satisfied {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.4), transparent 45%),
    var(--island-done);
  border-color: color-mix(in srgb, var(--tide-500) 50%, var(--island-edge));
}

.island.over {
  border-color: #b4534a;
  color: #9f1239;
}

html.night-tide .island.over {
  color: #f0a8a0;
}

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 1rem;
}

.tool-btn {
  min-height: 2.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.35rem;
}

.tool-btn i {
  font-size: 0.95rem;
  color: var(--tide-700);
}

html.night-tide .tool-btn i {
  color: var(--tide-200);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.side .panel {
  padding: 1rem 1.05rem;
}

.side h2 {
  margin: 0 0 0.3rem;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
}

.side p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.mode-btn {
  text-align: left;
  padding: 0.65rem 0.8rem;
  border-radius: 0.85rem;
}

.mode-btn strong {
  display: block;
  font-size: 0.9rem;
}

.mode-btn span {
  font-size: 0.74rem;
  color: var(--muted);
}

.mode-btn:hover,
.mode-btn.active {
  border-color: color-mix(in srgb, var(--tide-500) 40%, var(--border));
  background: color-mix(in srgb, var(--tide-500) 10%, var(--surface));
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.5rem 0.6rem;
}

.stat b {
  display: block;
  font-size: 1.05rem;
  color: var(--tide-700);
  font-variant-numeric: tabular-nums;
}

html.night-tide .stat b {
  color: var(--tide-200);
}

.stat span {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.48rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.toggle-row:last-child {
  border-bottom: none;
}

.switch {
  width: 2.45rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--border);
  position: relative;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 0.12rem;
  left: 0.12rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.switch[aria-checked="true"] {
  background: var(--tide-600);
  border-color: var(--tide-600);
}

.switch[aria-checked="true"]::after {
  transform: translateX(1.05rem);
}

.footer-mini {
  text-align: center;
  padding: 0.35rem 1rem 1.2rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.footer-mini a {
  color: var(--tide-700);
  font-weight: 600;
  text-decoration: none;
}

html.night-tide .footer-mini a {
  color: var(--tide-200);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 51, 47, 0.3);
  backdrop-filter: blur(6px);
}

.modal-root.open {
  display: flex;
}

.modal {
  width: min(100%, 25rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.4rem 1.25rem 1.2rem;
  box-shadow: var(--shadow);
}

.modal .kicker {
  margin: 0 0 0.3rem;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--tide-600);
}

.modal h2 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 600;
}

.modal .line {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.fact-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.85rem 0.95rem;
  margin-bottom: 0.9rem;
}

.fact-card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tide-600);
}

.fact-card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.next-block {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
}

.next-label {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--tide-600);
}

.next-games {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.next-games a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.55rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  transition: border-color 0.15s, background 0.15s;
}

.next-games a:hover {
  border-color: color-mix(in srgb, var(--tide-500) 45%, var(--border));
  background: color-mix(in srgb, var(--tide-500) 8%, var(--surface));
}

.btn-soft {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-soft:hover {
  background: color-mix(in srgb, var(--tide-500) 10%, var(--surface-2));
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: var(--bg);
  transition: opacity 0.4s, visibility 0.4s;
}

.splash.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash p {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
}

.splash span {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 480px) {
  :root {
    --cell: 2.2rem;
    --island-size: 1.85rem;
    --num-size: 0.85rem;
  }
  html.large-type {
    --cell: 2.45rem;
    --island-size: 2.05rem;
    --num-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .island,
  .board-frame.complete,
  .bridges-svg line {
    transition: none !important;
    animation: none !important;
  }
}
