/* ============================================================
   style.css — Crossword Puzzle App
   Stanford Daily — Cardinal red & white theme
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  /* Stanford Cardinal palette */
  --cardinal:      #8C1515;
  --cardinal-dark: #651010;

  --cell-bg:       #ffffff;
  --black-sq:      #1a1a1a;
  --border-color:  #555555;
  --active-cell:   #f7e04a;       /* yellow — high contrast on both red and white */
  --active-word:   #fde8e8;       /* light cardinal tint */
  --incorrect:     #b91c1c;
  --revealed:      #8C1515;       /* cardinal for revealed letters */
  --checked-dot:   #8C1515;
  --bg:            #f0e9de;       /* warm linen — matches Stanfordle */
  --gray-bg:       #f2eeee;       /* warm off-white */
  --panel-bg:      #fdf8f8;       /* barely-pink white */
  --clue-active-bg:#fde8e8;       /* matches active-word */
  --clue-done:     #b8a8a8;
  --header-bg:     #8C1515;       /* Stanford Cardinal */
  --header-fg:     #ffffff;
  --btn-bg:        #8C1515;
  --btn-hover:     #651010;
  --modal-overlay: rgba(60, 0, 0, 0.5);
  --serif:         Georgia, 'Times New Roman', serif;
  --sans:          system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cell-border:   1px solid var(--border-color);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 39px,
      rgba(0,0,0,0.025) 39px,
      rgba(0,0,0,0.025) 40px
    );
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Load Screen ─────────────────────────────────────────────── */
#load-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 1.5rem;
}

#load-screen h1 {
  font-family: var(--serif);
  font-size: 2rem;
  letter-spacing: -0.02em;
}

#load-screen p {
  color: #555;
  font-size: 0.95rem;
}

#drop-zone {
  width: 100%;
  max-width: 420px;
  border: 2px dashed #999;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fff;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--revealed);
  background: #eef4fc;
}

#drop-zone svg {
  display: block;
  margin: 0 auto 1rem;
  opacity: 0.4;
}

#drop-zone p {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: #444;
}

#file-input {
  display: none;
}

.browse-btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  background: var(--btn-bg);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  font-family: var(--sans);
  transition: background 0.15s;
}

.browse-btn:hover {
  background: var(--btn-hover);
}

#load-error {
  color: var(--incorrect);
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* ── App (shown once puzzle loaded) ──────────────────────────── */
#app {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

#app.visible {
  display: flex;
}

/* ── Header ──────────────────────────────────────────────────── */
#header {
  background: var(--header-bg);
  color: var(--header-fg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: 48px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

#puzzle-title {
  flex: 1;
  font-family: var(--serif);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  min-width: 5.5ch;
  text-align: center;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  color: var(--header-fg);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-family: var(--sans);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s;
}

#timer:hover {
  background: rgba(255,255,255,0.15);
}

#timer.paused {
  opacity: 0.7;
}

#timer-icon {
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Help Button ─────────────────────────────────────────────── */
#help-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--header-fg);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

#help-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* ── Help Modal ──────────────────────────────────────────────── */
#help-modal .modal {
  max-width: 460px;
  text-align: left;
}

#help-modal h2 {
  text-align: center;
  margin-bottom: 1.25rem;
}

.help-section {
  margin-bottom: 1rem;
}

.help-section h3 {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cardinal);
  margin-bottom: 0.5rem;
}

.help-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
  color: #333;
  line-height: 1.4;
}

.help-row + .help-row {
  border-top: 1px solid #f0e8e8;
}

.help-key {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 110px;
  color: #555;
  flex-shrink: 0;
}

kbd {
  display: inline-block;
  background: #f4f0f0;
  border: 1px solid #ccc;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: #333;
  line-height: 1.4;
}

.header-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--header-fg);
  border-radius: 5px;
  padding: 0.3rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.header-btn:hover {
  background: rgba(255,255,255,0.15);
}

/* ── Menu Dropdown ───────────────────────────────────────────── */
#menu-wrapper {
  position: relative;
}

#menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  min-width: 180px;
  z-index: 100;
  overflow: hidden;
}

#menu.open {
  display: block;
}

#menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 1rem;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: #222;
  cursor: pointer;
  transition: background 0.1s;
}

#menu button:hover {
  background: var(--gray-bg);
}

#menu hr {
  border: none;
  border-top: 1px solid #e8e8e8;
  margin: 2px 0;
}

/* ── Puzzle Area ─────────────────────────────────────────────── */
#puzzle-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ── Grid ────────────────────────────────────────────────────── */
#grid-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;    /* center banner and grid horizontally */
  justify-content: flex-start;
  padding: 1rem;
  overflow: auto;
}

#grid-footer {
  font-size: 0.5rem;
  color: var(--border-color);
  letter-spacing: 0.01em;
  padding: 10px 0 0 0;
  opacity: 0.6;
  width: 100%;
  text-align: right;
}

#grid-container {
  display: grid;
  border: 2px solid var(--border-color);
  /* grid-template-columns set dynamically via JS */
  /* width fills the wrapper minus padding; aspect-ratio keeps cells square */
  width: 100%;
  max-width: 100%;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--cell-bg);
  border-right: var(--cell-border);
  border-bottom: var(--cell-border);
  cursor: default;
  user-select: none;
  container-type: inline-size; /* cqw units in children = % of this cell's width */
}

/* Remove redundant right/bottom borders at grid edges */
.cell.last-col { border-right: none; }
.cell.last-row { border-bottom: none; }

.cell.black {
  background: var(--black-sq);
  cursor: default;
}

.cell.active-cell {
  background: var(--active-cell);
}

.cell.active-word:not(.active-cell) {
  background: var(--active-word);
}

/* Cell number label */
.cell-number {
  position: absolute;
  top: 5%;
  left: 5%;
  font-size: clamp(6px, 22cqw, 11px);
  line-height: 1;
  font-family: var(--sans);
  color: #111;
  pointer-events: none;
  z-index: 1;
}

/* Letter in cell */
.cell-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(10px, 55cqw, 28px);
  color: #111;
  pointer-events: none;
}

/* Incorrect letter */
.cell.incorrect .cell-letter {
  color: var(--incorrect);
}

/* Single diagonal slash through incorrect cells */
.cell.incorrect::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom right,
    transparent calc(50% - 0.75px),
    var(--incorrect) calc(50% - 0.75px),
    var(--incorrect) calc(50% + 0.75px),
    transparent calc(50% + 0.75px)
  );
  pointer-events: none;
  z-index: 1;
}

/* Revealed letter — no color change, looks like a normal filled cell */

/* Dot indicator for checked/revealed cells */
.cell.checked::after,
.cell.revealed::after {
  content: '•';
  position: absolute;
  top: 2%;
  right: 5%;
  font-size: clamp(5px, 15cqw, 8px);
  color: var(--checked-dot);
  line-height: 1;
  pointer-events: none;
}

/* ── Active-Clue Bar (mobile) ────────────────────────────────── */
#active-clue-bar {
  display: none;
  background: var(--active-word);
  padding: 0.5rem 1rem;
  font-family: var(--serif);
  font-size: 0.9rem;
  line-height: 1.4;
  border-top: 1px solid #bbb;
  flex-shrink: 0;
}

/* ── Clue Panel ──────────────────────────────────────────────── */
#clue-panel {
  flex: 0 0 200px;      /* fixed width — never grows or shrinks */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel-bg);
  border-left: 1px solid #ccc;
}

/* Clue panel tabs (mobile only) */
#clue-tabs {
  display: none;
  flex-shrink: 0;
  border-bottom: 2px solid #ccc;
}

#clue-tabs button {
  flex: 1;
  padding: 0.5rem;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

#clue-tabs button.active {
  color: var(--revealed);
  border-bottom-color: var(--revealed);
}

/* Desktop: each section is a flex column —
   header pinned at top, list scrolls independently */
#across-section,
#down-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#across-section {
  border-bottom: 2px solid #ddd;
}

.clue-section-header {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.6rem 1rem 0.4rem 0.25rem;
  color: var(--cardinal);
  flex-shrink: 0;
  border-bottom: 1px solid #e8e0e0;
  background: var(--panel-bg);
}

.clue-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-bottom: 0.5rem;
}

.clue-item {
  display: flex;
  gap: 0.4rem;
  padding: 0.15rem 0.6rem 0.15rem 0.25rem;
  font-family: var(--serif);
  font-size: 0.9rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 4px;
  margin: 0 0.25rem;
}

.clue-item:hover {
  background: rgba(0,0,0,0.05);
}

.clue-item.active-clue {
  background: var(--clue-active-bg);
}

.clue-item.completed-clue .clue-text {
  color: var(--clue-done);
}

.clue-num {
  font-weight: 700;
  min-width: 2.2ch;
  text-align: right;
  flex-shrink: 0;
  color: #444;
  font-family: var(--sans);
  font-size: 0.85rem;
  padding-top: 0.05em;
}

.clue-text {
  flex: 1;
}

/* ── Modals ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  text-align: center;
}

.modal h2 {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.modal p {
  color: #555;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

.modal .solve-time {
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin: 0.75rem 0;
  color: #222;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.55rem 1.25rem;
  border-radius: 6px;
  border: none;
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--header-bg);
  color: #fff;
}

.btn-primary:hover {
  background: var(--cardinal-dark);
}

.btn-secondary {
  background: var(--gray-bg);
  color: #222;
}

.btn-secondary:hover {
  background: #d4d4d4;
}

.btn-danger {
  background: var(--incorrect);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.85;
}

/* ── Scramble Warning ────────────────────────────────────────── */
#scramble-warning {
  display: none;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── Puzzle Banner ───────────────────────────────────────────── */
#puzzle-banner {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.6rem 1rem 0.65rem;
  background: var(--cardinal);
  border-radius: 6px 6px 0 0;  /* rounds into the grid top edge */
  width: 100%;
  flex-shrink: 0;
}

#puzzle-banner.visible {
  display: flex;
}

#banner-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

#banner-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
  display: block;
}

#banner-number {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 400;
  color: #ffffff;
  letter-spacing: 0.01em;
  line-height: 1;
}

#banner-author {
  font-family: var(--serif);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  font-style: italic;
  line-height: 1;
}

/* ── Embed Mode ──────────────────────────────────────────────── */
body.embed-mode #load-screen { display: none !important; }
body.embed-mode #puzzle-title { display: none; }
body.embed-mode #active-clue-bar { display: none; }

body.embed-mode {
  height: 100vh;
  overflow: hidden;
}

body.embed-mode #app {
  height: 100vh;
  overflow: hidden;
  border-radius: 8px;
}

/* Desktop-only embed layout (≥769px): side-by-side grid + clue panel */
@media (min-width: 769px) {
  body.embed-mode #puzzle-area {
    flex-direction: row;
    overflow: hidden;
  }

  body.embed-mode #grid-wrapper {
    flex: 1;
    overflow: auto;
    align-self: flex-start;
  }

  body.embed-mode #clue-panel {
    flex: 0 0 200px;
    height: auto;
    overflow: hidden;
    border-left: 1px solid #ccc;
    border-top: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  body.embed-mode #clue-tabs { display: none; }

  body.embed-mode #across-section,
  body.embed-mode #down-section {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
  }

  body.embed-mode .clue-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  body.embed-mode .clue-section-header {
    display: block;
    flex-shrink: 0;
  }

  body.embed-mode #mobile-clue-nav,
  body.embed-mode #mobile-keyboard { display: none; }
}

/* ── Mobile clue navigator (hidden on desktop) ───────────────── */
#mobile-clue-nav {
  display: none;
}

#mobile-keyboard {
  display: none;
}

/* ── Mobile Layout (touch devices — pointer: coarse) ───────────── */
@media (pointer: coarse) {
  html {
    height: 100%;
    overflow: hidden;
  }

  body {
    height: 100vh;       /* fallback for old browsers */
    height: 100dvh;      /* dynamic viewport: excludes browser chrome on iOS/Android */
    overflow: hidden;
  }

  #app {
    height: 100vh;       /* fallback */
    height: 100dvh;
    overflow: hidden;
  }

  /* Hide header and banner — reclaim vertical space for the grid */
  #puzzle-banner {
    display: none !important;
  }

  /* Hide desktop clue panel — replaced by mobile nav + keyboard */
  #clue-panel,
  #active-clue-bar {
    display: none;
  }

  /* Puzzle area centers the grid vertically with breathing room */
  #puzzle-area {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    padding: 10px 0;
  }

  /* Grid wrapper is exactly grid-sized (no extra height), centered */
  #grid-wrapper {
    flex: none;
    padding: 0;
    overflow: hidden;
    /* Size the wrapper to fit the grid: min of full-width vs height-available×(cols/rows).
       --puzzle-cols / --puzzle-rows set by JS after puzzle loads.
       On mobile the header (48px) and banner are hidden, freeing ~270px instead of ~320px. */
    width: min(100%, calc((100dvh - 300px) * var(--puzzle-cols, 15) / var(--puzzle-rows, 15)));
  }

  #grid-container {
    width: 100%;
  }

  #grid-footer {
    display: none;
  }

  /* ── Mobile clue navigator ─────────────────────────── */
  #mobile-clue-nav {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--active-word);
    border-top: 1px solid var(--cardinal-mid, #ddd);
    border-bottom: 1px solid var(--cardinal-mid, #ddd);
    flex-shrink: 0;
    min-height: 52px;
  }

  #mobile-prev,
  #mobile-next {
    background: none;
    border: none;
    color: var(--cardinal);
    font-size: 2rem;
    line-height: 1;
    padding: 0 0.75rem;
    cursor: pointer;
    flex-shrink: 0;
    height: 100%;
    display: flex;
    align-items: center;
  }

  #mobile-prev:active,
  #mobile-next:active {
    background: rgba(0,0,0,0.07);
  }

  #mobile-clue-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem 0;
    min-width: 0;
  }

  #mobile-clue-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cardinal);
  }

  #mobile-clue-text {
    font-family: var(--serif);
    font-size: 0.88rem;
    line-height: 1.35;
    color: #1a1a1a;
  }

  /* ── Mobile keyboard ───────────────────────────────── */
  #mobile-keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px 4px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: #c8bdb0;
    flex-shrink: 0;
  }

  .kb-row {
    display: flex;
    justify-content: center;
    gap: 5px;
  }

  .kb-key {
    flex: 1;
    max-width: 42px;
    height: 52px;
    background: #e2d8cc;
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.12);
    font-family: var(--sans);
    font-size: 1rem;
    font-weight: 700;
    color: #1e1b18;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .kb-key:active {
    background: #c8bdb0;
    box-shadow: none;
    transform: translateY(1px);
  }

  .kb-back {
    max-width: 62px;
    font-size: 1.2rem;
    background: #c8bdb0;
    color: #1e1b18;
  }

  .kb-back:active {
    background: #b5a99b;
  }
}

/* ── JS-class fallback (body.is-mobile added when pointer: coarse) ─────────── */
/* Mirrors the critical visibility rules from the media query above              */
body.is-mobile #puzzle-banner { display: none !important; }

body.is-mobile #clue-panel,
body.is-mobile #active-clue-bar { display: none; }

body.is-mobile #puzzle-area {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  padding: 10px 0;
}

body.is-mobile #grid-wrapper {
  flex: none;
  padding: 0;
  overflow: hidden;
  width: min(100%, calc((100dvh - 300px) * var(--puzzle-cols, 15) / var(--puzzle-rows, 15)));
}

body.is-mobile #grid-container {
  width: 100%;
}

body.is-mobile #grid-footer { display: none; }

body.is-mobile #mobile-clue-nav {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--active-word);
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  min-height: 52px;
}

body.is-mobile #mobile-prev,
body.is-mobile #mobile-next {
  background: none;
  border: none;
  color: var(--cardinal);
  font-size: 2rem;
  line-height: 1;
  padding: 0 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  height: 100%;
  display: flex;
  align-items: center;
}

body.is-mobile #mobile-clue-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0;
  min-width: 0;
}

body.is-mobile #mobile-clue-label {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cardinal);
}

body.is-mobile #mobile-clue-text {
  font-family: var(--serif);
  font-size: 0.88rem;
  line-height: 1.35;
  color: #1a1a1a;
}

body.is-mobile #mobile-keyboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 4px 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: #c8bdb0;
  flex-shrink: 0;
}

body.is-mobile .kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

body.is-mobile .kb-key {
  flex: 1;
  max-width: 42px;
  height: 52px;
  background: #e2d8cc;
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.12);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  color: #1e1b18;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body.is-mobile .kb-back {
  max-width: 62px;
  font-size: 1.2rem;
  background: #c8bdb0;
}
