:root {
  color-scheme: light;
  --page: #f6f3ec;
  --paper: #fffdf8;
  --ink: #303c32;
  --muted: #625e53;
  --line: #dedace;
  --accent: #3e6250;
  --accent-soft: #e6ede2;
  --focus: #376f75;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; -webkit-touch-callout: none; }
body { margin: 0; min-height: 100svh; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; color: inherit; }
button, input, summary, canvas { -webkit-user-select: none; user-select: none; }
a { color: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible, canvas:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.shell {
  width: min(100%, 1120px);
  margin-inline: auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.sitebar { display: flex; align-items: center; justify-content: space-between; }
.sitebar a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: .82rem;
  color: var(--muted);
}
.titlebar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 2px 0 15px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.24rem, 4.8vw, 2rem); letter-spacing: -.04em; line-height: 1.25; }
h2 { font-size: 1.22rem; line-height: 1.4; letter-spacing: -.025em; }
.utilities { display: flex; gap: 5px; }
.quiet {
  min-height: 44px;
  padding: 0 9px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  white-space: nowrap;
  font-size: .75rem;
  font-weight: 650;
}
.workspace { display: grid; gap: 18px; }
#stage {
  position: relative;
  min-width: 0;
  align-self: start;
  overflow: hidden;
  border-radius: 16px;
  background: #e9dfcb;
}
#game, #photoImg { display: block; width: 100%; height: auto; }
#game { aspect-ratio: 3 / 2; touch-action: none; }

:is([data-scene="welcome"], [data-scene="pet"], [data-scene="brush"], [data-scene="warm"], [data-scene="ruff"], [data-scene="nest"]) #game { cursor: grab; }
:is([data-scene="wash"], [data-scene="rinse"], [data-scene="play"]) #game { cursor: crosshair; }
#photoImg, [data-scene="end"] #game { display: none; }
[data-scene="end"] #photoImg { display: block; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#loadErr { display: none; margin-block: 10px; color: #8a422b; }

.controls { min-width: 0; }
.pane, #photoBar, #resultPanel { display: none; }
.pane, #photoBar, #resultPanel { width: 100%; flex-direction: column; gap: 12px; }

.visitor { display: grid; gap: 3px; }
.visitor p { color: var(--accent); font-size: .86rem; font-weight: 650; }
.visitor h2 { font-size: clamp(1.34rem, 4.7vw, 1.62rem); }
.gentleHint { color: var(--muted); font-size: .94rem; line-height: 1.6; }
#options { border-top: 1px solid var(--line); margin-top: 4px; }
#options summary { min-height: 44px; padding: 12px 0; color: var(--muted); font-size: .89rem; cursor: pointer; }
#options label { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); align-items: center; padding-bottom: 7px; font-size: .89rem; }
#options select { min-height: 44px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: var(--paper); font: inherit; }
.secondary { align-self: center; padding-inline: 20px; font-size: .9rem; }

#guide { display: none; margin: 2px 0 18px; }
:is([data-scene="loading"], [data-scene="wash"], [data-scene="rinse"], [data-scene="play"], [data-scene="brush"], [data-scene="warm"], [data-scene="ruff"], [data-scene="nest"]) #guide { display: block; }
#guideText { margin-top: 5px; min-height: 1.55em; color: var(--muted); font-size: .92rem; line-height: 1.55; }
#prog {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 12px;
  appearance: none;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent);
}
#prog::-webkit-progress-bar { background: var(--accent-soft); }
#prog::-webkit-progress-value { background: var(--accent); border-radius: 8px; transition: width .18s ease; }
#prog::-moz-progress-bar { background: var(--accent); border-radius: 8px; }
[data-scene="loading"] #prog { display: none; }

.bigBtn, .dl {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--accent);
  color: white;
  font-size: .95rem;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.bigBtn:active, .chip:active { translate: 0 1px; }
.dl { border-color: var(--line); background: var(--paper); color: var(--ink); }
.chip {
  min-height: 44px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  font-size: .78rem;
  white-space: nowrap;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: #254633; font-weight: 650; }
.accessories { display: flex; flex-wrap: wrap; gap: 6px; }
.accessories .chip { flex: 1 0 auto; padding-inline: 10px; font-size: .82rem; }
#resultPanel h2 { font-size: 1.12rem; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (hover: hover) {
  .sitebar a:hover { text-decoration: underline; text-underline-offset: 4px; }
  .quiet:hover { background: var(--accent-soft); color: var(--ink); }
  .bigBtn:hover { background: #304d3d; }
  .dl:hover, .chip:hover { border-color: var(--accent); }
}

@media (min-width: 800px) {
  .shell { padding-inline: 28px; padding-top: 26px; }
  .titlebar { margin-top: 7px; margin-bottom: 24px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; }
  .controls { padding: 10px 0 14px 20px; border-left: 1px solid var(--line); }
  #stage { border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  #prog::-webkit-progress-value { transition: none; }
}

@media (max-width: 350px) {
  .result-actions { grid-template-columns: 1fr; }
}
