/* Layout: a dark photo-studio frame around one camera "viewfinder" stage; start, day and week panels swap in place of it. */
:root {
  --studio: #14181f;
  --panel: #1e252f;
  --line: #2f3a48;
  --ink: #f4efe4;
  --muted: #9ba6b3;
  --flash: #ffd23f;
  --good: #3ddc84;
  --miss: #ff6b5e;
  --display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--studio); color: var(--ink); margin: 0; }
body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 32px;
}
.wrap { max-width: 1040px; margin: 0 auto; display: grid; gap: 16px; }
header.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-size: clamp(26px, 5vw, 38px); letter-spacing: 0.5px; line-height: 1; }
.brand span { color: var(--flash); }
.meta { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(18px, 4vw, 36px);
  display: grid;
  gap: 20px;
}
.title-panel, .week-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 300px); align-items: start; gap: 28px; }
.title-main, .week-main { display: grid; gap: 20px; min-width: 0; }
@media (max-width: 820px) { .title-panel, .week-panel { grid-template-columns: minmax(0, 1fr); } }

h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.05; text-wrap: balance; }
h1 { font-size: clamp(32px, 6.5vw, 56px); }
h2 { font-size: 24px; }
p { margin: 0; max-width: 62ch; }
.lead { color: var(--muted); font-size: 17px; }
.label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.step { border-top: 2px solid var(--line); padding-top: 10px; display: grid; gap: 4px; }
.step > b { font-family: var(--mono); color: var(--flash); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.fixword { color: var(--miss); }

.field { display: grid; gap: 8px; }
input[type="text"] {
  font: 700 18px var(--body);
  color: var(--ink);
  background: var(--studio);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  max-width: 340px;
}
input[type="text"]:focus { outline: none; border-color: var(--flash); }
input[aria-invalid="true"] { border-color: var(--miss); }
.field-note { font-size: 14px; color: var(--muted); }
.field-note.error { color: var(--miss); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font: 700 15px var(--body);
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--flash); background: var(--flash); color: var(--studio); }
.chip:hover { border-color: var(--flash); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.btn {
  font: 400 22px var(--display);
  letter-spacing: 0.5px;
  color: var(--studio);
  background: var(--flash);
  border: 0;
  border-radius: 12px;
  padding: 12px 28px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b8901a;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b8901a; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); box-shadow: none; font-size: 18px; padding: 10px 20px; }
.btn.small { font-size: 16px; padding: 8px 16px; }
.btn.act { min-width: 150px; font-size: 22px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn.act.fix { background: var(--miss); color: #fff; box-shadow: 0 4px 0 #a8372e; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Top 10 */
.board { background: var(--studio); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 12px; min-width: 0; }
.board-head { display: grid; gap: 2px; }
.top10 { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: none; }
.top10 li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 8px; border-radius: 8px; }
.top10 li:nth-child(odd):not(.empty) { background: rgba(255, 255, 255, 0.03); }
.top10 li.you { background: rgba(255, 210, 63, 0.14); outline: 1px solid rgba(255, 210, 63, 0.5); }
.top10 .pos { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.top10 li:nth-child(-n+3) .pos { color: var(--flash); font-weight: 700; }
.top10 .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top10 .sc { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.top10 li.empty { display: block; color: var(--muted); font-size: 14px; padding: 6px 0; }

/* Stage */
.stage { display: grid; gap: 12px; }
.viewfinder { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #0d1015; }
canvas#game { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; max-width: 100%; touch-action: manipulation; cursor: pointer; }
.controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 14px; }
kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 7px; color: var(--ink); }

/* Results */
.verdict { display: grid; gap: 8px; }
.grade { font-family: var(--display); font-size: clamp(38px, 8vw, 64px); line-height: 1; }
.pct { font-family: var(--mono); font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--studio); border-radius: 10px; padding: 12px 14px; display: grid; gap: 2px; }
.stat b { font-family: var(--mono); font-size: 24px; font-variant-numeric: tabular-nums; }
.stat.total b { color: var(--flash); }
.sheet { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; background: #0d1015; padding: 12px; border-radius: 10px; }
@media (max-width: 620px) { .sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.frame { display: grid; gap: 4px; }
.frame canvas { width: 100%; height: auto; aspect-ratio: 4 / 5; border-radius: 4px; display: block; background: #2a4a72; }
.frame .cap { display: flex; justify-content: space-between; gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.frame .cap .s { color: var(--good); font-weight: 700; }
.frame.missed .cap .s { color: var(--miss); }

.table-wrap { overflow-x: auto; }
table.days { width: 100%; border-collapse: collapse; font-size: 15px; }
table.days th, table.days td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.days thead th { font-family: var(--mono); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
table.days .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.days tfoot th, table.days tfoot td { border-bottom: 0; font-weight: 800; font-size: 17px; }
table.days tfoot td { color: var(--flash); }
.status { font-weight: 700; min-height: 1.5em; }
.status.error { color: var(--miss); }
.status.good { color: var(--good); }

.credit { text-align: center; font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); padding-top: 8px; }

@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
