:root {
  color-scheme: light;
  --bg: #f3efe6;
  --ink: #1e1b16;
  --muted: #6f6a60;
  --card: #fffdf8;
  --line: #e4dccb;
  --target: #e7a31a;
  --target-ink: #2a2108;
  --ok: #2f9d62;
  --bad: #d84b40;
  --key: #34373c;
  --key-ink: #f7f4ee;
  --unit: 48px;
  font-family: "Hiragino Sans", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button, input { font: inherit; }

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.brand {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
}

.stats strong { color: var(--ink); font-weight: 650; }

.ime {
  background: #fff4e5;
  border: 1px solid #efd0a0;
  color: #7a4b10;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 16px;
  margin-bottom: 16px;
}

.written {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.written span {
  display: inline-block;
  margin-right: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.kana-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 2px 1px;
  margin: 10px 0 6px;
  min-height: 1.45em;
}

.kana-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 1.35em;
  padding: 2px 2px 1px;
  border-radius: 8px;
}

.kana-cell .glyph {
  font-size: 40px;
  line-height: 1.15;
}

.kana-cell .roma {
  min-height: 1.15em;
  margin-top: 1px;
  font-size: 12px;
  line-height: 1.15;
  letter-spacing: 0;
  color: #5f5a52;
}

.kana-cell.now .roma { color: #3d3424; }

.kana-cell.done .glyph { color: #b0aa9e; }
.kana-cell.done .roma { color: #c4bfb4; }
.kana-cell.now { background: #f6d48a; }
.kana-cell.rest .glyph { color: var(--ink); }

.zh { margin: 0; font-size: 16px; color: #3f4a42; }
.hint {
  margin: 12px 0 0;
  min-height: 1.4em;
  color: #8a5a08;
  font-weight: 600;
}

.bar {
  height: 4px;
  background: #efe8da;
  border-radius: 99px;
  margin-top: 12px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--target);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.actions button, .settings button, .dialog button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.dialog button, .actions button:first-child {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.board-scroll { overflow-x: auto; padding-bottom: 6px; }

.board {
  width: max-content;
  margin: 0 auto;
  background: #1c1e22;
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.key {
  width: calc(var(--w) * var(--unit));
  height: 56px;
  border: 0;
  border-radius: 7px;
  background: var(--key);
  color: var(--key-ink);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  cursor: pointer;
}

.key.mod { background: #2a2d32; }
.mod-label { font-size: 11px; letter-spacing: 0.04em; color: #c9c4ba; }
.kana { font-size: 20px; font-weight: 650; line-height: 1; }
.latin {
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0.9;
  text-transform: lowercase;
}

.key.is-shift { background: #f3ddaa; color: var(--target-ink); }
.key.is-target {
  background: var(--target);
  color: var(--target-ink);
  outline: 3px solid #a86d00;
  outline-offset: 1px;
}
.key.is-ok { background: var(--ok); color: white; outline: none; }
.key.is-bad { background: var(--bad); color: white; outline: none; }

.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.settings label { display: flex; align-items: center; gap: 6px; }

.foot {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(243, 239, 230, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(40, 32, 20, 0.12);
}

.dialog h2 { margin: 0 0 8px; font-size: 22px; }
.dialog p { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }

@media (max-width: 720px) {
  .kana-cell .glyph { font-size: 30px; }
  .kana-cell .roma { font-size: 10px; }
  header { flex-direction: column; align-items: flex-start; }
  :root { --unit: 40px; }
  .key { height: 44px; }
  .kana { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
