:root {
  --ink: #493b32;
  --muted: #74685e;
  --cream: #fffaf0;
  --paper: #fffefa;
  --sage: #587662;
  --sage-light: #e8f0e4;
  --clay: #b76849;
  --clay-light: #f9ece4;
  --line: #e8dfd0;
  --font-round: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body.linest-themed { background: radial-gradient(circle at 80% 0, #f9ece4, transparent 32rem), var(--cream); color: var(--ink); }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--clay); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { width: min(100% - 32px, 1480px); margin: auto; padding: 14px 0 32px; }
.page-header { display: flex; align-items: center; gap: 18px; padding: 0 4px 14px; }
.page-header h1 { font: 700 clamp(1.85rem, 3vw, 2.8rem)/1.25 var(--font-round); margin: 2px 0 0; }
.eyebrow { margin: 0; color: var(--sage); font: 700 .9rem/1.4 var(--font-round); letter-spacing: .08em; }
.home-link { display: inline-flex; align-items: center; gap: 8px; color: var(--sage); font: 700 1rem var(--font-round); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); padding: 5px 14px 5px 5px; white-space: nowrap; }
.home-link img { width: 34px; height: 34px; object-fit: contain; }
.home-link:hover { border-color: var(--sage); }
.header-flower { margin-left: auto; color: #d6a786; font-size: 2.2rem; }

.play-layout { display: grid; grid-template-columns: minmax(190px, 228px) minmax(0, 1fr); gap: clamp(16px, 2.5vw, 32px); align-items: start; }
.scene-rail { display: flex; flex-direction: column; max-height: calc(100dvh - 104px); padding: 12px; border: 1px solid var(--line); border-radius: 26px; background: #f7f4eb; }
.rail-heading { padding: 4px 6px 12px; }
.rail-heading h2 { font: 700 1.25rem var(--font-round); margin: 2px 0 0; }
.scene-picker-open { flex: none; margin-bottom: 10px; padding: 8px 12px; border: 1px solid #a8bca9; border-radius: 999px; background: #fffefa; color: #355744; font: 700 .88rem var(--font-round); }
.scene-choices { display: grid; grid-auto-rows: max-content; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.scene-choice { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; padding: 5px; text-align: left; border: 2px solid transparent; border-radius: 15px; background: var(--paper); color: var(--ink); box-shadow: 0 3px 12px #4b3a2810; font-family: var(--font-round); }
.scene-choice[aria-pressed="true"] { border-color: var(--sage); background: #f3f8f0; }
.scene-choice img { display: block; flex: none; width: 58px; height: 54px; object-fit: cover; border-radius: 10px; background: #eee8dc; }
.scene-choice span { min-width: 0; max-width: 100%; padding: 0 5px 2px; font-weight: 700; line-height: 1.3; word-break: normal; overflow-wrap: anywhere; }
.scene-choice:hover { border-color: #a0b9a2; }

.play-main { min-width: 0; }
.challenge { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: clamp(12px, 2vw, 24px); margin-bottom: 12px; padding: clamp(11px, 1.5vw, 17px); border: 1px solid var(--line); border-radius: 27px; background: var(--paper); box-shadow: 0 8px 28px #4b3a2810; }
.challenge h2 { font: 700 clamp(1.3rem, 2.5vw, 2rem)/1.45 var(--font-round); margin: 4px 0; }
.challenge-help { color: var(--muted); margin: 4px 0 0; font-size: .95rem; }
.challenge-note { color: var(--sage); margin: 4px 0 0; font: 700 .95rem/1.5 var(--font-round); }
.without-preview .target-sample { width: auto; max-width: 128px; }
.difficulty-choices { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 7px; font: 700 .8rem var(--font-round); color: var(--sage); }
.difficulty-choices > span { margin-right: 2px; }
.difficulty-choices button { min-height: 32px !important; padding: 3px 9px; border: 1px solid #c6d4c4; border-radius: 999px !important; background: #fff; color: #355744; font: 700 .8rem var(--font-round); }
.difficulty-choices button[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: white; }
.target-sample { display: flex; align-items: center; flex-direction: column; gap: 5px; color: var(--muted); font: 700 .78rem/1.3 var(--font-round); width: 128px; }
.preview { box-sizing: content-box; flex-shrink: 0; position: relative; width: 80px; overflow: hidden; border: 4px solid white; border-radius: 15px; box-shadow: 0 0 0 2px #d3ddc9, 0 5px 12px #4b3a281c; background: #f0e9dd; }
.preview img { position: absolute; max-width: none; height: auto; display: block; }
.progress-box { display: flex; align-items: center; flex-direction: column; justify-content: center; min-width: 110px; min-height: 86px; padding: 9px; border-radius: 23px; background: var(--sage-light); color: #355744; font-family: var(--font-round); }
.progress-label { font-size: .83rem; font-weight: 700; }
.progress-box strong { font-size: clamp(1.25rem, 2vw, 1.65rem); white-space: nowrap; }

.picture-section { overflow: hidden; border: 1px solid #dacfbf; border-radius: 26px; background: #f4eddf; box-shadow: 0 10px 32px #4b3a2817; }
.picture-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 54px; padding: 8px 16px; color: var(--sage); font: 700 1rem var(--font-round); background: #f9f6ee; }
.picture-buttons { display: flex; align-items: center; gap: 6px; flex: none; }
.small-button { border: 1px solid #b9cfb8; border-radius: 999px !important; background: white; color: #355744; padding: 7px 16px; font: 700 .88rem var(--font-round); white-space: nowrap; }
.nav-button { min-width: 38px; padding-inline: 8px; font-size: 1.1rem; }
.timer-panel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--line); background: #f3f8f0; font-family: var(--font-round); }
.timer-readout { display: flex; align-items: baseline; gap: 10px; color: #355744; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.timer-readout strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.timer-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.timer-actions button { min-height: 36px; padding: 5px 12px; border: 1px solid #a8bca9; border-radius: 999px; background: var(--paper); color: #355744; font: 700 .82rem var(--font-round); }
.timer-notice { width: 100%; margin: 0; color: #70492f; font-size: .9rem; font-weight: 700; }
.timer-notice:empty { display: none; }
.image-viewport { overflow: visible; }
.image-board { width: 100%; max-width: var(--board-max-width, 100%); margin-inline: auto; position: relative; background: #eee5d7; }
.image-board:focus-visible { outline: 4px solid var(--clay); outline-offset: 3px; }
.image-viewport.is-zoomed { overflow: auto; max-height: min(72vh, 850px); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.image-viewport.is-zoomed .image-board { width: 180%; max-width: none; margin-inline: 0; }
.image-viewport.is-extra.is-zoomed .image-board { width: var(--extra-zoom-width, 1536px); }
.scene-bank-heading { grid-column: 1 / -1; margin: 12px 0 2px; color: var(--sage); font: 700 1rem var(--font-round); }
.image-board > img { display: block; width: 100%; height: auto; cursor: crosshair; -webkit-user-drag: none; }
.image-board.has-range-crop { overflow: hidden; }
.image-board.has-range-crop > img { position: absolute; max-width: none; }
.range-hint-info { display: flex; align-items: center; justify-content: space-between; gap: 5px 14px; flex-wrap: wrap; padding: 6px 12px; background: #edf2e7; color: var(--sage); font: 700 .78rem/1.4 var(--font-round); }
.range-hint-info span { color: var(--muted); font-weight: 400; font-size: .72rem; }
#hintHomeButton { min-height: 44px; }
.marker-layer { position: absolute; inset: 0; pointer-events: none; }
.found-marker { position: absolute; width: var(--marker-width); height: var(--marker-height); transform: translate(-50%, -50%); border: 3px solid #fff; outline: 3px solid var(--sage); border-radius: 50%; box-shadow: 0 2px 10px #1c3a3080; }
.found-marker::after { content: "✓"; position: absolute; right: -13px; top: -14px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--sage); color: white; font: 700 16px var(--font-round); }
.hint-marker { position: absolute; width: var(--hint-width); height: var(--hint-height); transform: translate(-50%, -50%); border: 5px solid #f8fcf2; outline: 5px solid #d58049; border-radius: 50%; box-shadow: 0 0 0 12px #fffaed80; pointer-events: none; animation: hint-pulse 900ms ease-in-out infinite alternate; }
.keyboard-cursor { position: absolute; width: 28px; height: 28px; transform: translate(-50%, -50%); border: 3px solid white; outline: 3px solid #9c5230; border-radius: 50%; box-shadow: 0 2px 8px #251d1870; pointer-events: none; }
.keyboard-cursor::before, .keyboard-cursor::after { content: ""; position: absolute; background: #9c5230; }
.keyboard-cursor::before { width: 2px; height: 10px; left: 10px; top: 5px; }
.keyboard-cursor::after { height: 2px; width: 10px; left: 6px; top: 9px; }
@keyframes hint-pulse { to { box-shadow: 0 0 0 20px #fffaed30; } }
.image-status { padding: 15px; text-align: center; background: #fffaf0; color: var(--muted); font: 700 .9rem var(--font-round); }
.bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 4px 0; }
.feedback { min-height: 2em; margin: 0; color: var(--sage); font: 700 1rem/1.5 var(--font-round); }
.actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.actions button, .complete-actions button { border: 1px solid #cfbfae; border-radius: 999px; background: var(--paper); color: var(--ink); padding: 10px 19px; font: 700 .95rem var(--font-round); white-space: nowrap; }
.actions button:hover:not(:disabled), .complete-actions button:hover { background: var(--clay-light); }
.complete-panel { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: #312a25a8; }
.complete-card { width: min(100%, 440px); padding: 32px 24px; border: 4px solid #f9eee1; border-radius: 32px; background: var(--paper); box-shadow: 0 16px 60px #251d1870; text-align: center; }
.complete-deco { color: var(--clay); font-size: 1.7rem; }
.complete-card h2 { margin: 8px 0 2px; font: 700 clamp(1.55rem, 4vw, 2rem) var(--font-round); }
.complete-card p { color: var(--muted); margin: 0 0 24px; }
.complete-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.complete-actions .next-button { background: var(--sage); border-color: var(--sage); color: white; }
.scene-picker { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: #312a25a8; }
.scene-picker-card { display: flex; flex-direction: column; width: min(100%, 760px); max-height: min(90dvh, 820px); padding: 18px; border: 4px solid #f9eee1; border-radius: 28px; background: var(--paper); box-shadow: 0 16px 60px #251d1870; }
.scene-picker-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; }
.scene-picker-head h2 { margin: 0; font: 700 1.4rem var(--font-round); }
.scene-picker-head button { border: 1px solid #cfbfae; border-radius: 999px; background: white; color: var(--ink); padding: 7px 13px; font: 700 .9rem var(--font-round); }
.scene-picker-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: max-content; align-content: start; min-height: 0; gap: 10px; overflow: auto; overflow-anchor: none; overscroll-behavior: contain; padding: 2px; }
.scene-picker-grid .scene-choice { display: grid; gap: 5px; justify-items: start; }
.scene-picker-grid .scene-choice img { width: 100%; height: auto; aspect-ratio: 3 / 2; }
.scene-picker-grid .scene-choice span { font-size: .85rem; }
.settings-dialog { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: #312a25a8; }
.settings-card { width: min(100%, 560px); max-height: min(92dvh, 760px); overflow-y: auto; padding: 20px; border: 4px solid #f9eee1; border-radius: 28px; background: var(--paper); box-shadow: 0 16px 60px #251d1870; font-family: var(--font-round); }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-head h2 { margin: 0; font-size: 1.45rem; }
.settings-head button, .settings-actions button { padding: 8px 14px; border: 1px solid #cfbfae; border-radius: 999px; background: white; color: var(--ink); font: 700 .9rem var(--font-round); }
.settings-card > p { margin: 6px 0 16px; color: var(--muted); }
.settings-field { margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; }
.settings-field legend { padding: 0 6px; color: var(--sage); font-weight: 700; }
.settings-levels { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.settings-levels label, .timer-toggle { display: inline-flex; align-items: center; gap: 3px; min-height: 36px; font-weight: 700; }
.settings-field input[type="radio"], .settings-field input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--sage); }
.settings-duration { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.settings-duration > label { font-size: .86rem; font-weight: 700; }
.settings-duration > input { width: 88px; min-height: 38px; padding: 5px 8px; border: 1px solid #a8bca9; border-radius: 10px; color: var(--ink); font: 700 1rem var(--font-round); }
.timer-presets { display: flex; gap: 6px; }
.timer-presets button { min-height: 36px; padding: 5px 10px; border: 1px solid #a8bca9; border-radius: 999px; background: white; color: #355744; font: 700 .85rem var(--font-round); }
.timer-presets button[aria-pressed="true"] { background: var(--sage); color: white; }
.settings-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.settings-actions .settings-apply { background: var(--sage); border-color: var(--sage); color: white; }

@media (max-width: 850px) {
  .app-shell { width: min(100% - 20px, 780px); padding-top: 8px; }
  .page-header { gap: 12px; padding-bottom: 10px; }
  .header-flower { display: none; }
  .play-layout { display: flex; flex-direction: column; gap: 12px; }
  .scene-rail, .play-main { width: 100%; }
  .scene-rail { max-height: none; padding: 6px; border-radius: 19px; }
  .rail-heading { display: none; }
  .scene-picker-open { width: 100%; margin: 0; min-height: 39px; }
  .scene-choices { display: none; }
  .challenge { grid-template-columns: minmax(0, 1fr) auto auto; padding: 12px; }
  .target-sample { width: 86px; }
  .preview { width: 60px; }
  .progress-box { min-width: 80px; min-height: 75px; padding: 7px; }
  .scene-picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .page-header h1 { font-size: 1.55rem; }
  .home-link { padding: 4px 8px 4px 4px; font-size: .75rem; }
  .home-link img { width: 27px; height: 27px; }
  .challenge { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .challenge-copy { grid-column: 1 / -1; }
  .challenge-help { display: none; }
  .target-sample { flex-direction: row; width: auto; font-size: .7rem; }
  .progress-box { min-height: 55px; flex-direction: row; gap: 7px; }
  .picture-topline { min-height: 46px; padding: 6px 10px; font-size: .88rem; }
  .picture-topline > span { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .small-button { padding: 6px 9px; font-size: .76rem; }
  .nav-button { min-width: 32px; padding-inline: 6px; }
  .picture-buttons { gap: 4px; }
  .difficulty-choices { gap: 3px; }
  .difficulty-choices button { padding-inline: 7px; font-size: .73rem; }
  .scene-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-row { display: block; }
  .feedback { margin-bottom: 8px; font-size: .9rem; }
  .actions { justify-content: stretch; }
  .actions button { flex: 1; }
  .timer-panel { gap: 6px 10px; padding: 8px 10px; }
  .timer-actions { width: 100%; }
  .timer-actions button { flex: 1; padding-inline: 7px; font-size: .75rem; }
  .settings-card { padding: 15px; }
}
@media (prefers-reduced-motion: reduce) { .hint-marker { animation: none; } }

/* App-local full view keeps the live board and all round state in place. */
body.full-view-open { overflow: hidden; }
.play-main.is-full-view { position: fixed; inset: 0; z-index: 9; height: 100dvh; box-sizing: border-box; padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); background: var(--paper); display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.is-full-view .challenge { flex: none; display: flex; justify-content: space-between; gap: 8px; margin: 0; padding: 5px 10px; border-radius: 12px; }
.is-full-view .challenge-copy, .is-full-view #targetName { display: none; }
.is-full-view .target-sample { flex-direction: row; width: auto; }
.is-full-view .preview { border-width: 2px; border-radius: 6px; }
.is-full-view .progress-box { min-height: 32px; min-width: 0; padding: 4px 10px; flex-direction: row; gap: 8px; border-radius: 10px; }
.is-full-view .picture-section { flex: 1 0 160px; min-height: 160px; display: flex; flex-direction: column; border-radius: 12px; }
.is-full-view .picture-topline { flex: none; min-height: 0; padding: 4px 8px; flex-wrap: wrap; }
.is-full-view .picture-topline > span { max-width: 100%; font-size: .8rem; }
.is-full-view .picture-buttons { flex-wrap: wrap; }
.is-full-view .image-viewport { flex: 1; min-height: 0; overflow: auto; display: grid; align-items: center; }
.is-full-view .image-viewport.is-zoomed { display: block; max-height: none; }
.is-full-view .image-status:empty { display: none; }
.is-full-view .bottom-row { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 0; }
.is-full-view .feedback { flex: 1; margin: 0; font-size: .8rem; }
.is-full-view .actions { flex-wrap: wrap; gap: 4px; }
.is-full-view .actions button { padding: 5px 8px; font-size: .8rem; }
.is-full-view .timer-panel { flex: none; padding: 4px 8px; gap: 4px 8px; }
.is-full-view .range-hint-info { flex: none; padding: 4px 8px; font-size: .72rem; }
@media (max-height: 500px) { .is-full-view .preview { max-height: 38px; } .is-full-view .progress-box strong { font-size: 1rem; } }
@media (max-width: 850px) {
  .picture-topline { flex-wrap: wrap; min-width: 0; }
  .picture-topline > span { max-width: 100%; }
  .picture-buttons { flex: 1 1 100%; min-width: 0; max-width: 100%; flex-wrap: wrap; }
}

.is-full-view button { min-height: 44px; min-width: 44px; }
