:root {
  color-scheme: light;
  --bg: #fbfaf8;
  --ink: #111820;
  --muted: #66707a;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.82);
  --line: #d9dde1;
  --tile: #efeeee;
  --tile-empty: #ffffff;
  --accent: #55a63d;
  --accent-strong: #2f8c1d;
  --blue: #1d70e8;
  --gold: #e8ad08;
  --absent: #e9e9e9;
  --danger: #c2413a;
  --shadow: 0 18px 55px rgba(17, 24, 32, 0.08);
  --surface-glow: radial-gradient(circle at 24% 18%, rgba(85, 166, 61, 0.08), transparent 28%),
    radial-gradient(circle at 78% 88%, rgba(29, 112, 232, 0.06), transparent 32%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #020b12;
  --ink: #f8fafc;
  --muted: #a8b1bd;
  --panel: #07121a;
  --panel-soft: rgba(7, 18, 26, 0.82);
  --line: #33424d;
  --tile: #1c2833;
  --tile-empty: #030d14;
  --accent: #56ad3b;
  --accent-strong: #68c54d;
  --blue: #2e86ff;
  --gold: #f0b80a;
  --absent: #1f2b35;
  --danger: #ff6b62;
  --shadow: 0 22px 65px rgba(0, 0, 0, 0.36);
  --surface-glow: radial-gradient(circle at 24% 18%, rgba(86, 173, 59, 0.12), transparent 30%),
    radial-gradient(circle at 80% 88%, rgba(46, 134, 255, 0.1), transparent 32%);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--surface-glow), var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(720px, calc(100% - 28px));
  height: 100vh;
  margin: 0 auto;
  padding: 18px 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(54px, auto) minmax(0, 1fr) minmax(54px, auto);
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.nav-left,
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 54px;
}

.nav-left {
  justify-content: flex-start;
}

.nav-actions {
  justify-content: flex-end;
}

.brand-lockup {
  justify-self: center;
  min-width: 0;
  text-align: center;
}

.topbar .eyebrow {
  display: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.worduel-logo {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 8vw, 3.35rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.65rem, 4vw, 3.25rem);
  line-height: 1.02;
}

.theme-toggle,
.icon-button,
.ghost-button,
.primary-button,
.copy-row button {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 850;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 1.55rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1;
}

#back-button {
  font-size: 2.2rem;
  padding-bottom: 4px;
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-button,
.copy-row button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.copy-row button:hover {
  background: var(--accent-strong);
}

.hero,
.join-page {
  align-self: center;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.72fr);
  gap: 28px;
  align-items: center;
  min-height: 0;
  padding: 28px 0;
}

.hero-copy {
  padding: 24px 0;
}

.lede {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.demo-stack {
  display: grid;
  gap: 14px;
  width: min(100%, 340px);
  margin-left: auto;
}

.demo-board {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 18px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.demo-action {
  width: 100%;
  margin-top: 4px;
}

.lobby-page,
.join-page {
  display: grid;
  place-items: center;
  min-height: 0;
  padding-top: 30px;
}

.lobby-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 22px;
  width: min(100%, 620px);
  max-height: 100%;
  min-height: 0;
}

.previous-games {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  text-align: right;
}

.previous-games-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-color: var(--muted) transparent;
  scrollbar-width: thin;
}

.previous-games-list::-webkit-scrollbar {
  width: 8px;
}

.previous-games-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line);
}

.previous-game-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(88px, 0.8fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
}

.previous-game-card span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.previous-game-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.previous-game-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.continue-button,
.delete-game-button {
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.delete-game-button {
  color: var(--danger);
}

.list-new-game {
  justify-self: center;
}

.join-panel {
  display: grid;
  gap: 22px;
  width: min(100%, 560px);
  padding: 24px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
}

input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.game-layout {
  min-height: 0;
  padding-top: 20px;
  overflow: hidden;
}

.play-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.game-topline {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  background: transparent;
}

.game-instruction {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 16px;
  padding: 10px 0 12px;
}

.game-instruction p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 850;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.person-icon,
.player-avatar {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.person-icon::before,
.player-avatar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.person-icon::after,
.player-avatar::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 24px;
  height: 12px;
  border-radius: 14px 14px 4px 4px;
  background: currentColor;
  transform: translateX(-50%);
}

.person-two {
  color: var(--blue);
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.guess-list {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  padding: 0 8px 14px;
  overflow-y: auto;
  scrollbar-color: var(--muted) transparent;
  scrollbar-width: thin;
}

.guess-list::-webkit-scrollbar {
  width: 8px;
}

.guess-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line);
}

.guess-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.guess-card.pending {
  background: color-mix(in srgb, var(--panel) 62%, transparent);
}

.guess-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

.guess-meta span:first-child {
  color: var(--accent-strong);
}

.guess-card:nth-child(even) .guess-meta span:first-child {
  color: var(--blue);
}

.demo-row,
.word-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 16px);
}

.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  font-size: clamp(1.45rem, 7vw, 2.2rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.tile.correct {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tile.present {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: var(--ink);
}

:root[data-theme="dark"] .tile.absent {
  color: #fff;
}

.tile.empty {
  background: var(--tile-empty);
  border-color: var(--line);
  color: var(--ink);
}

.guess-form {
  display: grid;
  gap: 10px;
  padding: 12px 0 10px;
  background: transparent;
}

.keyboard {
  display: grid;
  gap: 8px;
}

.keyboard-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
}

.keyboard-row:nth-child(2) {
  padding: 0 18px;
}

.key-button {
  display: grid;
  place-items: center;
  min-width: 0;
  height: clamp(44px, 8vh, 64px);
  border-radius: 8px;
  background: var(--tile);
  color: var(--ink);
  font-size: clamp(0.94rem, 3vw, 1.2rem);
  font-weight: 900;
  text-transform: uppercase;
}

.key-button.correct {
  background: var(--accent);
  color: #fff;
}

.key-button.present {
  background: var(--gold);
  color: #fff;
}

.key-button.absent {
  background: var(--absent);
  color: var(--muted);
}

.wide-key {
  grid-column: span 2;
  font-size: clamp(0.75rem, 2.5vw, 0.98rem);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 750;
  text-align: center;
}

.players {
  display: grid;
  gap: 12px;
}

.player-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 10px;
}

.player-pill {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 74%, transparent);
  color: var(--ink);
}

.player-pill:nth-child(2) .player-avatar {
  color: var(--blue);
}

.player-pill strong,
.player-pill small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-pill strong {
  display: block;
  color: var(--accent-strong);
  font-size: 1rem;
  font-weight: 850;
}

.player-pill:nth-child(2) strong {
  color: var(--blue);
}

.player-pill small {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
}

.player-marker {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--muted);
  color: transparent;
}

.player-pill.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}

.player-pill:nth-child(2).is-active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 55%, transparent);
}

.player-pill.is-active .player-marker {
  background: var(--accent);
}

.player-pill:nth-child(2).is-active .player-marker {
  background: var(--blue);
}

.player-pill.is-winner {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 60%, transparent);
}

.player-pill.is-open {
  border-style: dashed;
}

.share-link-button {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--blue);
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding: 12px 0;
  }

  .topbar {
    grid-template-columns: minmax(46px, auto) minmax(0, 1fr) minmax(46px, auto);
    gap: 8px;
    padding-bottom: 14px;
  }

  .nav-left,
  .nav-actions {
    min-width: 46px;
    gap: 6px;
  }

  .theme-toggle {
    width: 42px;
    height: 42px;
    font-size: 1.28rem;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    font-size: 1.45rem;
  }

  .ghost-button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .eyebrow {
    font-size: 0.62rem;
  }

  .hero {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .demo-board {
    width: 100%;
  }

  .demo-stack {
    width: 100%;
  }

  .copy-row {
    grid-template-columns: 1fr;
  }

  .lobby-page {
    align-items: stretch;
    padding-top: 18px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .section-heading p {
    text-align: left;
  }

  .previous-game-card {
    grid-template-columns: 1fr auto;
  }

  .previous-game-card > div {
    grid-column: 1 / -1;
  }

  .previous-game-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .continue-button,
  .delete-game-button {
    width: 100%;
  }

  .game-layout {
    padding-top: 12px;
  }

  .game-instruction {
    grid-template-columns: 24px minmax(0, 1fr) 24px;
    gap: 8px;
  }

  .person-icon {
    width: 24px;
    height: 24px;
  }

  .guess-list {
    padding-inline: 0;
  }

  .guess-card {
    padding: 10px;
  }

  .keyboard-row,
  .demo-row,
  .word-row {
    gap: 6px;
  }

  .keyboard-row:nth-child(2) {
    padding: 0 10px;
  }

  .player-strip {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .player-pill {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 70px;
    padding: 10px;
  }

  .player-marker,
  .share-link-button {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .player-marker {
    width: 9px;
    height: 9px;
  }
}
