:root {
  color-scheme: dark;
  font-family: 'Geist', 'Inter', 'Segoe UI', 'Yu Gothic UI', sans-serif;
  --bg: #11131d;
  --surface: #171a26;
  --surface-dark: #121520;
  --line: #323543;
  --text: #f3f0ed;
  --muted: #b3b1c0;
  --accent: #e3eda8;
  --lavender: #c3b7f6;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--lavender); outline-offset: 4px; }
a { color: inherit; }
button { color: inherit; }
main:focus { outline: none; }
h1, h2, p, figure { margin: 0; }
canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.site-shell {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 0 max(46px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(46px, env(safe-area-inset-left));
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: calc(82px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 12px; align-items: center; text-decoration: none; font-size: 14px; font-weight: 650; min-height: 44px; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.tools { display: flex; gap: 7px; align-items: center; }
.tool { min-height: 44px; min-width: 44px; padding: 0 11px; display: inline-grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: 3px; color: var(--muted); cursor: pointer; }
.tool:hover { color: var(--text); border-color: var(--line); }
.tool.lang { font-size: 12px; letter-spacing: .08em; font-weight: 700; }
.tool svg { width: 18px; height: 18px; }
.site-shell main { flex: 1; }
.site-footer { border-top: 1px solid var(--line); min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.site-footer .copyright { letter-spacing: .05em; }
.site-footer a { display: inline-flex; min-height: 44px; align-items: center; gap: 9px; text-decoration: none; }
.site-footer a:hover, .text-link:hover { color: var(--text); text-decoration: underline; }
.arrow { font-size: 1.15em; line-height: 1; }

.home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .98fr); align-items: center; gap: clamp(32px, 6vw, 100px); padding: clamp(56px, 8.1vh, 100px) 0; min-height: min(74vh, 735px); }
.home-copy { position: relative; z-index: 1; }
.wordmark { font-size: clamp(42px, 6.45vw, 107px); font-weight: 620; letter-spacing: -.081em; line-height: .99; margin-left: -.055em; }
.tagline { margin-top: clamp(19px, 2.4vw, 37px); font-size: clamp(23px, 3.1vw, 48px); font-weight: 560; letter-spacing: -.045em; line-height: 1.28; text-wrap: balance; }
:lang(ja) .tagline { letter-spacing: -.065em; }
.home-intro { margin-top: 17px; max-width: 37ch; color: var(--muted); font-size: clamp(15px, 1.25vw, 17px); line-height: 1.8; }
.home-actions { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 9px 20px; margin-top: 32px; }
.home-actions .primary { width: min(100%, 245px); }
.home-actions .status { flex-basis: 100%; }
.offline-code { flex-basis: 100%; max-width: 360px; color: var(--muted); font-size: 14px; }
.offline-code summary { cursor: pointer; min-height: 44px; padding: 12px 0; }
.offline-code .share-link { margin: 0 0 9px; }
.visual { position: relative; min-width: 0; background: #151827; border: 1px solid #3b3e52; padding: 8px; }
.visual::before, .visual::after { content: ''; position: absolute; z-index: 1; width: 13px; height: 13px; pointer-events: none; }
.visual::before { top: -1px; left: -1px; border-top: 1px solid var(--lavender); border-left: 1px solid var(--lavender); }
.visual::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--lavender); border-right: 1px solid var(--lavender); }
.hero-art { width: 100%; aspect-ratio: 1; object-fit: contain; }
.hero-figure { position: relative; }
.hero-figure::after { position: absolute; content: ''; pointer-events: none; inset: -16px; border: 1px solid #252938; z-index: -1; }

.button { min-height: 50px; border-radius: 4px; border: 1px solid transparent; padding: 12px 17px; display: inline-flex; justify-content: space-between; align-items: center; gap: 14px; background: var(--surface); font-size: 15px; font-weight: 650; line-height: 1.35; text-align: left; text-decoration: none; cursor: pointer; transition: background-color .16s, border-color .16s, color .16s; }
.primary { background: var(--accent); color: #171b17; border-color: var(--accent); }
.primary:hover { background: #f0f6c7; border-color: #f0f6c7; }
.secondary { border-color: #41465a; }
.secondary:hover { border-color: var(--lavender); background: #22263a; }
.text-link { border: 0; background: none; color: var(--muted); text-decoration: none; cursor: pointer; min-height: 44px; padding: 9px 0; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; text-align: left; }
.status { color: var(--muted); font-size: 13px; line-height: 1.6; }
.status.error { color: #ffc1b5; margin-top: 15px; }
.notice { position: fixed; inset: auto 16px max(16px, env(safe-area-inset-bottom)) auto; max-width: min(420px, calc(100% - 32px)); background: #292d3e; border: 1px solid #555a70; border-radius: 5px; box-shadow: 0 8px 36px #0006; padding: 13px 17px; z-index: 10; font-size: 14px; }
.notice:empty { width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }

.play { width: min(100%, 700px); margin: 0 auto; padding: 30px 0; }
.play-bar { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.play-title { font-weight: 650; letter-spacing: .09em; font-size: 13px; }
.phase { color: var(--muted); display: block; font-size: 14px; margin-top: 7px; }
.count { display: inline-flex; gap: 6px; align-items: baseline; color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.count strong { color: var(--text); font-size: 33px; line-height: 1; font-weight: 590; }
.progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 13px 0 16px; }
.progress span { height: 3px; border-radius: 2px; background: #33374b; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--lavender); width: var(--fill, 0%); transition: width 150ms ease-out; }
.play-stage { position: relative; isolation: isolate; width: 100%; height: clamp(280px, 52svh, 550px); min-height: 230px; overflow: hidden; padding: 0; background: radial-gradient(ellipse at center, #222945, #171c2e 48%, #111520 84%); border: 1px solid #30364d; border-radius: 6px; cursor: pointer; user-select: none; }
.play-stage::before, .play-stage::after { content: ''; position: absolute; inset: 18px; pointer-events: none; opacity: .6; }
.play-stage::before { border: 1px solid #333b52; border-radius: 2px; }
.play-stage::after { inset: 0; background-image: linear-gradient(90deg, transparent calc(50% - .5px), #3a455c calc(50% - .5px), #3a455c calc(50% + .5px), transparent calc(50% + .5px)), linear-gradient(0deg, transparent calc(50% - .5px), #3a455c calc(50% - .5px), #3a455c calc(50% + .5px), transparent calc(50% + .5px)); mask-image: radial-gradient(ellipse, #0000 24%, #000 92%); }
.play-stage canvas { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; }
.stage-hint { position: absolute; z-index: 2; bottom: 30px; left: 12px; right: 12px; color: var(--text); font-size: 15px; font-weight: 620; }
.stage-hint span { display: block; color: var(--muted); margin-top: 5px; font-weight: 400; font-size: 13px; }
.play-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 15px; }
.play-actions .primary { min-width: min(210px, 70%); }

.screen { width: min(100%, 1030px); margin: 0 auto; padding: clamp(36px, 6vw, 74px) 0; }
.result-layout { display: grid; grid-template-columns: minmax(0, .87fr) minmax(0, 1fr); align-items: center; gap: clamp(26px, 6vw, 80px); }
.screen-label { color: var(--lavender); font-size: 13px; font-weight: 650; line-height: 1.45; letter-spacing: .055em; margin-bottom: 12px; }
.screen-heading { font-size: clamp(30px, 4.25vw, 59px); font-weight: 570; line-height: 1.12; letter-spacing: -.055em; text-wrap: balance; overflow-wrap: anywhere; }
.screen-lead { margin-top: 14px; line-height: 1.75; font-size: 16px; color: var(--muted); }
.result-art { width: min(100%, 495px); aspect-ratio: 4 / 5; margin: 0 auto; box-shadow: 0 22px 55px #0006; }
.result-art canvas { width: 100%; height: auto; }
.result-motto { margin-top: 16px; color: var(--text); line-height: 1.6; font-size: clamp(16px, 1.8vw, 20px); font-weight: 540; }
.type-subtitle { display: block; margin-top: 8px; font-size: 12px; letter-spacing: .105em; text-transform: uppercase; color: var(--muted); }
.reading { margin-top: 22px; display: grid; gap: 13px; }
.reading section { border-top: 1px solid var(--line); padding-top: 13px; }
.reading h2 { font-size: 14px; font-weight: 670; color: var(--lavender); margin-bottom: 6px; }
.reading p { color: var(--muted); font-size: 15px; line-height: 1.68; white-space: pre-line; }
.result-actions, .share-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 20px; }
.result-actions > .primary { grid-column: 1 / -1; }
.result-actions > .primary:not(:first-child) { grid-row: 1; }
.result-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 16px; }
.result-links { display: flex; flex-wrap: wrap; column-gap: 18px; margin-top: 8px; }
.back { margin: -15px 0 13px; }
.share-link { color: var(--muted); font-size: 13px; margin-top: 19px; display: grid; gap: 7px; }
.share-link input { width: 100%; min-width: 0; min-height: 45px; border: 1px solid #41465a; background: var(--surface-dark); color: var(--text); border-radius: 4px; padding: 7px 12px; font-size: 16px; }
.finish-art { position: relative; }
.finish-art.is-assembling > canvas:first-child { animation: reveal-art .9s ease-in-out both; }
.finish-art #assembly { position: absolute; inset: 0; height: 100%; pointer-events: none; }
@keyframes reveal-art { 0% { opacity: .13; } 25% { opacity: .24; } 100% { opacity: 1; } }

@media (max-width: 840px) {
  .site-shell { padding-right: max(28px, env(safe-area-inset-right)); padding-left: max(28px, env(safe-area-inset-left)); }
  .home { gap: 35px; }
  .wordmark { font-size: clamp(38px, 7vw, 65px); }
}
@media (max-width: 640px) {
  .site-shell { padding-right: max(20px, env(safe-area-inset-right)); padding-left: max(20px, env(safe-area-inset-left)); }
  .topbar { min-height: calc(60px + env(safe-area-inset-top)); }
  .site-footer { min-height: 56px; font-size: 12px; }
  .home { grid-template-columns: 1fr; gap: 24px; min-height: auto; padding: 30px 0 27px; }
  .home-copy { display: contents; }
  .home-heading { grid-row: 1; }
  .hero-figure { grid-row: 2; width: min(100%, 420px, 55svh); margin: 0 auto; }
  .hero-figure::after { display: none; }
  .hero-art { aspect-ratio: 1.15; object-fit: cover; }
  .home-actions { grid-row: 3; margin: 0; }
  .home-actions .primary { width: 100%; }
  .wordmark { font-size: clamp(39px, 11.2vw, 71px); }
  .tagline { margin-top: 11px; font-size: clamp(24px, 6vw, 38px); }
  .home-intro { margin-top: 9px; line-height: 1.55; }
  .result-layout { display: flex; flex-direction: column; align-items: stretch; gap: 25px; }
  .result-art { width: min(100%, 400px); }
  .play { padding-top: 21px; }
  .play-stage { height: clamp(250px, 54svh, 510px); }
}
@media (max-width: 340px) {
  .result-actions, .share-actions { grid-template-columns: 1fr; }
  .site-footer { gap: 8px; }
}
@media (max-width: 640px) and (max-height: 620px) {
  .home-actions { grid-row: 2; }
  .hero-figure { grid-row: 3; }
}
@media (max-height: 510px) and (orientation: landscape) {
  .play-stage { height: 55vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
