:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #fbfcfb;
  --panel-strong: #ffffff;
  --ink: #20242a;
  --muted: #65717b;
  --line: #d5ddd8;
  --teal: #0e7c7b;
  --teal-dark: #075e5d;
  --gold: #f4d35e;
  --orange: #ee964b;
  --red: #d1495b;
  --green: #3a8f5b;
  --tile-empty: #e8eeea;
  --tile-absent: #69717a;
  --shadow: 0 18px 42px rgba(32, 36, 42, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(14, 124, 123, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(14, 124, 123, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 8% 8%, rgba(238, 150, 75, 0.13), transparent 22rem),
    var(--bg);
  background-size: 48px 48px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 850;
}

.brand img {
  width: 40px;
  height: 40px;
  box-shadow: 0 10px 20px rgba(14, 124, 123, 0.18);
  border-radius: 8px;
}

.game-tabs {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 251, 0.84);
}

.tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 800;
}

.tab.is-active {
  background: var(--teal);
  color: white;
}

main {
  display: grid;
}

.game-view {
  display: none;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 252, 251, 0.94);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 34px);
}

.game-view.is-active {
  display: block;
}

.game-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 900;
}

.icon-button:hover,
.word-key:hover,
.primary-action:hover,
.guess-form button:hover {
  transform: translateY(-1px);
}

.status-line {
  min-height: 30px;
  color: var(--muted);
  font-weight: 760;
}

.term-feedback {
  min-height: 28px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 850;
}

.term-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.term-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--muted);
  padding: 0 9px;
  font-size: 0.82rem;
  font-weight: 850;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend-swatch.correct {
  background: var(--green);
}

.legend-swatch.present {
  background: var(--gold);
}

.legend-swatch.absent {
  background: var(--tile-absent);
}

.word-board {
  display: grid;
  width: min(430px, 100%);
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 14px auto 20px;
}

.letter-tile {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--tile-empty);
  color: var(--ink);
  font-size: clamp(1.45rem, 8vw, 2.3rem);
  font-weight: 950;
  text-transform: uppercase;
}

.letter-tile.is-filled {
  background: var(--panel-strong);
  border-color: #bfb5a3;
}

.letter-tile.correct,
.word-key.correct {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.letter-tile.present,
.word-key.present {
  background: var(--gold);
  border-color: #d4b546;
  color: var(--ink);
}

.letter-tile.absent,
.word-key.absent {
  background: var(--tile-absent);
  border-color: var(--tile-absent);
  color: white;
}

.keyboard {
  display: grid;
  gap: 7px;
  width: min(720px, 100%);
  margin: 0 auto;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.word-key {
  min-width: 32px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  transition:
    transform 120ms ease,
    background 120ms ease;
}

.word-key:disabled {
  cursor: not-allowed;
  transform: none;
}

.word-key.is-wide {
  min-width: 68px;
  padding: 0 10px;
}

.context-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 16px;
  align-items: stretch;
  margin: 24px 0 10px;
}

.guess-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-self: end;
}

.guess-form input {
  min-width: 0;
  height: 52px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.guess-form input:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(14, 124, 123, 0.16);
}

.guess-form button,
.primary-action {
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: var(--teal);
  color: white;
  padding: 0 18px;
  font-weight: 900;
}

.thermo {
  position: relative;
  min-height: 168px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  overflow: hidden;
}

.thermo::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(32, 36, 42, 0.18);
  border-radius: 5px;
}

.thermo-fill {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 8%;
  background: linear-gradient(0deg, var(--teal), var(--gold), var(--red));
  transition: height 240ms ease;
}

.guess-list {
  display: grid;
  gap: 8px;
  max-width: 760px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.context-guess {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 96px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: 8px 12px;
}

.rank {
  font-weight: 950;
  color: var(--teal-dark);
}

.heat-bar {
  height: 12px;
  border-radius: 999px;
  background: #e3ebe6;
  overflow: hidden;
}

.heat-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--red));
}

.heat-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
  text-align: right;
}

.mistakes {
  display: flex;
  gap: 7px;
  min-height: 20px;
  margin: 4px 0 14px;
}

.mistake-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--orange);
}

.mistake-dot.is-used {
  background: var(--line);
}

.solved-groups {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.solved-group {
  border-radius: var(--radius);
  background: var(--teal);
  color: white;
  padding: 12px;
}

.solved-group strong {
  display: block;
  margin-bottom: 2px;
}

.connection-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 760px;
}

.connection-card {
  display: grid;
  min-height: 74px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  padding: 8px;
  font-weight: 930;
  text-align: center;
  text-transform: uppercase;
}

.connection-card.is-selected {
  border-color: var(--teal);
  background: #d9f0ed;
}

.primary-action {
  width: min(260px, 100%);
  margin-top: 16px;
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.who-stage {
  display: grid;
  gap: 16px;
  max-width: 760px;
  margin-top: 20px;
}

.who-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  padding: clamp(16px, 3vw, 24px);
}

.who-category {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: var(--radius);
  background: #e1f0eb;
  color: var(--teal-dark);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.who-hints {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding-left: 22px;
}

.who-hints li {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 780;
  line-height: 1.35;
}

.who-guesses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 760px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.who-guesses li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 900;
}

.who-guesses li.is-correct {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 5;
  max-width: min(520px, calc(100% - 28px));
  transform: translate(-50%, 120%);
  border-radius: var(--radius);
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  font-weight: 800;
  opacity: 0;
  transition:
    opacity 170ms ease,
    transform 170ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .game-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab {
    padding-inline: 6px;
  }

  .game-heading {
    align-items: flex-start;
  }

  .word-key {
    min-width: 0;
    flex: 1 1 0;
    height: 42px;
    padding: 0 4px;
  }

  .word-key.is-wide {
    flex: 1.45 1 0;
    min-width: 0;
  }

  .context-stage {
    grid-template-columns: 1fr;
  }

  .thermo {
    min-height: 28px;
  }

  .thermo-fill {
    width: 8%;
    height: auto;
    inset-block: 0;
    inset-inline: 0 auto;
    transition: width 240ms ease;
  }

  .context-guess {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .heat-label {
    grid-column: 1 / -1;
    text-align: left;
  }

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

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 18px, 1080px);
    padding-top: 10px;
  }

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

  .game-view {
    padding: 14px;
  }

  .guess-form {
    grid-template-columns: 1fr;
  }

  .connection-card {
    min-height: 62px;
    font-size: 0.82rem;
  }
}
