:root {
  color-scheme: dark;
  --bg: #12100e;
  --panel: #1b1814;
  --line: #2d2822;
  --ink: #f4efe6;
  --muted: #9c9386;
  --gold: #c4a574;
  --good: #3d7a56;
  --bad: #a85a4e;
  --soft: #243028;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body {
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100dvh;
  min-height: 100svh;
  overscroll-behavior-y: contain;
}
button, input { font: inherit; color: inherit; }
button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
input { font-size: 16px; }
main {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.03em; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.head-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 8px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: #1c1a17;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}
.stat strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.scroll-tabs, .tabs, .row, .namebox, .segment { display: flex; gap: 8px; }
.scroll-tabs {
  overflow-x: auto;
  flex-wrap: nowrap;
  margin: 0 -16px 10px;
  padding: 0 16px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-tabs::-webkit-scrollbar { display: none; }
.tabs { flex-wrap: wrap; margin-bottom: 10px; }
.scroll-tabs button, .tabs button, .chip {
  background: #1c1a17;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 40px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.scroll-tabs button.on, .tabs button.on, .chip.on {
  background: var(--ink);
  color: #111;
  border-color: var(--ink);
}
.scroll-tabs button small, .tabs button small { opacity: .6; font-size: 12px; }
.segment {
  background: #1c1a17;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 10px;
  gap: 4px;
}
.segment button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 8px 6px;
  min-height: 40px;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}
.segment button.on {
  background: var(--ink);
  color: #111;
}
.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  margin: 0 0 8px;
}
.week .dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
}
.week i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a2621;
  border: 1px solid var(--line);
}
.week .on i {
  background: var(--gold);
  border-color: var(--gold);
}
.week .now small { color: var(--ink); font-weight: 650; }
.goal-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}
.goal-row strong {
  color: var(--ink);
  font-weight: 650;
  font-size: 12px;
}
.bar, .goal {
  height: 4px;
  background: #2a2621;
  border-radius: 99px;
  overflow: hidden;
  margin: 0 0 12px;
}
.bar span, .goal span { display: block; height: 100%; background: var(--gold); }
.goal.done span { background: var(--good); }
.card, .stage-card {
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 18px 22px;
  min-height: 190px;
}
.es { font-size: 30px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.en { margin-top: 12px; font-size: 18px; }
.hint { color: var(--gold); margin-top: 6px; font-size: 14px; }
.ex { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }
.ex span { display: block; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); margin-top: 12px; font-size: 14px; }
.row { margin-top: 12px; flex-wrap: wrap; }
.row button, .choice, .grade {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 14px 10px;
  font-weight: 600;
  background: #2a2621;
  min-width: 0;
  min-height: 44px;
}
.row button.primary, .grade.good { background: var(--ink); color: #111; }
.row button.soft { background: var(--soft); }
.choices, .grades { display: grid; gap: 8px; margin-top: 12px; }
.grades { grid-template-columns: repeat(4, 1fr); }
.choice, .grade { text-align: left; background: #1c1a17; border: 1px solid var(--line); }
.choice.ok, .grade.easy { background: #1d3a2c; border-color: var(--good); }
.choice.no, .grade.again { background: #3d2422; border-color: var(--bad); }
.grade.hard { background: #3a3324; border-color: #8a7344; }
.grade small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.namebox { margin: 10px 0 12px; }
.namebox input, .typebox input {
  flex: 1;
  background: #1c1a17;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}
.typebox { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.typebox input { flex: 1 1 140px; }
.typebox button { min-height: 44px; }
.speak, .icon {
  background: #1c1a17;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  min-height: 44px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #111;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 5;
}
.toast.on { opacity: 1; }
.burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
}
.burst.on {
  animation: burst-fade .72s ease-out;
}
.burst::before,
.burst::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0;
}
.burst.on::before { animation: burst-ring .72s ease-out; }
.burst.on::after { animation: burst-ring .72s ease-out .08s; }
.burst.goal::before,
.burst.goal::after { border-color: #7dba8c; }
.burst.streak::before,
.burst.streak::after { border-color: #e0b36a; }
@keyframes burst-fade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes burst-ring {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(7); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .burst.on,
  .burst.on::before,
  .burst.on::after { animation: none; }
}
.progress-hero { min-height: 0; padding: 20px 16px 16px; margin-bottom: 12px; }
.progress-hero .week { margin: 14px 0 0; }
.progress-stats { margin: 0 0 14px; }
.goal-picks { margin-bottom: 10px; }
.set-list { display: grid; gap: 10px; margin: 0 0 16px; }
.set-row {
  background: #1c1a17;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
}
.set-row-top { display: flex; justify-content: space-between; gap: 8px; }
.set-row .bar { margin: 8px 0 4px; }
.set-row small { color: var(--muted); font-size: 12px; }
.plaza-host {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #c9b08a;
  min-height: 380px;
}
.plaza-host canvas { display: block; width: 100%; height: auto; }
.plaza-fallback { padding: 12px; }
.hotspots { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.hotspot {
  text-align: left;
  background: #241e18;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
}
.hotspot span { display: block; color: var(--muted); font-size: 13px; }
.quest {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #191612;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
@media (max-width: 520px) {
  .es { font-size: 26px; }
  .grades { grid-template-columns: 1fr 1fr; }
  .modes { overflow-x: auto; }
  .modes button { flex: 0 0 auto; padding: 8px 10px; min-height: 44px; }
  .card { min-height: 150px; padding: 20px 16px 18px; }
  .plaza-host { min-height: 280px; }
  .stat { padding: 6px 6px; }
  .stat strong { font-size: 14px; }
  .head { margin-bottom: 8px; align-items: center; }
  .head .sub { display: none; }
  .head-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 58%; }
  .icon { min-width: 44px; }
  .week { margin-bottom: 6px; }
  .week i { width: 7px; height: 7px; }
  .goal-row { margin-bottom: 3px; }
  .goal, .bar { margin-bottom: 10px; }
  .scroll-tabs { margin-bottom: 8px; }
  .segment { margin-bottom: 8px; }
  .segment button { min-height: 44px; }
}
@media (max-width: 520px) and (max-height: 700px) {
  .card { min-height: 132px; padding: 16px 14px; }
  .es { font-size: 24px; }
  .plaza-host { min-height: 220px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .card { min-height: 120px; padding: 14px 14px; }
  .plaza-host { min-height: 180px; }
  .head .sub { display: none; }
}
