@font-face {
  font-family: "M PLUS Rounded 1c";
  src: url("assets/fonts/rounded-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "M PLUS Rounded 1c";
  src: url("assets/fonts/rounded-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Mitr";
  src: url("assets/fonts/mitr-Medium.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0E00-0E7F;
}

:root {
  color-scheme: light;
  --paper: #f7f3e9;
  --ivory: #fffdf6;
  --ink: #293344;
  --muted: #5f6770;
  --line: #d8cdbd;
  --accent: #ab372f;
  font: 400 16px/1.5 "Mitr", "M PLUS Rounded 1c", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #295d80; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: default; }
h1, h2, p, figure { margin: 0; }
.app { width: min(100%, 548px); margin: 0 auto; padding: 12px max(12px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.masthead, .camera-footer, .album-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.masthead { padding: 0 0 10px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: clamp(6px, 1.8vw, 10px); }
.brand-camera { display: block; width: clamp(34px, 9vw, 52px); height: auto; }
h1 { font-size: clamp(23px, 5.3vw, 36px); font-weight: 700; line-height: 1.15; letter-spacing: -.025em; }
h1 em { color: var(--accent); font-style: normal; }
h2 { font-size: clamp(20px, 5vw, 30px); }
.primary, .outline { border: 1px solid var(--line); border-radius: 10px; min-height: 44px; padding: 6px 11px; color: var(--ink); background: var(--ivory); font-weight: 680; }
.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.primary:hover { background: #862820; }
#delete-photo, #delete-selected { color: var(--accent); }
.outline:hover { background: #eee6d9; }
ruby { ruby-align: center; }
rt { font-size: .54em; font-weight: 500; line-height: 1; }
.language-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: 8px 0; }
#language-label { font-size: 13px; font-weight: 700; }
#language-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
#language-buttons button {
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--ivory);
}
#language-buttons img { display: block; width: 28px; height: auto; border-radius: 2px; }
#language-buttons button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #fff0dc;
  box-shadow: inset 0 0 0 1px var(--accent);
}
.settings { display: flex; flex-wrap: wrap; gap: 10px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.settings label { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; }
.settings select { min-height: 44px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--ivory); }
.timer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 3px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#time-bar {
  --time-fill: var(--accent);
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e0d7ca;
}
#time-bar::-webkit-progress-bar { background: #e0d7ca; }
#time-bar.full-score { --time-fill: #257647; }
#time-bar::-webkit-progress-value { background: var(--time-fill); border-radius: 999px; }
#time-bar::-moz-progress-bar { background: var(--time-fill); border-radius: 999px; }
.prompt { display: flex; align-items: center; gap: 8px; min-height: 76px; padding: 6px 0; }
#hint-art { border: 1px solid var(--line); border-radius: 10px; background: var(--ivory); object-fit: contain; }
.prompt-copy { min-width: 0; flex: 1; display: grid; line-height: 1.2; overflow-wrap: anywhere; }
#progress { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#prompt-word { font-size: clamp(18px, 4.8vw, 29px); }
#prompt-roman { color: var(--muted); font-size: 13px; }
.prompt-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.prompt-actions button { padding-inline: 7px; font-size: 13px; }
.viewfinder { position: relative; overflow: hidden; border-radius: 16px; aspect-ratio: 4 / 5; isolation: isolate; background: #283850; }
canvas, #targets, #welcome { position: absolute; inset: 0; width: 100%; height: 100%; }
#miss-feedback {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: .18em;
  padding: .12em .38em;
  border-radius: .32em;
  background: #461814e8;
  color: #fff5ee;
  font-size: clamp(46px, 13vw, 78px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
#targets { pointer-events: none; }
#targets button { position: absolute; pointer-events: auto; border: 0; background: transparent; border-radius: 24%; min-width: 44px; min-height: 44px; transform: translate(-50%, -50%); }
#targets button.guide { outline: 2px solid #fff3ba; outline-offset: -3px; box-shadow: 0 0 12px #ffd166; }
#targets button:focus-visible { outline: 3px solid white; outline-offset: -3px; }
#targets button.wrong { outline: 2px solid #ffaba0; outline-offset: -3px; }
#welcome { display: grid; align-items: end; padding: 13px; }
.welcome-card { padding: 14px; border-radius: 12px; background: #fffaf0f5; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.welcome-card p { margin: 3px 0 12px; }
.camera-footer { margin-top: 6px; }
.camera-footer p { flex: 1; font-size: 13px; color: var(--muted); }
#review, #album { margin-top: 12px; }
.photo { padding: 10px 10px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--ivory); }
.photo img { display: block; width: 100%; max-height: 62svh; aspect-ratio: 4 / 5; object-fit: contain; background: #293344; border-radius: 5px; }
.photo figcaption { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; align-items: baseline; }
.photo figcaption strong { font-size: 21px; }
.photo figcaption span { color: var(--muted); }
#special { margin-inline-start: auto; color: var(--accent); font-weight: 780; }
.actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.actions .primary { flex: 1; min-width: 72px; }
#auto-prune-control { display: flex; gap: 6px; align-items: center; margin: 8px 0; }
#photos { display: grid; gap: 18px; margin: 12px 0 18px; }
.album-scene h3 { margin: 0 0 6px; font-size: 16px; line-height: 1.35; }
.album-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#photos button { position: relative; min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--ivory); color: var(--ink); font-weight: 650; }
#photos button[aria-pressed="true"] { box-shadow: inset 0 0 0 3px #295d80; }
#photos button[aria-pressed="true"]::after {
  content: "✓";
  position: absolute;
  inset: 10px 10px auto auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #295d80;
  color: white;
}
#photos img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 4px; }
.status { margin: 4px 0 0; color: var(--accent); font-size: 13px; overflow-wrap: anywhere; }
@media (max-height: 830px) and (orientation: portrait) {
  .viewfinder { width: min(100%, calc((100svh - 185px) * .8)); margin-inline: auto; }
}
#review { max-width: 430px; margin-inline: auto; }
.photo img { height: auto; max-height: none; background: transparent; }
.photo { box-shadow: 0 4px 12px #3a302014; }
.actions { justify-content: center; }
.actions .primary { flex: 0 0 100%; order: -1; }
.album-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.credits { flex-basis: 100%; color: var(--muted); }
.credits a { color: inherit; }
.retake { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.retake > span { flex: 0 0 100%; font-weight: 680; }
.retake select { flex: 1; min-width: 130px; min-height: 44px; color: var(--ink); background: var(--ivory); border: 1px solid var(--line); border-radius: 8px; }

.shutter-curtain {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  pointer-events: none;
}
.exposing .shutter-curtain::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 100vmax #151d2b;
  animation: shutter-iris 240ms ease-in-out both;
}
@keyframes shutter-iris {
  0%, 100% { width: 165%; }
  27%, 43% { width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .exposing .shutter-curtain { box-shadow: inset 0 0 0 4px #f5d6a2; }
  .exposing .shutter-curtain::before { content: none; }
}
.photo figcaption .shot-score { margin-inline-end: 8px; font-weight: 800; color: var(--accent); }
#hint-direction { color: var(--accent); font-size: 21px; font-weight: 800; }
@media (prefers-reduced-motion: reduce) {
  #targets button[data-pose="moving-right"], #targets button[data-pose="moving-left"],
  #targets button[data-pose="swinging"], #targets button[data-pose="perched"],
  #targets button[data-pose="left-in-front"], #targets button[data-pose="at-stage"],
  #targets button[data-pose="right-past-fuji"], #targets button[data-pose="right-under-lantern"],
  #targets button[data-pose="above-stones"], #targets button[data-pose="left-by-house"], #targets button[data-pose="tour-active"] {
    outline: 2px solid #fff3ba;
    outline-offset: -6px;
  }
  #targets button[data-pose="moving-right"]::after { content: "→"; }
  #targets button[data-pose="moving-left"]::after { content: "←"; }
  #targets button[data-pose^="moving-"]::after {
    position: absolute;
    inset: 0 0 auto;
    color: #fff3ba;
    text-shadow: 0 1px 2px #151d2b;
    font-weight: 900;
  }
}

.run-score {
  margin: 8px 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 10px;
}
.score-board {
  position: relative;
  flex: 1 1 260px;
  display: flex;
  margin: 0;
  padding: 5px 12px 7px;
  color: #fff0dc;
  background: repeating-linear-gradient(0deg, #ffffff07 0 1px, transparent 1px 4px),
    linear-gradient(125deg, #3e1920, #191725 53%, #302020);
  border: 1px solid #825042;
  border-left: 4px solid #ef8a6d;
  border-right: 4px solid #ffc96b;
  border-radius: 9px;
  box-shadow: inset 0 0 0 2px #ffffff0d, 0 2px 4px #311b222e;
}
.score-board > div { flex: 1; min-width: 0; }
.score-board > div + div { border-inline-start: 1px solid #a6716559; padding-inline-start: 12px; }
.score-board dt { font-size: .76rem; font-weight: 700; line-height: 1.25; }
.score-board dd {
  margin: 1px 0 0;
  color: #ffd47e;
  font: 800 clamp(1.25rem, 5vw, 1.7rem)/1.1 ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px #ffb05e52;
  overflow-wrap: anywhere;
}
#start-over { font-size: .82rem; }
#restart-dialog {
  width: min(420px, calc(100% - 24px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--ivory);
}
#restart-dialog::backdrop { background: #1917259c; }
#restart-dialog p { margin: 7px 0 16px; }
