:root {
  --bg: #191715;
  --bg-2: #211d1c;
  --bg-3: #2a2523;
  --line: #3a3532;
  --text: #F1ECEC;
  --muted: #a49c98;
  --faint: #6f6763;
  --accent: #F5B84E;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(900px 560px at 50% -10%, #2b2622, transparent 70%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- topbar ---------- */

.topbar {
  width: 100%;
  max-width: 860px;
  padding: 14px 16px 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.back {
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}

.back:hover {
  color: var(--text);
  background: var(--bg-2);
  border-color: var(--line);
}

.topbar h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-select {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-mono);
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--text);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a49c98' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center,
    var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 32px 8px 12px;
  cursor: pointer;
  max-width: 190px;
  transition: border-color .15s, filter .15s;
}

.nav-select:hover {
  border-color: var(--faint);
  filter: brightness(1.08);
}

.nav-select:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

.nav-select option {
  background: var(--bg-2);
  color: var(--text);
}

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

/* ---------- action buttons ---------- */

#newGame,
#playAgain {
  background: var(--accent);
  color: #1a1613;
  font-weight: 700;
  font-size: .92rem;
  padding: 10px 20px;
  border-radius: 12px;
  box-shadow: 0 6px 22px rgba(245, 184, 78, .35);
  transition: transform .1s, filter .15s;
}

#playAgain {
  font-size: .98rem;
  padding: 11px 26px;
}

#newGame:hover,
#playAgain:hover {
  filter: brightness(1.08);
}

#newGame:active,
#playAgain:active {
  transform: scale(.96);
}

/* ---------- layout ---------- */

.layout {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 16px 12px;
}

.game {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  width: 100%;
  min-height: 0;
}

.col-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  max-width: 620px;
}

.col-right {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hint {
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .02em;
  color: var(--faint);
  text-align: center;
  padding: 0 12px;
}

.theme {
  font-family: var(--font-mono);
  font-size: .8rem;
  letter-spacing: .03em;
  color: var(--muted);
}

.theme b {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- word ---------- */

.word {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  gap: 6px;
  --gap: 6px;
  container-type: inline-size;
  --tw: calc((100% - (var(--tiles, 7) - 1) * var(--gap)) / var(--tiles, 7));
  min-height: 56px;
}

.tile {
  flex-shrink: 0;
  width: min(46px, var(--tw));
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: clamp(.7rem, calc((100cqw - (var(--tiles, 7) - 1) * var(--gap)) / var(--tiles, 7) * .5), 1.35rem);
  font-weight: 600;
  color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}

.tile.shown {
  color: var(--accent);
  border-color: #5a4a2c;
}

/* ---------- flask ---------- */

.flask-wrap {
  position: relative;
  width: min(200px, 24vw);
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, .45));
}

.flask-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

#ink {
  transition: height .55s cubic-bezier(.3, 1.15, .4, 1);
}

.floor {
  transition: opacity .35s ease;
}

.floor.gone {
  opacity: 0;
}

#cake {
  transition: transform .3s ease;
}

#cake.bounce {
  animation: cakeBounce .6s ease;
}

@keyframes cakeBounce {
  0% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-10px) scale(1.05);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.flask-wrap.shake {
  animation: flaskShake .3s ease;
}

@keyframes flaskShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

/* ---------- hud ---------- */

.hud {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--muted);
}

.hud b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- keyboard ---------- */

.keyboard {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.kb-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.key {
  font-family: var(--font-mono);
  font-size: 1rem;
  width: 44px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, filter .15s, transform .05s;
}

.key:hover {
  border-color: var(--faint);
  filter: brightness(1.12);
}

.key:active {
  transform: scale(.93);
}

.key.right {
  color: #93d693;
  border-color: #3a5a3a;
  background: var(--bg-3);
}

.key.wrong {
  color: #e2918a;
  border-color: #5a3735;
  opacity: .7;
}

/* ---------- end overlay ---------- */

.win-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 7, .82);
  backdrop-filter: blur(4px);
  z-index: 50;
  padding: 16px;
}

.win-overlay.hidden {
  display: none;
}

.win-box {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  max-width: 340px;
  animation: pop .25s ease;
}

@keyframes pop {
  from {
    transform: scale(.92);
    opacity: 0;
  }
}

.win-box h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.win-box.lose h2 {
  color: #b0a7e6;
}

.win-box p {
  color: var(--muted);
  margin-bottom: 18px;
}

@media (prefers-reduced-motion: reduce) {
  .win-box,
  #cake.bounce,
  .flask-wrap.shake {
    animation: none;
  }
}

/* ---------- mobile ---------- */

@media (max-width: 760px) {
  .topbar {
    padding: 10px 12px 4px;
  }

  .nav-select {
    max-width: 150px;
    font-size: .74rem;
    padding: 7px 28px 7px 10px;
  }

  .game {
    gap: 10px;
  }

  .col-left {
    gap: 8px;
  }

  .flask-wrap {
    width: 118px;
  }

  .tile {
    width: min(36px, var(--tw));
    height: 42px;
    font-size: clamp(.6rem, calc((100cqw - (var(--tiles, 7) - 1) * var(--gap)) / var(--tiles, 7) * .5), 1.05rem);
  }

  .word {
    gap: 4px;
    --gap: 4px;
  }

  .key {
    width: 34px;
    height: 38px;
    font-size: .8rem;
  }

  .kb-row {
    gap: 4px;
    margin-bottom: 4px;
  }

  .hud {
    gap: 12px;
    font-size: .76rem;
  }

  #newGame {
    padding: 8px 14px;
    font-size: .84rem;
  }
}
