:root {
  --bg: #f7f5ef;
  --ink: #1e2430;
  --muted: #697080;
  --panel: #ffffff;
  --line: #d9dde7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b42318;
  --tile: #fdfefe;
  --tile-hit: #dff7ef;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 35%),
    linear-gradient(315deg, rgba(180, 35, 24, 0.08), transparent 38%),
    var(--bg);
}

button,
select {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: center;
  padding: 32px 0;
}

.play-area,
.score-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 221, 231, 0.9);
  box-shadow: var(--shadow);
}

.play-area {
  border-radius: 8px;
  padding: clamp(18px, 3vw, 32px);
}

.score-panel {
  border-radius: 8px;
  padding: 22px;
}

.topbar,
.status-row,
.score-head,
.best-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
}

h2 {
  font-size: 1.4rem;
}

.timer,
.target,
.best-score {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfcfd;
}

.timer span,
.target span,
.select-wrap span,
.best-score span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.timer strong {
  display: block;
  min-width: 104px;
  color: var(--accent-dark);
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.status-row {
  margin: 26px 0 20px;
  flex-wrap: wrap;
}

.target strong,
.best-score strong {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

.select-wrap {
  min-width: 132px;
}

.language-wrap {
  min-width: 156px;
}

select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.ghost {
  color: var(--accent-dark);
  border: 1px solid var(--line);
  background: white;
}

button.ghost:hover {
  border-color: var(--accent);
}

.board-shell {
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 18px);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    #eef7f4;
  background-size: 28px 28px;
}

.board {
  --size: 5;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: clamp(7px, 1.4vw, 12px);
  width: min(72vh, 100%);
  max-width: 640px;
  aspect-ratio: 1;
}

.cell {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid #c8d7d3;
  border-radius: 8px;
  color: var(--ink);
  background: var(--tile);
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.08);
  font-size: clamp(1.15rem, 4vw, 2.2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    color 120ms ease;
}

.cell:hover {
  transform: translateY(-2px);
}

.cell.done {
  color: var(--accent-dark);
  background: var(--tile-hit);
  box-shadow: none;
}

.cell.wrong {
  color: white;
  background: var(--warn);
}

.cell.repeat {
  color: white;
  background: var(--accent-dark);
}

.records {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.record {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.record time,
.record span {
  color: var(--muted);
  font-size: 0.82rem;
}

.record strong {
  font-variant-numeric: tabular-nums;
}

.empty {
  color: var(--muted);
  padding: 18px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  max-width: calc(100% - 32px);
  border-radius: 8px;
  padding: 12px 16px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .score-panel {
    order: 2;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 20px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .timer {
    width: 100%;
  }

  .timer strong {
    text-align: left;
  }

  .status-row > * {
    flex: 1 1 140px;
  }

  button {
    width: 100%;
  }
}
