:root {
  --bg: #e7edf2;
  --paper: #f8fafb;
  --ink: #15232e;
  --muted: #4d5d6b;
  --line: #c9d3dc;
  --accent: #1d4e89;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

.sheet {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem calc(2rem + env(safe-area-inset-bottom));
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

h2 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-weight: 600;
}

.mast p,
.hint,
.makeup,
.used,
.skips,
.empty {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.result {
  margin-top: 1.25rem;
  background: #fff;
  border-left: 4px solid var(--accent);
  padding: 0.95rem 1rem 1rem;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.list li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.secret {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.35rem;
  line-height: 1.35;
  font-weight: 500;
  font-variant-ligatures: none;
  overflow-wrap: anywhere;
  user-select: all;
}

button,
input { font: inherit; }

.copy,
.copy-all,
#cancel {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0.15rem 0;
  cursor: pointer;
}

.copy-all { margin-top: 0.85rem; }

.go {
  margin-top: 1rem;
  width: 100%;
  min-height: 3rem;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.go:disabled,
.choice:disabled,
.stepper button:disabled {
  opacity: 0.45;
  cursor: default;
}

.group { margin-top: 1.4rem; }

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.choice,
.stepper button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.choice {
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
}

.choice.mark {
  min-width: 2.75rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.15rem;
}

.symbol-choices { margin-top: 0.35rem; }

.space-total {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.times {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
}

.times li + li { margin-top: 0.35rem; }

.parts { word-break: keep-all; }

.choice[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.rows { margin-top: 0.35rem; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stepper span {
  min-width: 1.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stepper button {
  width: 2.75rem;
  height: 2.75rem;
}

.makeup { margin-top: 0.8rem; }

#capture {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom));
  background: var(--bg);
}

#capture.grab { touch-action: none; }

.capture-body {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 22rem;
}

#capture-text {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.35;
  font-weight: 600;
}

#mash {
  width: 100%;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.offscreen-copy {
  position: fixed;
  left: -9999px;
}

#cancel {
  align-self: flex-start;
  min-height: 2.75rem;
  font-size: 1rem;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}
