:root {
  --bg: #68605d;
  --bg-dark: #3a3334;
  --surface: rgba(80, 70, 68, 0.42);
  --surface-strong: rgba(58, 51, 52, 0.48);
  --key: #554a47;
  --key-hover: #6a5f5c;
  --correct: #5ba3d0;
  --wrong: #d17a5c;
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.78);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.18);
  --shadow-key: 0 4px 12px rgba(0, 0, 0, 0.16);
  --radius: 8px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 30%),
    linear-gradient(180deg, #6f6764 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Lexend Deca", system-ui, sans-serif;
}

button {
  font: inherit;
}

select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px 14px;
}

.game {
  width: min(100%, 1040px);
  display: grid;
  gap: 16px;
  min-width: 0;
}

.topbar,
.status-strip,
.hangman-card,
.board-card,
.keyboard-card {
  min-width: 0;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.topbar {
  position: relative;
  z-index: 5;
  padding: 18px 18px 16px;
  display: grid;
  gap: 16px;
  overflow: visible;
}

.brand-lockup h1 {
  margin: 0;
  font-family: "Archivo Black", system-ui, sans-serif;
  font-size: clamp(2.2rem, 11vw, 4.2rem);
  letter-spacing: 0.08em;
  line-height: 0.95;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.eyebrow,
.card-label,
.subhead {
  margin: 0;
}

.eyebrow,
.card-label {
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.subhead {
  margin-top: 8px;
  color: var(--text-soft);
  max-width: 32rem;
  font-size: 0.95rem;
}

.top-actions,
.icon-actions,
.meta-grid,
.playfield,
.result-actions {
  display: flex;
  gap: 8px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
}

.ghost-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 140ms ease-out,
    color 140ms ease-out,
    transform 140ms ease-out,
    box-shadow 140ms ease-out;
}

.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  background: rgba(58, 51, 52, 0.72);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ghost-icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
}

.primary-button {
  min-height: 40px;
  padding: 0 16px;
  background: var(--correct);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(91, 163, 208, 0.26);
}

.utility-select {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(58, 51, 52, 0.72);
  color: var(--text);
  cursor: pointer;
}

.language-picker {
  position: relative;
  min-width: 0;
}

.language-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.select-chevron {
  width: 10px;
  height: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-right: 2px solid var(--text-soft);
  border-bottom: 2px solid var(--text-soft);
  transform: translateY(-2px) rotate(45deg);
}

.language-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 12;
  display: grid;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(58, 51, 52, 0.98);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.34);
}

.language-option {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
  padding: 0 10px;
}

.language-option:hover,
.language-option:focus-visible,
.language-option.is-selected {
  background: var(--correct);
  color: var(--text);
}

.utility-select:focus-visible,
.ghost-button:focus-visible,
.primary-button:focus-visible {
  outline: 2px solid rgba(91, 163, 208, 0.88);
  outline-offset: 2px;
}

.status-strip {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.meta-card,
.message-card {
  background: var(--surface-strong);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.message-card,
.meta-card,
.board-card,
.hangman-card,
.keyboard-card {
  padding: 14px;
}

.meta-value,
.result-title {
  margin: 6px 0 0;
}

.message-card p:last-child,
.result-copy {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.meta-grid {
  flex-wrap: wrap;
  min-width: 0;
}

.meta-card {
  flex: 1 1 96px;
  min-width: 0;
}

.meta-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.life-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
}

.life-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--bg-dark);
  transition: background-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.life-dot.is-on {
  background: var(--correct);
  box-shadow: 0 0 10px rgba(91, 163, 208, 0.48);
}

.playfield {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(420px, 1.4fr);
  gap: 8px;
  min-width: 0;
  align-items: stretch;
}

.hangman-card,
.board-card {
  flex: 1 1 0;
  min-width: 0;
}
.board-card {
  overflow: hidden;
}

.hangman-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.drawing-frame {
  width: 100%;
  min-height: 216px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 14px;
}

.hangman-svg {
  width: min(100%, 190px);
  overflow: visible;
}

.gallows-piece,
.hangman-part {
  fill: none;
  stroke-linecap: round;
}

.gallows-piece {
  stroke: var(--bg-dark);
  stroke-width: 5;
}

.hangman-part {
  stroke: var(--wrong);
  stroke-width: 4;
  opacity: 0;
  transform-origin: center;
}

.hangman-part.is-visible {
  opacity: 1;
  animation: part-appear 300ms ease-out;
}

.word-row {
  display: grid;
  gap: clamp(0.35rem, 1vw, 0.75rem);
  justify-items: center;
  align-items: center;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.word-line {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: clamp(0.35rem, 1vw, 0.75rem);
  overflow: hidden;
}

.word-tile {
  flex: 1 1 0;
  min-width: 0;
  max-width: 4.1rem;
  min-height: clamp(2.25rem, 9vw, 3rem);
  aspect-ratio: 1;
  border: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bg-dark);
  color: var(--text);
  font: inherit;
  padding: 0;
  box-shadow: var(--shadow-key);
  position: relative;
  overflow: hidden;
}

.word-tile:disabled {
  cursor: default;
}

.word-tile::after {
  content: "";
  position: absolute;
  inset: auto 10px 8px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.word-tile.is-revealed {
  background: var(--correct);
}

.word-tile.is-hinted {
  background: #d2aa50;
}

.word-tile.is-unlockable {
  cursor: pointer;
  box-shadow:
    inset 0 0 0 2px rgba(210, 170, 80, 0.9),
    var(--shadow-key);
  animation: unlockable-pulse 900ms ease-out infinite alternate;
}

.word-letter {
  position: relative;
  z-index: 1;
  font-size: clamp(1.2rem, 2.2vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.word-tile.is-revealed .word-letter {
  animation: letter-reveal 500ms ease-out both;
}

.hint-token-button {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(58, 51, 52, 0.72);
  color: var(--text);
  box-shadow: var(--shadow-key);
  cursor: pointer;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition:
    background-color 140ms ease-out,
    border-color 140ms ease-out,
    color 140ms ease-out,
    transform 140ms ease-out,
    box-shadow 140ms ease-out,
    opacity 140ms ease-out;
}

.hint-token-button:hover:not(:disabled),
.hint-token-button:focus-visible:not(:disabled) {
  background: rgba(58, 51, 52, 0.88);
  border-color: rgba(210, 170, 80, 0.45);
  transform: translateY(-1px);
}

.hint-token-button:active:not(:disabled) {
  transform: scale(0.96);
}

.hint-token-button:disabled {
  cursor: default;
  opacity: 0.46;
  box-shadow: none;
}

.hint-token-button.is-active {
  color: #f0d27b;
  border-color: rgba(210, 170, 80, 0.62);
  background: rgba(58, 51, 52, 0.92);
  box-shadow:
    0 0 0 2px rgba(210, 170, 80, 0.22),
    0 8px 18px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px);
}

.hint-token-icon {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hint-token-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.hint-token-count {
  min-width: 1.3em;
  color: #f0d27b;
  font-weight: 700;
}

.wrong-area {
  margin-top: 18px;
}

.wrong-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}

.wrong-chip {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--wrong);
  color: var(--text);
  font-weight: 600;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  animation: wrong-guess 400ms ease-out both;
}

.message-card,
.result-card {
  margin-top: 18px;
}

.message-card {
  min-height: 62px;
  display: grid;
  place-items: center;
  text-align: center;
}

.message-card p {
  margin: 0;
}

.result-card {
  background: rgba(58, 51, 52, 0.76);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px;
  animation: status-reveal 500ms ease-out both;
}

.result-copy {
  line-height: 1.5;
}

.result-actions {
  margin-top: 14px;
  flex-wrap: wrap;
}

.keyboard-card {
  padding: 14px 10px;
}

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

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.key {
  width: clamp(28px, 8vw, 46px);
  height: clamp(50px, 13vw, 62px);
  border: 0;
  border-radius: 6px;
  background: var(--key);
  color: var(--text);
  font-size: clamp(0.86rem, 2.8vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-key);
  touch-action: manipulation;
  cursor: pointer;
  transition:
    background-color 140ms ease-out,
    box-shadow 140ms ease-out,
    transform 140ms ease-out,
    opacity 140ms ease-out;
}

.key:hover:not(:disabled),
.key:focus-visible:not(:disabled) {
  background: var(--key-hover);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.key:active:not(:disabled) {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}

.key.is-correct,
.key.is-correct:hover,
.key.is-correct:focus-visible {
  background: var(--correct);
  box-shadow: none;
}

.key.is-hint,
.key.is-hint:hover,
.key.is-hint:focus-visible {
  background: #d2aa50;
  box-shadow: none;
}

.key.is-wrong,
.key.is-wrong:hover,
.key.is-wrong:focus-visible {
  background: var(--wrong);
  box-shadow: none;
}

.key:disabled {
  cursor: default;
  opacity: 0.72;
}

.hidden {
  display: none;
}

.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;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 16, 17, 0.62);
  backdrop-filter: blur(6px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-panel {
  width: min(100%, 620px);
  max-height: min(100vh - 36px, 760px);
  overflow: auto;
  background: rgba(74, 65, 63, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.35);
  padding: 16px;
  animation: status-reveal 220ms ease-out both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 10px 0 0;
  font-size: clamp(1.4rem, 5vw, 2rem);
}

.modal-intro {
  margin: 10px 0 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.help-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--text);
  display: grid;
  gap: 10px;
  line-height: 1.55;
}

.help-examples {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.help-examples-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.help-example {
  display: grid;
  gap: 8px;
}

.help-example-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.help-example-tile {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  background: rgba(58, 51, 52, 0.76);
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
}

.help-example-tile.is-correct {
  border-color: transparent;
  background: var(--correct);
}

.help-example-tile.is-hint {
  border-color: transparent;
  background: #d2aa50;
}

.help-example-tile.is-wrong {
  border-color: transparent;
  background: var(--wrong);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.help-example p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.help-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.help-info-card {
  background: rgba(58, 51, 52, 0.76);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px;
}

.help-info-card p:last-child {
  margin: 8px 0 0;
  color: var(--text-soft);
  line-height: 1.55;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .app-shell {
    display: block;
    padding: 10px 8px 14px;
  }

  .game {
    width: 100%;
    gap: 10px;
  }

  .topbar {
    padding: 14px;
    gap: 12px;
  }

  .brand-lockup h1 {
    font-size: clamp(2.4rem, 15vw, 3.25rem);
    letter-spacing: 0.06em;
  }

  .subhead {
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
    align-items: stretch;
  }

  .icon-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 64px;
    width: 100%;
  }

  .language-picker {
    grid-column: 1 / 3;
  }

  .icon-actions .ghost-icon-button {
    width: 100%;
    min-width: 0;
  }

  .modal-header .ghost-icon-button {
    width: 38px;
    min-width: 38px;
  }

  .ghost-button,
  .primary-button {
    padding-inline: 10px;
  }

  .status-strip,
  .message-card,
  .meta-card,
  .board-card,
  .hangman-card,
  .keyboard-card {
    padding: 12px;
  }

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

  .card-label {
    font-size: 0.62rem;
    line-height: 1.25;
  }

  .life-dots {
    gap: 7px;
  }

  .drawing-frame {
    min-height: 250px;
    padding-top: 0;
  }

  .hangman-svg {
    width: min(82%, 176px);
  }

  .hint-token-button {
    min-height: 38px;
    padding-inline: 10px;
  }

  .word-row {
    gap: 0.35rem;
  }

  .word-line {
    gap: 0.35rem;
  }

  .word-tile {
    max-width: 3rem;
  }

  .keyboard-card {
    padding-inline: 8px;
  }

  .keyboard {
    gap: 7px;
  }

  .keyboard-row {
    gap: 4px;
  }

  .key {
    width: clamp(24px, 7.8vw, 34px);
    height: 52px;
    min-width: 0;
  }
}

@media (min-width: 840px) {
  .topbar {
    grid-template-columns: 1.4fr auto;
    align-items: start;
  }

  .status-strip {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .playfield {
    grid-template-columns: minmax(260px, 0.9fr) minmax(420px, 1.4fr);
  }

  .keyboard-card {
    padding-inline: 18px;
  }

  .help-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 980px) {
  .playfield {
    grid-template-columns: 1fr;
  }

  .hangman-card {
    order: 1;
  }

  .board-card {
    order: 2;
  }

  .hint-token-button {
    align-self: center;
  }
}

@media (max-width: 600px) {
  .word-row[data-row-count="2"],
  .word-row[data-row-count="2"] .word-line {
    gap: clamp(0.18rem, 0.9vw, 0.3rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes letter-reveal {
  0% {
    transform: rotateY(90deg) scale(0.8);
    opacity: 0;
  }

  50% {
    transform: rotateY(45deg) scale(1.05);
  }

  100% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes unlockable-pulse {
  from {
    box-shadow:
      inset 0 0 0 2px rgba(210, 170, 80, 0.78),
      var(--shadow-key);
  }

  to {
    box-shadow:
      inset 0 0 0 3px rgba(210, 170, 80, 0.98),
      0 8px 18px rgba(0, 0, 0, 0.2);
  }
}

@keyframes wrong-guess {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }

  60% {
    transform: scale(1.15) rotate(10deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes status-reveal {
  0% {
    transform: translateY(-20px) scale(0.9);
    opacity: 0;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes part-appear {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }

  60% {
    transform: scale(1.1);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}
