:root {
  color-scheme: light;
  font-family: Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: #17323b;
  background: #e7f0eb;
  --ink: #17323b;
  --deep: #173d48;
  --paper: #fffaf0;
  --mist: #eaf5f1;
  --aqua: #75beb7;
  --coral: #e98268;
  --gold: #efc876;
  --line: rgba(23, 50, 59, 0.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: #e7f0eb; }
body { min-height: 100vh; margin: 0; overflow-x: hidden; background: linear-gradient(180deg, #f9f4e8 0, #e7f0eb 58%, #c9dfd9 100%); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid #f2b55e; outline-offset: 4px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.topbar, .game-shell, footer { width: min(1080px, calc(100% - 32px)); margin-inline: auto; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.topbar p { margin: 0; color: #62767b; font: 800 0.64rem/1 ui-monospace, Consolas, monospace; letter-spacing: 0.14em; }
.wordmark { display: flex; align-items: center; gap: 11px; color: var(--ink); font-size: 0.73rem; font-weight: 900; letter-spacing: 0.18em; text-decoration: none; }
.mark { width: 25px; height: 25px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; transform: rotate(-4deg); }
.mark i { background: var(--aqua); }
.mark i:nth-child(2), .mark i:nth-child(3) { background: transparent; }

.game-shell { padding: clamp(48px, 7vw, 88px) 0 80px; }
.game-heading { display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1.1fr); align-items: end; gap: clamp(28px, 7vw, 88px); margin-bottom: 42px; }
.eyebrow, .overlay-kicker { margin: 0 0 15px; color: #5a7777; font: 800 0.64rem/1.3 ui-monospace, Consolas, monospace; letter-spacing: 0.16em; }
h1 { margin: 0; font-size: clamp(3.4rem, 8vw, 7rem); line-height: 0.82; letter-spacing: -0.08em; }
h1 em { color: var(--coral); font-style: normal; }
.lead { margin: 0 0 3px; padding-left: 20px; border-left: 4px solid var(--aqua); color: #496269; font-weight: 700; line-height: 1.9; }

.play-area { border: 1px solid var(--line); background: rgba(255, 250, 240, 0.74); box-shadow: 0 28px 80px rgba(30, 69, 74, 0.14); }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.hud-item { min-height: 76px; padding: 15px 20px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.hud-item + .hud-item { border-left: 1px solid var(--line); }
.hud-item > span { color: #718288; font: 800 0.56rem/1 ui-monospace, Consolas, monospace; letter-spacing: 0.14em; }
.hud-item strong { font-size: clamp(1rem, 2.2vw, 1.35rem); line-height: 1; }
.hud-time { text-align: center; }
.hud-time strong { font-size: clamp(1.7rem, 4vw, 2.4rem); font-variant-numeric: tabular-nums; }
.hud-time small { margin-left: 4px; color: #73858a; font-size: 0.68rem; }
.hud-trace strong { color: var(--coral); font-variant-numeric: tabular-nums; }
.hud-wind strong { font-variant-numeric: tabular-nums; }

.scene-frame { position: relative; overflow: hidden; background: #173d48; isolation: isolate; }
#game-canvas { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; background: #b8ddd2; touch-action: none; }
.scene-frame.can-trace #game-canvas { cursor: crosshair; }
.scene-frame.is-tracing #game-canvas { cursor: grabbing; }
.scene-frame::after { position: absolute; inset: 14px; z-index: 4; border: 1px solid rgba(255, 255, 255, 0.42); border-radius: 3px; pointer-events: none; content: ""; }
.big-cue { position: absolute; z-index: 7; left: 50%; top: 13%; min-width: 180px; padding: 12px 22px; border: 2px solid rgba(23, 50, 59, 0.28); border-radius: 999px; color: var(--ink); background: rgba(255, 250, 240, 0.93); box-shadow: 0 9px 0 rgba(23, 50, 59, 0.16); font-size: clamp(1.2rem, 4vw, 2.1rem); font-weight: 950; letter-spacing: 0.03em; text-align: center; transform: translateX(-50%); pointer-events: none; }
.camera-flash { position: absolute; z-index: 20; inset: 0; background: white; opacity: 0; pointer-events: none; }
.camera-flash.is-flashing { animation: camera-flash 320ms ease-out; }

.overlay { position: absolute; z-index: 10; inset: 0; padding: clamp(14px, 4vw, 36px); display: grid; place-items: center; background: linear-gradient(180deg, rgba(20, 52, 61, 0.24), rgba(20, 52, 61, 0.68)); }
.overlay-card { width: min(560px, 100%); padding: clamp(22px, 5vw, 42px); border: 1px solid rgba(255, 255, 255, 0.58); border-radius: 18px; background: rgba(255, 250, 240, 0.95); box-shadow: 0 24px 65px rgba(9, 36, 43, 0.26); text-align: center; backdrop-filter: blur(8px); }
.overlay-card h2 { margin: 0; font-size: clamp(2rem, 6vw, 3.7rem); line-height: 1; letter-spacing: -0.055em; }
.steps { margin: 26px 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; }
.steps li { padding: 9px 12px; display: flex; flex-direction: column; gap: 4px; }
.steps li + li { border-left: 1px solid var(--line); }
.steps b { color: var(--coral); font-size: 1.15rem; }
.steps span { color: #61767a; font-size: 0.76rem; font-weight: 750; }
.primary-button { min-height: 54px; padding: 0 24px; border: 0; border-radius: 999px; color: white; background: var(--deep); box-shadow: 0 7px 0 #0d2931; font-weight: 900; cursor: pointer; transition: transform 120ms ease, box-shadow 120ms ease; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 9px 0 #0d2931; }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #0d2931; }
.result-card { width: min(430px, 100%); }
.result-score { margin: 21px 0 12px; color: var(--coral); }
.result-score strong { font-size: clamp(4rem, 13vw, 7rem); line-height: 0.8; letter-spacing: -0.08em; }
.result-score span { margin-left: 8px; color: var(--ink); font-weight: 900; }
.result-message { min-height: 2.8em; margin: 0 0 22px; color: #526a6f; font-weight: 750; line-height: 1.55; }

.controls { min-height: 112px; padding: 20px clamp(18px, 4vw, 34px); display: grid; grid-template-columns: minmax(190px, 300px) 1fr; align-items: center; gap: 28px; border-top: 1px solid var(--line); }
.controls p { margin: 0; color: #536b70; font-weight: 700; line-height: 1.7; }
.auto-shutter { min-height: 66px; padding: 0 22px; display: flex; align-items: center; justify-content: center; gap: 14px; border: 2px solid var(--ink); border-radius: 10px; color: var(--paper); background: var(--deep); box-shadow: 0 7px 0 var(--ink); }
.auto-shutter > span:last-child { display: flex; flex-direction: column; gap: 4px; }
.auto-shutter b { font: 900 0.74rem/1 ui-monospace, Consolas, monospace; letter-spacing: 0.08em; }
.auto-shutter small { color: #bedbd5; font-size: 0.74rem; font-weight: 800; }
.shutter-icon { width: 27px; height: 21px; position: relative; border: 3px solid currentColor; border-radius: 4px; }
.shutter-icon::before { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; content: ""; transform: translate(-50%, -50%); }
.shutter-icon::after { position: absolute; left: 4px; top: -7px; width: 10px; height: 5px; border: 2px solid currentColor; border-bottom: 0; border-radius: 3px 3px 0 0; content: ""; }

footer { min-height: 78px; padding: 20px 0; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid var(--line); color: #637b7e; font: 750 0.62rem/1.5 ui-monospace, Consolas, monospace; letter-spacing: 0.08em; }

@keyframes camera-flash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 700px) {
  .topbar, .game-shell, footer { width: min(100% - 22px, 1080px); }
  .topbar p { display: none; }
  .game-shell { padding-top: 42px; }
  .game-heading { grid-template-columns: 1fr; gap: 24px; }
  h1 { font-size: clamp(3.5rem, 19vw, 6rem); }
  .lead { font-size: 0.9rem; }
  .hud-item { min-height: 65px; padding: 11px 10px; }
  .hud-item strong { font-size: 0.9rem; }
  .hud-time strong { font-size: 1.55rem; }
  .scene-frame::after { inset: 8px; }
  .overlay { padding: 10px; }
  .overlay-card { padding: 19px 16px 20px; border-radius: 12px; }
  .overlay-card h2 { font-size: clamp(1.8rem, 8vw, 2.7rem); }
  .steps { margin: 16px 0; }
  .steps li { padding: 5px 6px; }
  .steps b { font-size: 0.95rem; }
  .steps span { font-size: 0.63rem; }
  .primary-button { min-height: 48px; }
  .result-score { margin: 13px 0 7px; }
  .result-message { margin-bottom: 14px; font-size: 0.78rem; }
  .controls { min-height: 0; padding: 17px 14px 20px; grid-template-columns: 1fr; gap: 16px; }
  .auto-shutter { min-height: 61px; }
  .controls p { min-height: 2.8em; font-size: 0.8rem; text-align: center; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .game-heading { margin-bottom: 28px; }
  .hud-item:first-child strong { font-size: 0.8rem; }
  .scene-frame { min-height: 219px; }
  #game-canvas { min-height: 219px; object-fit: cover; }
  .big-cue { top: 9%; min-width: 140px; padding: 8px 15px; font-size: 1rem; }
  .result-overlay { padding: 6px; }
  .result-overlay .overlay-card { padding: 9px 11px 11px; }
  .result-card .overlay-kicker { margin-bottom: 3px; font-size: 0.48rem; }
  .result-card h2 { font-size: 1.45rem; }
  .result-card .result-score { margin: 4px 0 3px; }
  .result-card .result-score strong { font-size: 3rem; }
  .result-card .result-score span { font-size: 0.66rem; }
  .result-card .result-message { min-height: 0; margin-bottom: 6px; font-size: 0.68rem; line-height: 1.25; }
  .result-card .primary-button { min-height: 44px; padding-inline: 14px; font-size: 0.72rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
