:root {
  color-scheme: light;
  --app-height: 100vh;
  --bg: #eef4f7;
  --bg-2: #f8fbfc;
  --surface: #ffffff;
  --surface-soft: #f3f7f9;
  --surface-strong: #e7f0f4;
  --ink: #14212b;
  --muted: #647484;
  --line: #d8e3e8;
  --line-strong: #bdd0d8;
  --primary: #27657f;
  --primary-dark: #17475d;
  --primary-soft: #e4f1f5;
  --accent: #f0ad3d;
  --accent-soft: #fff4dd;
  --good: #247a55;
  --good-soft: #e8f7ef;
  --bad: #b84848;
  --bad-soft: #fff0ef;
  --warn: #9a650f;
  --warn-soft: #fff5df;
  --shadow-sm: 0 6px 18px rgba(24, 45, 59, 0.08);
  --shadow: 0 18px 55px rgba(24, 45, 59, 0.12);
  --radius-sm: 14px;
  --radius: 24px;
  --radius-lg: 32px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: var(--app-height, 100vh);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(240, 173, 61, 0.24), transparent 28%),
    radial-gradient(circle at 86% 4%, rgba(39, 101, 127, 0.20), transparent 30%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  background-image:
    linear-gradient(rgba(20, 33, 43, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 33, 43, .045) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 72%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
input, select { user-select: text; }
button, input, select, dialog { outline: none; }
button:focus-visible, input:focus-visible, select:focus-visible {
  box-shadow: 0 0 0 4px rgba(39, 101, 127, .18);
  border-color: var(--primary);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar, .game-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar {
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid rgba(216, 227, 232, .84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}

.topbar > div:first-child {
  position: relative;
  padding-left: 58px;
}

.topbar > div:first-child::before {
  content: "M";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: white;
  font-weight: 950;
  letter-spacing: -.06em;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 24px rgba(23, 71, 93, .24);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 5.2vw, 3.35rem); letter-spacing: -0.06em; line-height: .95; }
h2 { margin-bottom: 10px; font-size: clamp(1.48rem, 3.5vw, 2.35rem); letter-spacing: -0.045em; line-height: 1.05; }
h3 { margin-bottom: 12px; font-size: 1.04rem; }
p { line-height: 1.5; }

.eyebrow, .section-label {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .105em;
  text-transform: uppercase;
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.card {
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(216, 227, 232, .94);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 26px;
  align-items: center;
  margin-bottom: 18px;
  min-height: 210px;
  color: white;
  background:
    linear-gradient(135deg, rgba(23, 71, 93, .96), rgba(39, 101, 127, .94)),
    radial-gradient(circle at top right, rgba(240, 173, 61, .42), transparent 38%);
  border: 0;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -120px;
  width: 310px;
  height: 310px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}

.hero > * { position: relative; z-index: 1; }
.hero p { color: rgba(255, 255, 255, .78); margin-bottom: 0; font-size: 1.08rem; max-width: 56ch; }
.hero h2 { max-width: 10ch; }

.mini-path {
  display: grid;
  gap: 9px;
  min-width: 126px;
}

.mini-path span {
  display: block;
  padding: 8px 12px;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 13px;
  font-weight: 950;
  letter-spacing: .09em;
  text-align: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .10);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

@media (min-width: 900px) {
  .mode-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.mode-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-height: 160px;
  padding: 18px;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.mode-card::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: var(--primary-dark);
  font-size: 1.28rem;
  font-weight: 950;
  background: var(--primary-soft);
  border: 1px solid rgba(39, 101, 127, .12);
}
.mode-card[data-mode="infinite"]::before { content: "∞"; }
.mode-card[data-mode="daily"]::before { content: "◆"; color: var(--warn); background: var(--accent-soft); }
.mode-card[data-mode="free"]::before { content: "Aa"; font-size: 1rem; }
.mode-card[data-mode="timeAttack"]::before { content: "⏱"; color: var(--bad); background: var(--bad-soft); }

.mode-card::after {
  content: "";
  position: absolute;
  inset: auto -26px -34px auto;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(39, 101, 127, .06);
  z-index: -1;
}

.mode-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.mode-card strong { display: block; font-size: 1.13rem; letter-spacing: -.02em; }
.mode-card span { color: var(--muted); line-height: 1.38; }

.stats-card {
  padding: 20px;
  background: rgba(255, 255, 255, .78);
}
.stats-card h3 { margin-bottom: 14px; }
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(152px, 1fr));
  gap: 10px;
}
.stats-row div {
  position: relative;
  overflow: hidden;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.stats-row div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary);
}
.stats-row div:nth-child(2)::before, .stats-row div:nth-child(4)::before { background: var(--accent); }
.stats-row div:nth-child(3)::before { background: var(--good); }
.stats-row div:nth-child(5)::before { background: var(--bad); }
.stats-row strong { display: block; font-size: 1.55rem; line-height: 1; letter-spacing: -.04em; }
.stats-row span { display: block; margin-top: 7px; color: var(--muted); font-size: .88rem; font-weight: 760; }

.primary-btn, .secondary-btn, .ghost-btn, .back-btn {
  border-radius: 999px;
  min-height: 46px;
  padding: 10px 17px;
  font-weight: 900;
  border: 1px solid transparent;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}
.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 24px rgba(23, 71, 93, .18);
}
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 28px rgba(23, 71, 93, .23); }
.secondary-btn { background: var(--primary-soft); color: var(--primary-dark); border-color: rgba(39, 101, 127, .14); }
.secondary-btn:hover { background: #d9ebf1; transform: translateY(-1px); }
.ghost-btn, .back-btn { background: var(--surface); color: var(--ink); border-color: var(--line); }
.ghost-btn:hover, .back-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
#solutionBtn { background: var(--warn-soft); color: var(--warn); border-color: rgba(154, 101, 15, .18); }
#skipBtn { background: var(--bad-soft); color: var(--bad); border-color: rgba(184, 72, 72, .18); }

.setup-card { max-width: 650px; margin: 0 auto; }
.setup-fields { display: grid; gap: 14px; margin-top: 18px; }
label { display: grid; gap: 8px; font-weight: 900; }
input, select {
  min-height: 50px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(20, 33, 43, .02);
}
.hint { color: var(--muted); margin-bottom: 0; }

#gameScreen.active {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, .72fr);
  gap: 18px;
  align-items: start;
}
#gameScreen .game-nav { grid-column: 1 / -1; margin-bottom: 0; }

.game-card { margin-bottom: 0; }
.game-header, .history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.timer-box {
  min-width: 104px;
  text-align: right;
  background: var(--bad-soft);
  border: 1px solid rgba(184, 72, 72, .18);
  border-radius: 18px;
  padding: 11px 13px;
}
.timer-box span { display:block; color: var(--bad); font-size: .72rem; font-weight: 950; letter-spacing: .09em; text-transform: uppercase; }
.timer-box strong { font-size: 1.35rem; letter-spacing: -.03em; color: var(--ink); }

.goal-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 18px 0;
}
.goal-row > div:not(.arrow) {
  position: relative;
  overflow: hidden;
  padding: 15px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 19px;
}
.goal-row > div:not(.arrow)::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 4px;
  background: var(--primary);
}
.goal-row > div:last-child::after { background: var(--accent); }
.goal-row span { display: block; color: var(--muted); font-size: .74rem; font-weight: 950; letter-spacing: .09em; text-transform: uppercase; }
.goal-row strong { display: block; margin-top: 3px; font-size: clamp(1.25rem, 4.8vw, 1.9rem); letter-spacing: .08em; }
.arrow { color: var(--muted); font-weight: 950; font-size: 1.4rem; }

.turn-box {
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 17px;
  background: var(--accent-soft);
  border: 1px solid rgba(240, 173, 61, .34);
  color: var(--warn);
  font-weight: 900;
}

.rules-panel {
  position: relative;
  padding: 15px 15px 15px 50px;
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  border: 1px solid var(--line);
  border-radius: 19px;
  margin-bottom: 18px;
}
.rules-panel::before {
  content: "i";
  position: absolute;
  top: 15px;
  left: 15px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  font-weight: 950;
  font-style: italic;
}
.rules-panel h3 { margin-bottom: 8px; font-size: 1rem; }
.rules-panel ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.58; }

.word-area {
  text-align: center;
  margin: 22px 0 18px;
  padding: 20px 12px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--primary-soft), rgba(228, 241, 245, .42));
  border: 1px solid rgba(39, 101, 127, .10);
}
.letter-slots {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 2vw, 13px);
  flex-wrap: wrap;
}
.letter-slot {
  width: clamp(50px, 12vw, 72px);
  height: clamp(58px, 14vw, 80px);
  border: 2px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: clamp(1.65rem, 7vw, 2.55rem);
  font-weight: 950;
  letter-spacing: .045em;
  box-shadow: 0 8px 18px rgba(24, 45, 59, .07);
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.letter-slot.selected {
  transform: translateY(-3px);
  border-color: var(--primary);
  background: #f8fdff;
  box-shadow: 0 12px 28px rgba(39, 101, 127, .18);
}
.selected-hint { margin: 12px 0 0; color: var(--muted); font-size: .94rem; font-weight: 700; }

.keyboard-wrap { margin-top: 6px; }
.keyboard {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 7px;
}
.key-btn {
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-weight: 950;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(24, 45, 59, .04);
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.key-btn:disabled { opacity: .34; cursor: not-allowed; box-shadow: none; }
.key-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--primary); background: var(--primary-soft); }

.actions-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.message-box {
  min-height: 46px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 750;
}
.message-box.good { color: var(--good); border-color: rgba(36,122,85,.28); background: var(--good-soft); }
.message-box.bad { color: var(--bad); border-color: rgba(184,72,72,.28); background: var(--bad-soft); }
.message-box.warn { color: var(--warn); border-color: rgba(154,101,15,.28); background: var(--warn-soft); }

.history-card {
  position: sticky;
  top: 18px;
}
.history-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  counter-reset: path;
}
.history-list li {
  position: relative;
  padding: 10px 12px 10px 42px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-weight: 900;
  letter-spacing: .06em;
  counter-increment: path;
}
.history-list li::before {
  content: counter(path);
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: .72rem;
  font-weight: 950;
  letter-spacing: 0;
}
.history-header span { color: var(--muted); font-weight: 850; }

.modal {
  width: min(610px, calc(100% - 30px));
  border: 0;
  padding: 0;
  border-radius: 28px;
  background: transparent;
}
.modal::backdrop { background: rgba(14, 25, 33, .48); backdrop-filter: blur(4px); }
.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 26px;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 1.4rem;
  color: var(--ink);
}
.modal-content ul { color: var(--muted); line-height: 1.55; padding-left: 20px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.stars-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--warn);
  font-size: 2rem;
  letter-spacing: .12em;
  white-space: pre-line;
}
.stars-box:not(:empty) { line-height: 1.45; }

@media (max-width: 860px) {
  .app-shell { padding: 14px; }
  #gameScreen.active { grid-template-columns: 1fr; }
  .history-card { position: static; }
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero h2 { max-width: 14ch; }
  .mini-path { grid-template-columns: repeat(5, 1fr); min-width: 0; }
  .mini-path span { font-size: .8rem; padding: 8px 6px; }
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .mode-card { min-height: 145px; }
  .stats-row, .actions-row { grid-template-columns: 1fr; }
  .keyboard { grid-template-columns: repeat(7, 1fr); }
  .game-header { align-items: stretch; }
}

@media (max-width: 520px) {
  .topbar { align-items: flex-start; }
  .topbar > div:first-child { padding-left: 52px; }
  .topbar > div:first-child::before { width: 40px; height: 40px; border-radius: 14px; }
  .card { padding: 18px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 132px; }
  .goal-row { grid-template-columns: 1fr; text-align: center; }
  .arrow { transform: rotate(90deg); }
  .keyboard { grid-template-columns: repeat(6, 1fr); }
  .modal-actions { display: grid; }
  .modal-actions > button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* Ajustes de juego: botones de información/historial y teclado QWERTY */
.game-nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.icon-text-btn {
  padding-inline: 14px;
}
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 7px;
}
.keyboard-row:nth-child(2) { padding-inline: clamp(10px, 4vw, 30px); }
.keyboard-row:nth-child(3) { padding-inline: clamp(26px, 8vw, 64px); }
.key-btn {
  flex: 1 1 0;
  max-width: 54px;
}
.modal-subtitle {
  margin-top: -4px;
  color: var(--muted);
  font-weight: 850;
}
.history-list-modal {
  max-height: min(62vh, 460px);
  overflow: auto;
  padding-right: 4px;
}

@media (max-width: 700px) {
  body.is-playing {
    overflow: hidden;
  }
  body.is-playing .app-shell {
    height: 100svh;
    min-height: 100svh;
    padding: 8px;
    overflow: hidden;
  }
  body.is-playing .topbar {
    display: none;
  }
  body.is-playing main,
  body.is-playing #gameScreen.active {
    height: 100%;
    min-height: 0;
  }
  body.is-playing #gameScreen.active {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
  }
  body.is-playing .game-nav {
    min-height: 42px;
    margin: 0;
    gap: 8px;
  }
  body.is-playing .game-nav .back-btn,
  body.is-playing .game-nav .ghost-btn {
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 13px;
    font-size: .86rem;
  }
  body.is-playing .game-nav-actions {
    gap: 6px;
    flex-wrap: nowrap;
  }
  body.is-playing .game-card {
    min-height: 0;
    height: 100%;
    padding: 10px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  body.is-playing .game-header {
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
  }
  body.is-playing .game-header h2 {
    margin: 0;
    font-size: clamp(1.08rem, 5vw, 1.34rem);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.is-playing .game-header .eyebrow {
    margin-bottom: 3px;
    font-size: .62rem;
  }
  body.is-playing .timer-box {
    min-width: 82px;
    padding: 7px 9px;
    border-radius: 14px;
  }
  body.is-playing .timer-box strong { font-size: 1rem; }
  body.is-playing .goal-row {
    flex: 0 0 auto;
    grid-template-columns: 1fr auto 1fr;
    gap: 6px;
    margin: 8px 0;
    text-align: center;
  }
  body.is-playing .goal-row > div:not(.arrow) {
    padding: 9px 6px;
    border-radius: 15px;
  }
  body.is-playing .goal-row span { font-size: .58rem; }
  body.is-playing .goal-row strong {
    margin-top: 2px;
    font-size: clamp(1.08rem, 7vw, 1.45rem);
    letter-spacing: .07em;
  }
  body.is-playing .arrow {
    transform: none;
    font-size: 1.05rem;
  }
  body.is-playing .rules-panel,
  body.is-playing .history-card {
    display: none;
  }
  body.is-playing .turn-box {
    flex: 0 0 auto;
    margin: 0 0 6px;
    padding: 8px 10px;
    border-radius: 14px;
    font-size: .84rem;
  }
  body.is-playing .word-area {
    flex: 0 0 auto;
    margin: 6px 0 8px;
    padding: 10px 6px;
    border-radius: 18px;
  }
  body.is-playing .word-area .section-label {
    margin-bottom: 5px;
    font-size: .58rem;
  }
  body.is-playing .letter-slots {
    gap: 7px;
    flex-wrap: nowrap;
  }
  body.is-playing .letter-slot {
    width: min(19.5vw, 60px);
    height: min(20vw, 64px);
    min-width: 48px;
    min-height: 52px;
    border-radius: 15px;
    font-size: clamp(1.55rem, 9vw, 2.12rem);
  }
  body.is-playing .letter-slot.selected {
    transform: translateY(-2px);
  }
  body.is-playing .selected-hint {
    margin-top: 7px;
    font-size: .78rem;
  }
  body.is-playing .keyboard-wrap {
    flex: 0 0 auto;
    margin-top: 0;
  }
  body.is-playing .keyboard-wrap .section-label {
    display: none;
  }
  body.is-playing .keyboard {
    gap: 5px;
  }
  body.is-playing .keyboard-row {
    gap: 4px;
  }
  body.is-playing .keyboard-row:nth-child(2) { padding-inline: 12px; }
  body.is-playing .keyboard-row:nth-child(3) { padding-inline: 34px; }
  body.is-playing .key-btn {
    min-height: 35px;
    max-width: none;
    border-radius: 10px;
    font-size: .92rem;
    padding: 0;
  }
  body.is-playing .actions-row {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
  }
  body.is-playing .actions-row > button {
    min-height: 36px;
    padding: 8px 8px;
    border-radius: 12px;
    font-size: .82rem;
  }
  body.is-playing .message-box {
    flex: 0 0 auto;
    min-height: 38px;
    max-height: 58px;
    margin-top: 8px;
    padding: 9px 10px;
    border-radius: 13px;
    font-size: .78rem;
    line-height: 1.25;
    overflow: hidden;
  }
}

@media (max-width: 380px) {
  body.is-playing .game-nav .back-btn,
  body.is-playing .game-nav .ghost-btn {
    padding-inline: 8px;
    font-size: .78rem;
  }
  body.is-playing .keyboard-row:nth-child(2) { padding-inline: 8px; }
  body.is-playing .keyboard-row:nth-child(3) { padding-inline: 24px; }
  body.is-playing .key-btn { min-height: 32px; font-size: .82rem; }
  body.is-playing .letter-slot {
    min-width: 42px;
    min-height: 48px;
  }
  body.is-playing .actions-row > button { font-size: .76rem; }
}


/* Ajuste móvil: teclado más grande, menos aire y botones consistentes */
.game-card,
.game-nav,
.actions-row,
.keyboard-wrap,
.word-area,
.goal-row {
  box-sizing: border-box;
}

.actions-row > button,
.game-nav button {
  min-width: 0;
  white-space: nowrap;
}

@media (max-width: 700px) {
  body.is-playing .app-shell {
    padding: max(7px, env(safe-area-inset-top)) 7px max(7px, env(safe-area-inset-bottom));
  }

  body.is-playing #gameScreen.active {
    gap: 7px;
  }

  body.is-playing .game-nav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    min-height: 40px;
    gap: 7px;
  }

  body.is-playing .game-nav-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
  }

  body.is-playing .game-nav .back-btn,
  body.is-playing .game-nav .ghost-btn {
    min-height: 38px;
    padding: 7px 8px;
    border-radius: 13px;
    font-size: clamp(.74rem, 3.1vw, .86rem);
  }

  body.is-playing .game-card {
    height: 100%;
    padding: clamp(10px, 2.9vw, 14px);
    border-radius: 21px;
    justify-content: space-between;
    gap: clamp(7px, 1.6svh, 12px);
  }

  body.is-playing .game-header {
    min-height: 0;
  }

  body.is-playing .game-header h2 {
    font-size: clamp(1.1rem, 5.1vw, 1.42rem);
  }

  body.is-playing .timer-box {
    min-width: clamp(84px, 24vw, 106px);
  }

  body.is-playing .goal-row {
    width: 100%;
    gap: clamp(6px, 2vw, 10px);
    margin: 0;
  }

  body.is-playing .goal-row > div:not(.arrow) {
    padding: clamp(10px, 3.2vw, 14px) 7px;
    border-radius: 16px;
  }

  body.is-playing .goal-row span {
    font-size: clamp(.58rem, 2.2vw, .68rem);
  }

  body.is-playing .goal-row strong {
    font-size: clamp(1.22rem, 7.4vw, 1.7rem);
  }

  body.is-playing .turn-box {
    margin: 0;
  }

  body.is-playing .word-area {
    width: 100%;
    margin: 0;
    padding: clamp(11px, 3.2vw, 16px) 7px clamp(10px, 2.6vw, 14px);
    border-radius: 19px;
  }

  body.is-playing .letter-slots {
    gap: clamp(8px, 2.4vw, 12px);
  }

  body.is-playing .letter-slot {
    width: clamp(54px, 20.5vw, 72px);
    height: clamp(58px, 20.8vw, 76px);
    min-width: 0;
    min-height: 0;
    border-radius: clamp(15px, 4vw, 20px);
    font-size: clamp(1.72rem, 9.5vw, 2.38rem);
  }

  body.is-playing .selected-hint {
    margin-top: clamp(6px, 1.3svh, 10px);
    font-size: clamp(.78rem, 3vw, .9rem);
  }

  body.is-playing .keyboard-wrap {
    width: 100%;
    flex: 1 1 auto;
    min-height: 142px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    flex-direction: column;
    margin: 0;
  }

  body.is-playing .keyboard {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    gap: clamp(5px, 1.4vw, 8px);
  }

  body.is-playing .keyboard-row {
    width: 100%;
    gap: clamp(4px, 1.35vw, 7px);
  }

  body.is-playing .keyboard-row:nth-child(2) {
    padding-inline: clamp(7px, 3.2vw, 16px);
  }

  body.is-playing .keyboard-row:nth-child(3) {
    padding-inline: clamp(34px, 11vw, 66px);
  }

  body.is-playing .key-btn {
    min-height: clamp(43px, 7.15svh, 54px);
    border-radius: clamp(11px, 3.2vw, 15px);
    font-size: clamp(.98rem, 4vw, 1.16rem);
    box-shadow: 0 5px 12px rgba(24, 45, 59, .07);
  }

  body.is-playing .actions-row {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(7px, 2vw, 10px);
    margin: 0;
  }

  body.is-playing .actions-row > button {
    min-height: clamp(41px, 6.4svh, 48px);
    padding: 8px 8px;
    border-radius: 14px;
    font-size: clamp(.8rem, 3.25vw, .92rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  body.is-playing:not([data-mode="timeAttack"]) .actions-row #solutionBtn,
  body.is-playing[data-mode="timeAttack"] .actions-row #skipBtn {
    grid-column: 1 / -1;
  }

  body.is-playing .message-box {
    width: 100%;
    min-height: clamp(42px, 6.8svh, 54px);
    max-height: clamp(48px, 8.6svh, 68px);
    margin: 0;
    padding: 10px 11px;
    border-radius: 14px;
    font-size: clamp(.78rem, 3vw, .9rem);
    display: flex;
    align-items: center;
  }
}

@media (max-width: 380px) {
  body.is-playing .app-shell {
    padding-inline: 6px;
  }

  body.is-playing #gameScreen.active {
    gap: 6px;
  }

  body.is-playing .game-nav-actions {
    gap: 4px;
  }

  body.is-playing .game-nav .back-btn,
  body.is-playing .game-nav .ghost-btn {
    min-height: 36px;
    padding-inline: 6px;
    font-size: .74rem;
  }

  body.is-playing .game-card {
    padding: 9px;
    gap: 6px;
  }

  body.is-playing .keyboard-wrap {
    min-height: 132px;
  }

  body.is-playing .keyboard-row:nth-child(2) {
    padding-inline: 5px;
  }

  body.is-playing .keyboard-row:nth-child(3) {
    padding-inline: 26px;
  }

  body.is-playing .key-btn {
    min-height: clamp(39px, 6.55svh, 48px);
    font-size: .94rem;
    border-radius: 11px;
  }

  body.is-playing .letter-slot {
    width: clamp(50px, 20vw, 62px);
    height: clamp(54px, 20vw, 66px);
    font-size: clamp(1.56rem, 8.8vw, 2.05rem);
  }

  body.is-playing .actions-row > button {
    min-height: 39px;
    font-size: .76rem;
  }

  body.is-playing .message-box {
    min-height: 39px;
    font-size: .76rem;
  }
}

@media (max-height: 640px) and (max-width: 700px) {
  body.is-playing .game-header h2 {
    font-size: 1.05rem;
  }

  body.is-playing .game-header .eyebrow,
  body.is-playing .word-area .section-label {
    display: none;
  }

  body.is-playing .goal-row > div:not(.arrow) {
    padding-block: 8px;
  }

  body.is-playing .goal-row strong {
    font-size: 1.18rem;
  }

  body.is-playing .word-area {
    padding-block: 8px;
  }

  body.is-playing .letter-slot {
    height: 52px;
    font-size: 1.55rem;
  }

  body.is-playing .selected-hint {
    margin-top: 5px;
    font-size: .74rem;
  }

  body.is-playing .keyboard-wrap {
    min-height: 124px;
  }

  body.is-playing .key-btn {
    min-height: 36px;
    font-size: .86rem;
  }

  body.is-playing .actions-row > button {
    min-height: 36px;
    font-size: .73rem;
  }

  body.is-playing .message-box {
    min-height: 36px;
    max-height: 44px;
    font-size: .72rem;
  }
}

/* Corrección de scroll móvil y mejora de pantallas intermedias */
@media (max-width: 700px) {
  html.is-playing-root,
  body.is-playing {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
  }

  body.is-playing .app-shell {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    transform: none;
  }

  body.is-playing main {
    width: 100%;
  }
}

#setupScreen.active {
  min-height: calc(100svh - 126px);
  display: grid;
  align-content: start;
  gap: 16px;
}

#setupScreen > .back-btn {
  justify-self: start;
}

.setup-card {
  position: relative;
  overflow: hidden;
  width: min(720px, 100%);
  padding: clamp(20px, 4vw, 30px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,251,252,.92)),
    radial-gradient(circle at 90% 8%, rgba(240,173,61,.20), transparent 32%);
}

.setup-card::before {
  content: "Aa";
  position: absolute;
  top: 22px;
  right: 22px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid rgba(39,101,127,.14);
  font-weight: 950;
  letter-spacing: -.03em;
}

.setup-card h2 {
  max-width: calc(100% - 70px);
  margin-bottom: 7px;
}

.setup-card > p {
  max-width: 58ch;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 650;
}

.setup-fields {
  gap: 16px;
}

.setup-fields label {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 5px 14px rgba(24,45,59,.045);
}

.setup-fields input,
.setup-fields select {
  min-height: 54px;
  border-radius: 15px;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.setup-fields select {
  letter-spacing: 0;
}

.setup-fields .hint {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px solid rgba(240,173,61,.26);
  color: var(--warn);
  font-weight: 750;
}

.setup-fields .primary-btn {
  width: 100%;
  min-height: 54px;
  border-radius: 17px;
  font-size: 1rem;
}

@media (min-width: 680px) {
  #freeSetup {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  #freeSetup .hint,
  #freeSetup .primary-btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  body:not(.is-playing) {
    overflow-x: hidden;
  }

  #setupScreen.active {
    min-height: auto;
    gap: 12px;
  }

  #setupScreen > .back-btn {
    min-height: 42px;
    padding: 8px 13px;
  }

  .setup-card {
    border-radius: 22px;
    padding: 18px;
  }

  .setup-card::before {
    top: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    border-radius: 15px;
  }

  .setup-card h2 {
    font-size: 1.55rem;
  }

  .setup-card > p {
    margin-bottom: 14px;
    font-size: .94rem;
  }

  .setup-fields {
    gap: 12px;
  }

  .setup-fields label {
    padding: 12px;
    gap: 7px;
  }

  .setup-fields input,
  .setup-fields select {
    min-height: 50px;
    font-size: 1rem;
  }
}


/* Corrección final Chrome móvil: altura visual real y sin scroll fantasma */
@media (max-width: 700px) {
  html.is-playing-root,
  body.is-playing {
    width: 100% !important;
    height: var(--app-height, 100dvh) !important;
    min-height: var(--app-height, 100dvh) !important;
    max-height: var(--app-height, 100dvh) !important;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    scroll-behavior: auto !important;
  }

  body.is-playing {
    position: fixed !important;
    inset: 0 auto auto 0 !important;
    touch-action: manipulation;
  }

  body.is-playing .app-shell {
    position: fixed !important;
    inset: 0 auto auto 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: var(--app-height, 100dvh) !important;
    min-height: var(--app-height, 100dvh) !important;
    max-height: var(--app-height, 100dvh) !important;
    overflow: hidden !important;
    margin: 0 !important;
  }

  body.is-playing main,
  body.is-playing #gameScreen.active {
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.is-playing #gameScreen.active {
    grid-template-rows: auto minmax(0, 1fr) !important;
  }
}


/* Menú móvil compacto + estadísticas en panel */
.mobile-stats-btn {
  display: none;
}

.stats-modal .modal-content {
  max-width: 560px;
}

.stats-row-modal {
  margin-top: 14px;
}

@media (max-width: 700px) {
  body:not(.is-playing) .app-shell {
    padding: 10px;
  }

  body:not(.is-playing) .topbar {
    min-height: 58px;
    margin-bottom: 10px;
    padding: 9px 10px;
    border-radius: 18px;
  }

  body:not(.is-playing) .topbar > div:first-child {
    padding-left: 44px;
  }

  body:not(.is-playing) .topbar > div:first-child::before {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: .95rem;
  }

  body:not(.is-playing) .topbar .eyebrow {
    margin-bottom: 2px;
    font-size: .58rem;
    letter-spacing: .08em;
  }

  body:not(.is-playing) h1 {
    font-size: clamp(1.55rem, 7.4vw, 2.05rem);
  }

  body:not(.is-playing) #helpBtn {
    min-height: 36px;
    padding: 7px 11px;
    font-size: .82rem;
  }

  body:not(.is-playing) .hero {
    min-height: 0;
    margin-bottom: 10px;
    padding: 14px;
    grid-template-columns: 1fr;
    gap: 6px;
    border-radius: 20px;
  }

  body:not(.is-playing) .hero h2 {
    max-width: none;
    margin-bottom: 5px;
    font-size: clamp(1.12rem, 5.8vw, 1.42rem);
    line-height: 1.03;
  }

  body:not(.is-playing) .hero p {
    font-size: .82rem;
    line-height: 1.28;
  }

  body:not(.is-playing) .mini-path {
    display: none;
  }

  body:not(.is-playing) .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 10px;
  }

  body:not(.is-playing) .mode-card {
    min-height: 96px;
    padding: 12px 11px 11px;
    border-radius: 17px;
    gap: 4px;
    justify-content: flex-end;
  }

  body:not(.is-playing) .mode-card::before {
    top: 10px;
    left: 10px;
    width: 31px;
    height: 31px;
    border-radius: 11px;
    font-size: .98rem;
  }

  body:not(.is-playing) .mode-card[data-mode="free"]::before {
    font-size: .76rem;
  }

  body:not(.is-playing) .mode-card::after {
    width: 74px;
    height: 74px;
    right: -23px;
    bottom: -28px;
  }

  body:not(.is-playing) .mode-card strong {
    font-size: clamp(.88rem, 4vw, 1rem);
    line-height: 1.05;
  }

  body:not(.is-playing) .mode-card span {
    font-size: clamp(.69rem, 3.25vw, .78rem);
    line-height: 1.16;
  }

  body:not(.is-playing) .mobile-stats-btn {
    display: flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px;
    border-radius: 17px;
    border: 1px solid rgba(39, 101, 127, .16);
    color: var(--primary-dark);
    background: linear-gradient(135deg, rgba(228, 241, 245, .96), rgba(255, 255, 255, .92));
    box-shadow: var(--shadow-sm);
  }

  body:not(.is-playing) .mobile-stats-btn span {
    font-weight: 950;
  }

  body:not(.is-playing) .mobile-stats-btn strong {
    color: var(--muted);
    font-size: .76rem;
    text-align: right;
  }

  body:not(.is-playing) .stats-card {
    display: none;
  }

  .stats-modal .modal-content {
    width: min(94vw, 520px);
    padding: 18px;
  }

  .stats-modal h2 {
    font-size: 1.45rem;
    padding-right: 46px;
  }

  .stats-row-modal {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-row-modal div {
    padding: 12px 10px 11px;
    border-radius: 15px;
  }

  .stats-row-modal strong {
    font-size: 1.18rem;
  }

  .stats-row-modal span {
    margin-top: 5px;
    font-size: .72rem;
    line-height: 1.12;
  }
}

@media (max-width: 380px) {
  body:not(.is-playing) .app-shell {
    padding: 8px;
  }

  body:not(.is-playing) .hero {
    padding: 12px;
  }

  body:not(.is-playing) .mode-grid {
    gap: 7px;
  }

  body:not(.is-playing) .mode-card {
    min-height: 88px;
    padding: 10px;
  }

  body:not(.is-playing) .mode-card::before {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  body:not(.is-playing) .mode-card strong {
    font-size: .84rem;
  }

  body:not(.is-playing) .mode-card span {
    font-size: .66rem;
  }

  body:not(.is-playing) .mobile-stats-btn {
    min-height: 44px;
    padding: 9px 11px;
  }
}

/* Ajuste final: menú móvil compacto, pero sin solapes ni estadísticas descuadradas */
@media (max-width: 700px) {
  body:not(.is-playing) .app-shell {
    padding: 12px;
  }

  body:not(.is-playing) #homeScreen.active {
    display: block;
  }

  body:not(.is-playing) .hero {
    margin-bottom: 12px;
    padding: 15px;
  }

  body:not(.is-playing) .mode-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
    align-items: stretch;
  }

  body:not(.is-playing) .mode-card {
    min-height: 122px;
    height: auto;
    padding: 52px 12px 12px;
    justify-content: flex-start;
    align-items: stretch;
    gap: 6px;
    border-radius: 18px;
    overflow: hidden;
  }

  body:not(.is-playing) .mode-card::before {
    top: 12px;
    left: 12px;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1;
  }

  body:not(.is-playing) .mode-card[data-mode="free"]::before {
    font-size: .78rem;
  }

  body:not(.is-playing) .mode-card strong,
  body:not(.is-playing) .mode-card span {
    position: relative;
    z-index: 1;
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body:not(.is-playing) .mode-card strong {
    font-size: clamp(.9rem, 3.8vw, 1rem);
    line-height: 1.12;
  }

  body:not(.is-playing) .mode-card span {
    font-size: clamp(.7rem, 3vw, .78rem);
    line-height: 1.24;
  }

  body:not(.is-playing) .mobile-stats-btn {
    min-height: 52px;
    margin-top: 2px;
    padding: 10px 13px;
    border-radius: 18px;
  }

  body:not(.is-playing) .mobile-stats-btn span,
  body:not(.is-playing) .mobile-stats-btn strong {
    min-width: 0;
  }

  .stats-modal .modal-content {
    width: min(92vw, 500px);
    max-height: min(82vh, 620px);
    overflow: auto;
    padding: 18px;
    border-radius: 24px;
  }

  .stats-modal h2 {
    margin-bottom: 6px;
    padding-right: 44px;
    line-height: 1.05;
  }

  .stats-modal .modal-subtitle {
    margin-bottom: 14px;
    max-width: 26ch;
  }

  .stats-row-modal {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 0;
  }

  .stats-row-modal div {
    min-height: 86px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 13px 9px 11px 13px;
    border-radius: 16px;
    text-align: center;
  }

  .stats-row-modal div::before {
    width: 4px;
  }

  .stats-row-modal strong {
    width: 100%;
    font-size: clamp(1.05rem, 5vw, 1.28rem);
    line-height: 1.05;
    letter-spacing: -.03em;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .stats-row-modal span {
    width: 100%;
    margin-top: 6px;
    font-size: clamp(.68rem, 3vw, .76rem);
    line-height: 1.18;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 380px) {
  body:not(.is-playing) .app-shell {
    padding: 10px;
  }

  body:not(.is-playing) .mode-grid {
    gap: 9px;
  }

  body:not(.is-playing) .mode-card {
    min-height: 116px;
    padding: 48px 10px 10px;
    border-radius: 17px;
  }

  body:not(.is-playing) .mode-card::before {
    top: 10px;
    left: 10px;
    width: 31px;
    height: 31px;
  }

  body:not(.is-playing) .mode-card strong {
    font-size: .86rem;
  }

  body:not(.is-playing) .mode-card span {
    font-size: .66rem;
    line-height: 1.2;
  }

  .stats-row-modal {
    gap: 8px;
  }

  .stats-row-modal div {
    min-height: 80px;
    padding: 11px 8px 10px 12px;
  }
}

/* Estabilización final de partida móvil: evita deformaciones al jugar */
@media (max-width: 700px) {
  body.is-playing .app-shell,
  body.is-playing main,
  body.is-playing #gameScreen.active {
    width: 100% !important;
    min-width: 0 !important;
  }

  body.is-playing #gameScreen.active {
    grid-template-rows: 42px minmax(0, 1fr) !important;
    gap: 8px !important;
    align-items: stretch !important;
  }

  body.is-playing .game-nav {
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    overflow: hidden !important;
  }

  body.is-playing .game-nav .back-btn,
  body.is-playing .game-nav .ghost-btn {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
  }

  body.is-playing .game-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    gap: 8px !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
    padding: 10px !important;
  }

  body.is-playing .game-card > * {
    flex-shrink: 0 !important;
    min-width: 0 !important;
  }

  body.is-playing .game-header {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    overflow: hidden !important;
    align-items: center !important;
  }

  body.is-playing .game-header > div:first-child {
    min-width: 0 !important;
  }

  body.is-playing .game-header h2 {
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  body.is-playing .timer-box {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 5px 8px !important;
    display: grid !important;
    align-content: center !important;
  }

  body.is-playing .timer-box span {
    font-size: .55rem !important;
    line-height: 1 !important;
  }

  body.is-playing .timer-box strong {
    font-size: 1rem !important;
    line-height: 1.05 !important;
  }

  body.is-playing .goal-row {
    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  body.is-playing .goal-row > div:not(.arrow) {
    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;
    display: grid !important;
    align-content: center !important;
    padding: 7px 6px !important;
  }

  body.is-playing .word-area {
    height: 104px !important;
    min-height: 104px !important;
    max-height: 104px !important;
    margin: 0 !important;
    padding: 8px 7px !important;
    display: grid !important;
    grid-template-rows: auto 1fr auto !important;
    align-items: center !important;
    overflow: hidden !important;
  }

  body.is-playing .letter-slots {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 8px !important;
    align-items: center !important;
    justify-items: center !important;
  }

  body.is-playing .letter-slot {
    width: 100% !important;
    max-width: 68px !important;
    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;
    border-radius: 15px !important;
    font-size: clamp(1.5rem, 8.6vw, 2.1rem) !important;
  }

  body.is-playing .letter-slot.selected {
    transform: none !important;
    box-shadow: 0 0 0 3px rgba(39, 101, 127, .14), 0 7px 15px rgba(24, 45, 59, .08) !important;
  }

  body.is-playing .selected-hint {
    height: 17px !important;
    min-height: 17px !important;
    max-height: 17px !important;
    margin: 2px 0 0 !important;
    overflow: hidden !important;
    line-height: 17px !important;
  }

  body.is-playing .keyboard-wrap {
    height: 154px !important;
    min-height: 154px !important;
    max-height: 154px !important;
    flex: 0 0 154px !important;
    display: flex !important;
    justify-content: center !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  body.is-playing .keyboard {
    height: 100% !important;
    max-width: 540px !important;
    justify-content: center !important;
    gap: 6px !important;
  }

  body.is-playing .keyboard-row {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    gap: 4px !important;
  }

  body.is-playing .keyboard-row:nth-child(2) {
    padding-inline: 10px !important;
  }

  body.is-playing .keyboard-row:nth-child(3) {
    padding-inline: 34px !important;
  }

  body.is-playing .key-btn {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    border-radius: 12px !important;
    font-size: 1rem !important;
    line-height: 1 !important;
  }

  body.is-playing .actions-row {
    height: 88px !important;
    min-height: 88px !important;
    max-height: 88px !important;
    margin: 0 !important;
    grid-auto-rows: 40px !important;
    gap: 8px !important;
    overflow: hidden !important;
  }

  body.is-playing .actions-row > button {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0 8px !important;
    line-height: 1.05 !important;
  }

  body.is-playing .message-box {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    overflow: hidden !important;
    line-height: 1.22 !important;
  }
}

@media (max-width: 700px) and (max-height: 620px) {
  body.is-playing #gameScreen.active {
    grid-template-rows: 38px minmax(0, 1fr) !important;
    gap: 6px !important;
  }

  body.is-playing .game-nav {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
  }

  body.is-playing .game-nav .back-btn,
  body.is-playing .game-nav .ghost-btn {
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    font-size: .74rem !important;
  }

  body.is-playing .game-card {
    gap: 6px !important;
    padding: 8px !important;
  }

  body.is-playing .game-header {
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
  }

  body.is-playing .goal-row {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
  }

  body.is-playing .goal-row > div:not(.arrow) {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
  }

  body.is-playing .word-area {
    height: 88px !important;
    min-height: 88px !important;
    max-height: 88px !important;
    padding-block: 6px !important;
  }

  body.is-playing .letter-slot {
    height: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    font-size: 1.5rem !important;
  }

  body.is-playing .selected-hint {
    height: 15px !important;
    min-height: 15px !important;
    max-height: 15px !important;
    line-height: 15px !important;
    font-size: .72rem !important;
  }

  body.is-playing .keyboard-wrap {
    height: 126px !important;
    min-height: 126px !important;
    max-height: 126px !important;
    flex-basis: 126px !important;
  }

  body.is-playing .keyboard {
    gap: 4px !important;
  }

  body.is-playing .keyboard-row {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
  }

  body.is-playing .key-btn {
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    font-size: .86rem !important;
  }

  body.is-playing .actions-row {
    height: 78px !important;
    min-height: 78px !important;
    max-height: 78px !important;
    grid-auto-rows: 36px !important;
    gap: 6px !important;
  }

  body.is-playing .actions-row > button {
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    font-size: .72rem !important;
  }

  body.is-playing .message-box {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    font-size: .72rem !important;
  }
}

@media (max-width: 360px) {
  body.is-playing .keyboard-row:nth-child(2) {
    padding-inline: 6px !important;
  }

  body.is-playing .keyboard-row:nth-child(3) {
    padding-inline: 24px !important;
  }

  body.is-playing .key-btn {
    font-size: .88rem !important;
  }
}

@media (max-width: 700px) and (min-height: 621px) {
  body.is-playing .game-card {
    justify-content: space-between !important;
  }
}
