:root {
  --bg: #1b1f24;
  --text: #f2f4f7;
  --hint: #9aa4b2;
  --card: #262c33;
  --accent: #4f8cff;
  --accent-text: #ffffff;
  --correct: #3fa34d;
  --present: #c9a227;
  --absent: #3a4149;
  --danger: #e5484d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 16px);
  min-height: 100vh;
}

h1, h2 { margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
.hint { color: var(--hint); margin: 4px 0 0; font-size: .9rem; }
.center { text-align: center; }
.spacer { width: 60px; }
.msg { min-height: 1.4em; text-align: center; margin: 10px 0; font-weight: 600; }
.msg.win { color: var(--correct); }

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .45; cursor: default; }

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}
button.ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 10px;
  border-radius: 10px;
}

/* ---------- top bar ---------- */
.bar, .hero, .row, .row.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bar { margin-bottom: 8px; }
.row { margin: 10px 0; }

/* ---------- home ---------- */
.home .hero { margin: 8px 0 18px; }
.lang { font-weight: 700; border: 1px solid var(--hint); border-radius: 999px; padding: 6px 12px; }
.grid-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 130px;
}
.card .icon { font-size: 2rem; }
.card strong { font-size: 1rem; }
.card .hint { font-size: .8rem; }
.card .mini-stats { margin-top: auto; font-size: .75rem; color: var(--hint); }

/* ---------- word grid ---------- */
.wboard {
  display: grid;
  gap: 6px;
  margin: 12px auto;
  width: min(100%, 300px);
}
.wrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #3b434c;
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  text-transform: uppercase;
}
.tile.filled { border-color: var(--hint); }
.tile.correct { background: var(--correct); border-color: var(--correct); }
.tile.present { background: var(--present); border-color: var(--present); }
.tile.absent { background: var(--absent); border-color: var(--absent); }

.kb { display: grid; gap: 6px; margin-top: 8px; }
.krow { display: flex; justify-content: center; gap: 5px; }
.key {
  background: var(--card);
  border-radius: 8px;
  height: 46px;
  min-width: 0;
  flex: 1 1 0;
  max-width: 44px;
  font-weight: 700;
}
.key.wide { flex: 1.6 1 0; max-width: 64px; font-size: .75rem; }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent { background: var(--absent); color: var(--hint); }
.pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.pad .key { max-width: none; height: 44px; }
.pad .key.wide { grid-column: span 2; max-width: none; font-size: .9rem; }

/* ---------- country ---------- */
.text {
  flex: 1;
  background: var(--card);
  color: var(--text);
  border: 1px solid #39414b;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  min-width: 0;
}
.guesses { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.guesses li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
}
.arrow { display: inline-block; font-size: 1.2rem; transition: transform .2s; }
.km { color: var(--hint); min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- minesweeper ---------- */
.seg { display: flex; gap: 4px; }
.field { display: flex; flex-direction: column; gap: 2px; }
.select {
  background: var(--card);
  color: var(--text);
  border: 1px solid #39414b;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
}
.ms-wrap { overflow: auto; margin-top: 8px; }
.ms-grid { display: grid; gap: 2px; width: max-content; margin: 0 auto; }
.ms-cell {
  width: 30px; height: 30px;
  background: #3a4149;
  border-radius: 4px;
  font-weight: 700;
  font-size: .95rem;
  padding: 0;
}
.ms-cell.open { background: #20252b; }
.ms-cell.boom { background: var(--danger); }
.ms-cell.n1 { color: #5b9dff; }
.ms-cell.n2 { color: #3fa34d; }
.ms-cell.n3 { color: #e5484d; }
.ms-cell.n4, .ms-cell.n5, .ms-cell.n6, .ms-cell.n7, .ms-cell.n8 { color: #c678dd; }

/* ---------- sudoku ---------- */
.sd-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 360px);
  margin: 10px auto 0;
  border: 2px solid #4a525c;
}
.sd-cell {
  aspect-ratio: 1;
  background: var(--card);
  border: 1px solid #3a4149;
  font-size: 1.1rem;
  padding: 0;
}
.sd-cell.vr { border-right: 2px solid #4a525c; }
.sd-cell.hr { border-bottom: 2px solid #4a525c; }
.sd-cell.given { font-weight: 700; color: var(--text); }
.sd-cell:not(.given) { color: var(--accent); }
.sd-cell.near { background: #2d343c; }
.sd-cell.sel { background: #3b5a8a; }
.sd-cell.bad { color: var(--danger); }
