:root {
  --bg: #68605d;
  --bg-deep: #3a3334;
  --surface: rgba(80, 70, 68, 0.42);
  --surface-strong: rgba(58, 51, 52, 0.48);
  --tile: #3a3334;
  --tile-soft: rgba(255, 255, 255, 0.08);
  --key: #625856;
  --key-hover: #736866;
  --key-wrong: #433c3b;
  --key-wrong-text: rgba(255, 255, 255, 0.58);
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.78);
  --correct: #5ba3d0;
  --hint: #d8b856;
  --hint-accent: rgb(218 185 114);
  --wrong: #d97b61;
  --teal: #47b8a6;
  --violet: #8c7bc9;
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.18);
  --shadow-key: 0 4px 12px rgba(0, 0, 0, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

html {
  background: var(--bg);
}

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

button {
  font: inherit;
}

body.modal-open {
  overflow: hidden;
}

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

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

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

.topbar {
  position: relative;
  z-index: 5;
  padding: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  overflow: visible;
}

.brand-lockup {
  min-width: 0;
}

.brand-lockup h1 {
  margin: 0;
  max-width: 100%;
  font-family: Impact, Haettenschweiler, "Arial Black", system-ui, sans-serif;
  font-size: 4rem;
  letter-spacing: 0;
  line-height: 0.92;
  overflow-wrap: anywhere;
  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;
  font-size: 0.72rem;
  font-weight: 700;
}

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

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

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

.utility-select {
  padding: 0 12px;
}

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

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

.select-chevron {
  width: 10px;
  height: 10px;
  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: var(--radius);
  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);
}

.ghost-icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-weight: 800;
}

.status-strip {
  padding: 14px;
}

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

.meta-card {
  min-width: 0;
  padding: 14px;
  background: var(--surface-strong);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-value {
  margin: 7px 0 0;
  font-size: 1.35rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.playfield {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.side-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.word-card {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  gap: 14px;
  min-height: 152px;
}

.word-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.language-chip {
  min-height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.language-mark {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--correct);
}

.word-card[data-language="Portuguese"] .language-mark {
  background: var(--teal);
}

.word-card[data-language="English"] .language-mark {
  background: var(--correct);
}

.word-card[data-language="Spanish"] .language-mark {
  background: var(--hint);
}

.word-card[data-language="Italian"] .language-mark,
.word-card[data-language="Italiano"] .language-mark {
  background: var(--wrong);
}

.word-card[data-language="French"] .language-mark,
.word-card[data-language="Français"] .language-mark {
  background: var(--violet);
}

.word-card[data-code="pt"] .language-mark {
  background: var(--teal);
}

.word-card[data-code="en"] .language-mark {
  background: var(--correct);
}

.word-card[data-code="es"] .language-mark {
  background: var(--hint);
}

.word-card[data-code="it"] .language-mark {
  background: var(--wrong);
}

.word-card[data-code="fr"] .language-mark {
  background: var(--violet);
}

.tile-row {
  display: flex;
  align-content: center;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.word-tile {
  width: var(--word-tile-size, 42px);
  height: var(--word-tile-size, 42px);
  border: 0;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--tile);
  box-shadow: var(--shadow-key);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  padding: 0;
  position: relative;
  overflow: hidden;
}

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

.word-tile::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 8px;
  height: 3px;
  border-radius: 99px;
  background: var(--tile-soft);
}

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

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

.word-tile.is-hinted::after {
  background: var(--hint-accent);
}

.word-tile.is-static {
  background: transparent;
  box-shadow: none;
}

.word-tile.is-static::after {
  display: none;
}

.word-tile.is-unlockable {
  cursor: pointer;
  box-shadow:
    inset 0 0 0 2px rgba(210, 170, 80, 0.9),
    var(--shadow-key);
}

.word-letter {
  position: relative;
  z-index: 1;
}

.round-panel,
.unlock-panel {
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.unlock-panel {
  gap: 12px;
}

.language-selector {
  display: grid;
  gap: 10px;
}

.active-language-zone,
.inactive-language-zone {
  display: grid;
  gap: 8px;
}

.active-language-zone {
  padding: 10px;
  border: 2px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
}

.active-language-zone.is-drop-target {
  border-color: rgba(91, 163, 208, 0.8);
  background: rgba(91, 163, 208, 0.08);
}

.active-language-zone.is-disabled {
  pointer-events: none;
}

.inactive-language-zone .card-label {
  text-align: center;
  color: rgba(255, 255, 255, 0.38);
}

.language-token-list {
  display: grid;
  gap: 7px;
  min-height: 36px;
}

.language-token {
  min-height: 34px;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(58, 51, 52, 0.78);
  color: var(--text);
  cursor: grab;
  text-align: left;
  touch-action: manipulation;
}

.language-token:active {
  cursor: grabbing;
}

.language-token.is-inactive {
  opacity: 0.48;
}

.language-token.is-dragging {
  opacity: 0.34;
}

.language-token-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  font-size: 0.86rem;
}

.language-token-code {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.language-token .language-mark {
  flex: 0 0 auto;
}

.language-token[data-code="pt"] .language-mark {
  background: var(--teal);
}

.language-token[data-code="en"] .language-mark {
  background: var(--correct);
}

.language-token[data-code="es"] .language-mark {
  background: var(--hint);
}

.language-token[data-code="fr"] .language-mark {
  background: var(--violet);
}

.language-token[data-code="it"] .language-mark {
  background: #d97b61;
}

.drawing-frame {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 4px 0 2px;
}

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

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

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

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

.hangman-part.is-visible {
  opacity: 1;
}

.misses-block {
  min-width: 0;
}

.chances-row {
  min-height: 34px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.chance-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 26px;
}

.chance-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--bg-deep);
}

.chance-dot.is-on {
  background: var(--correct);
  box-shadow: 0 0 10px rgba(103, 174, 211, 0.42);
}

.hint-token-button {
  width: 100%;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

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

.hint-token-button strong {
  color: #f1d66d;
}

.hint-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
}

.hint-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.miss-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: 800;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.round-message {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
  font-size: 0.94rem;
}

.result-card {
  background: rgba(58, 51, 52, 0.76);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px;
}

.result-title,
.result-copy {
  margin: 0;
}

.result-title {
  font-weight: 800;
}

.result-copy {
  margin-top: 8px;
  color: var(--text-soft);
  line-height: 1.4;
}

.primary-button {
  min-height: 40px;
  margin-top: 14px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--correct);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.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: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: var(--shadow-key);
  cursor: pointer;
  touch-action: manipulation;
  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: var(--hint);
  box-shadow: none;
}

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

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

.key.is-wrong:disabled {
  opacity: 1;
}

.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(0, 0, 0, 0.44);
}

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

.modal-panel {
  width: min(100%, 520px);
  max-height: min(680px, 92vh);
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(58, 51, 52, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
}

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

.modal-title {
  margin: 12px 0 0;
  font-size: 1.45rem;
}

.modal-intro,
.help-list {
  color: var(--text-soft);
  line-height: 1.5;
}

.modal-intro {
  margin: 10px 0 0;
}

.help-list {
  margin: 14px 0 0;
  padding-left: 1.2rem;
}

.help-tile-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.help-tile-example {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
}

.help-word-tile {
  width: 38px;
  height: 38px;
  pointer-events: none;
}

.help-tile-label {
  max-width: 100%;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

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

  .topbar {
    display: grid;
  }

  .brand-lockup h1 {
    font-size: 3rem;
  }

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

  .playfield {
    display: grid;
  }

  .round-panel,
  .unlock-panel {
    grid-row: auto;
  }

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

@media (max-width: 560px) {
  .app-shell {
    padding: 10px 8px;
  }

  .game {
    gap: 10px;
  }

  .topbar {
    padding: 12px;
  }

  .brand-lockup h1 {
    font-size: 2.35rem;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .language-picker {
    flex: 1 1 auto;
  }

  .status-strip {
    padding: 8px;
  }

  .meta-grid,
  .playfield,
  .word-grid {
    gap: 8px;
  }

  .meta-card {
    padding: 10px;
  }

  .meta-value {
    margin-top: 4px;
    font-size: 1.2rem;
  }

  .side-column {
    gap: 8px;
  }

  .round-panel,
  .unlock-panel {
    padding: 10px;
    gap: 10px;
  }

  .drawing-frame {
    min-height: 156px;
  }

  .hangman-svg {
    width: 150px;
  }

  .word-card {
    min-height: 0;
    padding: 10px 8px;
    gap: 12px;
  }

  .language-chip {
    min-height: 26px;
    padding: 0 9px;
    gap: 7px;
    font-size: 0.8rem;
  }

  .language-mark {
    width: 9px;
    height: 9px;
  }

  .tile-row {
    gap: 5px;
  }

  .word-tile {
    font-size: 1rem;
    border-radius: 7px;
  }

  .word-tile::after {
    left: 6px;
    right: 6px;
    bottom: 6px;
    height: 3px;
  }

  .keyboard-card {
    padding-inline: 8px;
    margin-bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .chances-row {
    min-height: 26px;
    margin-bottom: 8px;
  }

  .chance-dot {
    width: 11px;
    height: 11px;
  }

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

  .keyboard-row {
    gap: 4px;
  }
}
