:root {
  --soft: #f4f7f1;
  --ok: #0d5f3e;
  --bad: #7f1d1d;

  --hero-start: #496189;
  --hero-end: #2c3f5f;

  --kb-gap: 8px;
  --kb-max: 660px;
}

.setup {
  height: 100%;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(12px, 2vw, 16px);
  overflow: hidden;
}

.hero {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(145deg, #8a644d, #614634);
  position: relative;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.heroInner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1 1 auto;
}

.heroTitle {
  margin: 0;
  font-size: clamp(20px, 3.2vw, 34px);
  font-weight: 400;
  font-family: "CMB", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.2px;
  color: #f7f9f2;
  text-shadow: 0 1px 0 rgba(8, 20, 14, 0.45);
}

.heroDesc {
  margin: 0;
  max-width: 58ch;
  font-weight: 750;
  line-height: 1.35;
  color: #f7f9f2;
}

input,
select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 14px;
  background: #fff;
  outline: none;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.spacer {
  flex: 1 1 auto;
  min-height: 10px;
}

.startRow {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.game {
  height: 100%;
  display: grid;
  grid-template-columns: 1.45fr 0.55fr;
  gap: clamp(12px, 2vw, 16px);
  overflow: hidden;
  align-items: stretch;
}

.main {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.mainTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

.hearts {
  font-size: 18px;
  letter-spacing: 2px;
  line-height: 1.1;
  text-align: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--soft);
  border-radius: 16px;
  flex: 0 0 auto;
  margin-bottom: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wordBox {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--soft);
  border-radius: 18px;
  padding: clamp(12px, 1.8vw, 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(92px, 14vh, 150px);
  margin-bottom: 10px;
  overflow: hidden;
}

.wordDisplay {
  font-family: "CMB", "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.05;
  text-align: center;
  color: #0b1220;
  white-space: nowrap;
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  letter-spacing: clamp(4px, 1vw, 12px);
  font-size: clamp(18px, 3vw, 44px);
  transform-origin: center;
}

.keyboardWrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.keyboard {
  width: 100%;
  max-width: var(--kb-max);
  max-height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.kbRow {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--maxCols), 1fr);
  gap: var(--kb-gap);
  justify-content: center;
}

.key,
.keySpacer {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 950;
  font-size: clamp(13px, 1.6vw, 17px);
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.06);
  user-select: none;
  color: #111827;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.key {
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.12s ease, background 0.12s ease, color 0.12s ease;
}

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

.keySpacer {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
}

.key.used {
  background: #111827;
  color: #fff;
  pointer-events: none;
  filter: none;
}

.key.good {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: var(--ok);
  pointer-events: none;
}

.key.bad {
  background: #fee2e2;
  border-color: #fecaca;
  color: var(--bad);
  pointer-events: none;
}

.side {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.stat.hidden {
  display: none;
}

.msg {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--soft);
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 850;
  line-height: 1.25;
  min-height: 64px;
}

.msg strong {
  color: var(--text);
  font-family: "CMB", "Segoe UI", system-ui, sans-serif;
  font-weight: 400;
}

.sideButtons {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

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

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

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

  .side {
    min-height: 220px;
  }

  :root {
    --kb-max: 720px;
  }
}

@media (max-height: 720px) {
  :root {
    --kb-gap: 6px;
  }

  .wordBox {
    min-height: 84px;
  }

  .keyboard {
    gap: 8px;
  }
}
