:root {
  color-scheme: light;
  --foam: #f4fdff;
  --sky: #d8f7ff;
  --sea: #0677a1;
  --deep-sea: #064b69;
  --reef: #00a7b5;
  --lagoon: #7fe0e9;
  --sand: #f8d88b;
  --warm-sand: #f0bd5a;
  --sun: #ffe66d;
  --coral: #ff7f6e;
  --shell: #fff7dc;
  --ink: #07384d;
  --muted: #4f7180;
  --danger: #b43f50;
  --shadow: 0 22px 56px rgb(6 75 105 / 18%);
  --soft-shadow: 0 10px 24px rgb(6 75 105 / 12%);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 8%, rgb(255 230 109 / 70%), transparent 8rem),
    radial-gradient(circle at 10% 10%, rgb(127 224 233 / 72%), transparent 16rem),
    linear-gradient(180deg, var(--sky) 0%, var(--foam) 46%, #fff0c8 100%);
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: auto 0 0;
  height: 28vh;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(80% 75% at 18% 100%, rgb(255 255 255 / 70%), transparent 45%),
    radial-gradient(90% 75% at 76% 100%, rgb(255 255 255 / 54%), transparent 48%),
    linear-gradient(180deg, transparent, rgb(0 167 181 / 18%));
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0.86rem 1.05rem;
  background: linear-gradient(135deg, var(--sea), var(--reef));
  color: #fff;
  font-weight: 850;
  box-shadow: var(--soft-shadow);
  touch-action: manipulation;
}

button.secondary {
  background: linear-gradient(135deg, #0b95bd, #09b8bc);
}

button.ghost {
  background: rgb(255 255 255 / 64%);
  color: var(--deep-sea);
  outline: 2px solid rgb(6 119 161 / 22%);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
}

input,
textarea {
  width: 100%;
  margin-top: 0.45rem;
  border: 2px solid rgb(6 119 161 / 16%);
  border-radius: 1.1rem;
  padding: 0.86rem;
  background: rgb(255 255 255 / 78%);
  color: var(--ink);
  resize: vertical;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
}

.app-shell {
  position: relative;
  width: min(100%, 820px);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
}

.hero,
.panel {
  border: 1px solid rgb(6 119 161 / 13%);
  border-radius: 1.6rem;
  background: rgb(255 255 255 / 70%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  position: relative;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  overflow: hidden;
  padding: 1.3rem;
}

.hero::after {
  position: absolute;
  right: -2rem;
  bottom: -2.6rem;
  width: 12rem;
  height: 12rem;
  border-radius: 999px;
  content: "";
  background:
    radial-gradient(circle at 50% 50%, transparent 0 38%, rgb(255 230 109 / 72%) 39% 56%, transparent 57%),
    radial-gradient(circle, rgb(0 167 181 / 18%), transparent 65%);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.panel {
  margin-top: 1rem;
  padding: 1rem;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 0.28rem;
  color: var(--sea);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 0.95;
}

h1 {
  max-width: 9ch;
  color: var(--deep-sea);
  font-size: clamp(2.6rem, 14vw, 5.4rem);
  font-weight: 950;
  letter-spacing: -0.09em;
}

h2 {
  color: var(--deep-sea);
  font-size: 1.28rem;
}

h3 {
  color: var(--deep-sea);
  font-size: 1.05rem;
}

.lede {
  max-width: 34rem;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 2.1rem;
  border: 1px solid rgb(6 119 161 / 14%);
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  background: rgb(216 247 255 / 74%);
  color: var(--deep-sea);
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.muted {
  background: rgb(255 247 220 / 78%);
  color: var(--muted);
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.actions-grid,
.pairing-grid,
.word-check {
  display: grid;
  gap: 0.75rem;
}

.actions-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pairing-grid {
  margin: 0.9rem 0;
}

.setup-choice {
  display: grid;
  gap: 0.75rem;
}

.manual-pairing {
  margin-top: 0.9rem;
  border: 1px solid rgb(6 119 161 / 12%);
  border-radius: 1rem;
  padding: 0.85rem;
  background: rgb(255 255 255 / 48%);
}

.manual-pairing summary {
  color: var(--deep-sea);
  cursor: pointer;
  font-weight: 900;
}

.word-check {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.scoreboard-shell {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid rgb(6 119 161 / 12%);
  border-radius: 1.25rem;
  padding: 0.9rem;
  background:
    linear-gradient(135deg, rgb(216 247 255 / 84%), rgb(255 247 220 / 78%)),
    rgb(255 255 255 / 64%);
}

.scoreboard-heading {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.score-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.score-player {
  display: grid;
  gap: 0.45rem;
  border: 2px solid transparent;
  border-radius: 1rem;
  padding: 0.8rem;
  background: rgb(255 255 255 / 72%);
  box-shadow: var(--soft-shadow);
}

.score-player.current {
  border-color: var(--sun);
  background: linear-gradient(145deg, #fff9d6, #e1fbff);
}

.score-player-top {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
}

.player-badge {
  display: grid;
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 999px;
  background: rgb(6 119 161 / 12%);
}

.player-name {
  overflow: hidden;
  color: var(--deep-sea);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-value {
  color: var(--deep-sea);
  font-size: clamp(2.2rem, 10vw, 4rem);
  font-weight: 950;
  letter-spacing: -0.08em;
}

.score-bar {
  overflow: hidden;
  height: 0.48rem;
  border-radius: 999px;
  background: rgb(6 119 161 / 12%);
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--reef), var(--sun));
}

.score-player p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.player-names {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.65rem;
  align-items: end;
}

label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 850;
}

.hint {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.48;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
  overflow: hidden;
  border: 4px solid var(--deep-sea);
  border-radius: 1.05rem;
  background: var(--deep-sea);
  box-shadow: var(--soft-shadow);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.9rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 54%);
}

.mode-button {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.mode-button.active {
  background: linear-gradient(135deg, var(--sea), var(--reef));
  color: #fff;
  box-shadow: var(--soft-shadow);
}

.square {
  display: grid;
  min-width: 0;
  min-height: clamp(1.28rem, 6vw, 2.8rem);
  place-items: center;
  border-radius: 0;
  padding: 0;
  background: #f6e5ad;
  color: rgb(7 56 77 / 78%);
  font-size: clamp(0.45rem, 2.2vw, 0.74rem);
  font-weight: 950;
  line-height: 1;
  box-shadow: none;
}

.square.committed {
  background: linear-gradient(145deg, #fff2bd, var(--sand));
  color: var(--deep-sea);
  font-size: clamp(0.9rem, 3.8vw, 1.5rem);
}

.square.pending {
  background: linear-gradient(145deg, #fff8d5, var(--sun));
  color: var(--deep-sea);
  font-size: clamp(0.9rem, 3.8vw, 1.5rem);
  outline: 3px solid var(--reef);
  outline-offset: -3px;
}

.premium-tw {
  background: var(--coral);
  color: #fff9ec;
}

.premium-dw,
.premium-star {
  background: #ffbd9b;
}

.premium-tl {
  background: var(--sea);
  color: #f4fdff;
}

.premium-dl {
  background: var(--lagoon);
}

.rack-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: center;
  margin-top: 1rem;
}

.rack-actions {
  display: grid;
  gap: 0.55rem;
}

.rack {
  display: flex;
  gap: 0.45rem;
  min-width: 0;
  overflow-x: auto;
  padding: 0.2rem 0 0.45rem;
}

.tile {
  display: grid;
  flex: 0 0 2.85rem;
  width: 2.85rem;
  height: 2.85rem;
  min-height: 2.85rem;
  place-items: center;
  border-radius: 0.65rem;
  border: 2px solid var(--warm-sand);
  background: linear-gradient(145deg, #fff2bd, var(--sand));
  color: var(--deep-sea);
  box-shadow: 0 5px 0 var(--warm-sand);
  font-size: 1.36rem;
  font-weight: 950;
}

.tile.selected {
  outline: 3px solid var(--reef);
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--warm-sand);
}

.success {
  color: #006d59;
  font-weight: 850;
}

.error {
  color: var(--danger);
  font-weight: 850;
}

@media (max-width: 520px) {
  .hero,
  .section-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-stack {
    justify-content: flex-start;
  }

  .section-heading,
  .rack-row,
  .word-check,
  .scoreboard-heading,
  .player-names {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .actions-grid,
  .score-card {
    grid-template-columns: 1fr;
  }

  .mode-switch {
    border-radius: 1.1rem;
    grid-template-columns: 1fr;
  }
}
