:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  color-scheme: light;
  --accent: #17c8e8;
  --ink: #20242c;
  --background: #f4f6f8;
  --surface: #fff;
  --line: #dfe5e9;
  --control-line: #7e919c;
  --muted: #53616c;
  --soft: #e9eef2;
  --selected: #dbf6fb;
  --link: #006579;
  --paper: #fafaf5;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; color: var(--muted); }
a { color: var(--link); text-underline-offset: 3px; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--link); outline-offset: 3px;
}
[hidden] { display: none !important; }
.site-header {
  min-height: 80px; max-width: 1280px; margin: auto; padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; color: var(--ink); font-size: 26px; font-weight: 750; line-height: 1.2; }
.brand img { border-radius: 8px; flex-shrink: 0; }
.language-label { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.language-label svg { color: var(--muted); }
.language-label select, .tools select, .title-field input, .link-field {
  min-height: 44px; border: 1px solid var(--control-line); border-radius: 6px;
  color: var(--ink); background: var(--surface); padding: 9px 12px; font-size: 14px;
}
.language-label select { max-width: 180px; }
.game-tabs {
  display: flex; justify-content: center; gap: 24px; max-width: 1216px; margin: auto;
  border-bottom: 1px solid var(--line);
}
.game-tabs button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; border: 0; border-bottom: 3px solid transparent; padding: 10px 20px;
  background: none; font-size: 14px; font-weight: 650; color: var(--muted);
}
.game-tabs button:hover { color: var(--ink); }
.game-tabs button[aria-current] { color: var(--link); border-bottom-color: var(--accent); }
main { max-width: 1280px; margin: auto; padding: 0 32px; }
.play-layout {
  display: grid; grid-template-columns: 216px minmax(280px, 400px) 200px;
  justify-content: center; align-items: start; gap: 40px; padding: 24px 0 32px;
}
.tools { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; min-width: 0; }
.tool-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600;
  line-height: 20px; text-decoration: none; overflow-wrap: anywhere;
}
.button:hover:not(:disabled) { border-color: var(--control-line); background: var(--selected); }
.primary { border-color: var(--accent); background: var(--accent); color: #13272b; }
.primary:hover:not(:disabled) { background: #65dbef; border-color: #65dbef; }
.primary:disabled { background: var(--soft); border-color: var(--line); color: var(--muted); }
.icon-button { width: 44px; min-width: 44px; padding: 10px; }
.tool-options .button { min-width: 0; width: 100%; border-color: transparent; }
.tool-options [aria-pressed=true] { color: var(--link); background: var(--selected); border-color: var(--control-line); }
.control-label { font-size: 13px; line-height: 20px; font-weight: 600; color: var(--muted); margin-top: 12px; }
.tools select { width: 100%; }
.swatches { display: grid; grid-template-columns: repeat(5, 44px); gap: 0; }
.swatch { width: 44px; height: 44px; flex-shrink: 0; position: relative; border: 0; border-radius: 6px; background: none; padding: 0; }
.swatch::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 1px var(--control-line); }
.swatch[aria-pressed=true]::before { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--link); }
.swatch:disabled::before { opacity: .6; }
.size-picker { position: relative; margin-top: 12px; min-width: 0; }
.size-picker>summary { display: none; }
.size-popover { display: flex; flex-direction: column; gap: 8px; }
.size-popover .control-label { margin: 0; }
.tools input[type=range] { width: 100%; margin: 0; accent-color: var(--link); min-height: 44px; }
.drawing-stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mode-controls { display: flex; min-height: 50px; background: var(--soft); border-radius: 6px; padding: 3px; }
.mode-controls button { flex: 1; min-height: 44px; border: 0; padding: 8px 12px; border-radius: 4px; background: none; font-size: 14px; font-weight: 650; color: var(--muted); }
.mode-controls button[aria-pressed=true] { background: var(--surface); color: var(--link); box-shadow: 0 1px 3px #18242d12; }
.prompt-field { height: 48px; min-height: 48px; }
.title-field { display: flex; align-items: center; height: 48px; }
.title-field input { width: 100%; }
.prompt { display: flex; align-items: center; height: 48px; margin: 0; font-size: 13px; font-weight: 600; line-height: 20px; overflow: auto; overflow-wrap: anywhere; }
.canvas-actions { display: flex; align-items: stretch; gap: 8px; height: 48px; min-height: 48px; }
.edit-actions { display: flex; gap: 4px; flex-shrink: 0; }
.edit-actions .button { width: 44px; padding: 8px; }
.edit-actions .button:disabled { background: none; }
.drawing-actions { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); flex: 1; min-width: 0; gap: 6px; }
.drawing-actions .button { min-width: 0; padding: 5px 8px; font-size: 13px; line-height: 18px; }
.drawing-actions .button:only-child { grid-column: 1/-1; }
.drawing-actions .icon-button { width: 44px; min-width: 44px; }
#draw-panel[data-state=revealing] .edit-actions, #draw-panel[data-state=revealed] .edit-actions { display: none; }
.canvas-frame { position: relative; aspect-ratio: 3/4; width: 100%; border: 1px solid var(--control-line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.canvas-frame canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#cursor { position: absolute; pointer-events: none; width: 15px; height: 15px; border: 2px solid #006579; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); }
.canvas-status { height: 20px; font-size: 12px; line-height: 20px; color: var(--muted); text-align: center; }
.featured-rail { min-width: 0; }
.featured-rail h2 { font-size: 17px; line-height: 24px; margin: 4px 0 16px; }
.featured-rail .artwork-grid { grid-template-columns: 1fr; gap: 16px; }
.text-button { min-height: 44px; border: 0; background: none; color: var(--link); padding: 10px 0; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.artwork-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.artwork-card { border: 1px solid var(--line); border-radius: 8px; position: relative; overflow: hidden; background: var(--paper); transition: border-color .15s; }
.artwork-card:hover, .artwork-card:focus-within { border-color: var(--control-line); }
.artwork-open { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; color: inherit; cursor: pointer; }
.artwork-open canvas { display: block; width: 100%; height: auto; aspect-ratio: 3/4; }
.artwork-title { display: block; padding: 12px; background: var(--surface); font-size: 14px; font-weight: 600; line-height: 22px; overflow-wrap: anywhere; min-height: 66px; }
.featured-rail .artwork-title { font-size: 12px; line-height: 18px; min-height: 56px; padding: 10px; }
.artwork-play { position: absolute; right: 8px; top: 8px; }
.artwork-play .button { border-color: #ffffff88; }
.library-panel { padding: 32px 0 48px; min-height: 60vh; }
.library-panel h2 { font-size: 26px; margin: 0 0 24px; }
.empty-state { grid-column: 1/-1; padding: 72px 16px; text-align: center; }
.empty-state h2 { font-size: 20px; }
.guide { border-top: 1px solid var(--line); padding: 32px 0; display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.guide>div { max-width: 700px; }
.guide h1 { font-size: 22px; line-height: 32px; margin: 0 0 16px; overflow-wrap: anywhere; }
.guide h2 { font-size: 16px; margin: 0 0 8px; }
.guide p { font-size: 15px; line-height: 26px; color: var(--muted); margin: 0; }
.store-button { flex-shrink: 0; max-width: 300px; }
.store-button img { flex-shrink: 0; }
.app-intro { border-top: 1px solid var(--line); padding: 32px 0; }
.app-intro-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.app-intro-header>div { max-width: 740px; min-width: 0; }
.app-intro h2 { font-size: 20px; line-height: 1.5; margin: 0 0 12px; overflow-wrap: anywhere; }
.app-intro p { font-size: 15px; line-height: 1.8; color: var(--muted); margin: 0; }
.app-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin: 28px 0; }
.app-feature-icon { display: inline-flex; color: var(--ink); margin-bottom: 8px; }
.app-features h3 { font-size: 16px; line-height: 1.5; margin: 0 0 8px; overflow-wrap: anywhere; }
.app-intro .app-availability { border-top: 1px solid var(--line); padding-top: 20px; font-size: 14px; }
.document .app-intro-header { flex-direction: column; }
.faq { max-width: 800px; padding: 0 0 32px; }
.faq details, .document details { border-bottom: 1px solid var(--line); }
.faq summary, .document summary { padding: 16px 0; min-height: 52px; cursor: pointer; font-size: 15px; font-weight: 600; line-height: 22px; }
.faq p, .document p { line-height: 1.8; color: var(--muted); }
.faq p { padding: 0 0 16px; margin: 0; }
footer { max-width: 1280px; margin: auto; padding: 24px 32px; border-top: 1px solid var(--line); display: flex; gap: 24px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
footer .text-button { font-size: 13px; }
footer a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; color: var(--muted); }
footer a:hover { color: var(--link); }
.language-links summary { min-height: 44px; line-height: 44px; cursor: pointer; }
.language-links nav { display: flex; gap: 8px 24px; flex-wrap: wrap; padding-top: 8px; max-width: 700px; }
.document { max-width: 850px; min-height: 70vh; padding: 40px 32px 64px; }
.document h1 { font-size: 32px; line-height: 1.4; margin: 0 0 32px; overflow-wrap: anywhere; }
.document h2 { font-size: 20px; line-height: 1.5; margin-top: 32px; }
.document>.button { margin: 24px 12px 0 0; }
.game-dialog { border: 1px solid var(--line); border-radius: 8px; padding: 24px; width: min(560px, calc(100% - 32px)); max-height: 90dvh; color: var(--ink); background: var(--surface); overflow: auto; }
.game-dialog::backdrop { background: #1a242d88; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-header h2 { margin: 0; font-size: 20px; line-height: 1.4; overflow-wrap: anywhere; }
.dialog-header .button { flex-shrink: 0; }
.dialog-body { display: flex; flex-direction: column; gap: 16px; }
.dialog-body p { margin: 0; line-height: 1.7; }
.dialog-actions, .share-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.share-actions .primary { flex: 1; }
.share-actions .button { min-width: 150px; }
.replay-board { display: block; width: min(100%, 320px); aspect-ratio: 3/4; align-self: center; max-height: 55dvh; object-fit: contain; border-radius: 6px; }
.link-field { width: 100%; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 44px; font-weight: 600; }
.switch-row input { width: 24px; height: 24px; flex-shrink: 0; accent-color: var(--link); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.result-verdict { font-size: 17px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); width: max-content; border: 1px solid var(--control-line); border-radius: 6px; padding: 14px 18px; background: var(--surface); box-shadow: 0 4px 20px #18242d20; z-index: 50; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 1100px) {
  .play-layout { grid-template-columns: 200px minmax(280px, 400px); gap: 32px; }
  .featured-rail { grid-column: 1/-1; }
  .featured-rail .artwork-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 440px; }
  .featured-rail .artwork-title { font-size: 13px; }
  .swatches { grid-template-columns: repeat(4, 44px); justify-content: space-between; }
  .artwork-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .guide { align-items: flex-start; flex-direction: column; gap: 20px; }
  .app-intro-header { flex-direction: column; }
}
@media (min-width: 641px) and (min-height: 600px) {
  .play-layout { grid-template-columns: 216px minmax(280px, min(400px, calc((100svh - 350px)*.75))) 200px; }
}
@media (min-width: 641px) and (max-width: 1100px) and (min-height: 600px) {
  .play-layout { grid-template-columns: 200px minmax(280px, min(400px, calc((100svh - 350px)*.75))); }
}
@media (max-width: 640px) {
  .site-header { padding: 12px 16px; min-height: 68px; gap: 8px; }
  .brand { font-size: 22px; gap: 8px; min-width: 0; }
  .brand img { width: 36px; height: 36px; }
  .language-label svg { display: none; }
  .language-label select { max-width: 116px; padding: 8px; font-size: 13px; }
  .game-tabs { gap: 0; margin: 0 16px; }
  .game-tabs button { flex: 1; padding: 10px 6px; gap: 6px; }
  .game-tabs svg { width: 18px; height: 18px; }
  main { padding: 0 16px; }
  .play-layout { display: flex; flex-direction: column; gap: 8px; padding: 16px 0 24px; }
  .drawing-stage { display: contents; }
  .mode-controls { order: 0; width: 100%; }
  .prompt-field { order: 1; width: 100%; }
  .tools { order: 2; display: grid; grid-template-columns: 176px minmax(0, 1fr) 44px; gap: 6px; width: 100%; padding: 0; }
  .tool-options { grid-column: 1; grid-row: 1; gap: 0; }
  .tools select { grid-column: 2; grid-row: 1; padding: 8px; font-size: 13px; min-width: 0; }
  .brush-label, .color-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; margin: 0; }
  .swatches { grid-column: 1/-1; grid-row: 2; display: flex; gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: thin; padding: 0 1px 4px; }
  .size-picker { grid-column: 3; grid-row: 1; margin: 0; }
  .size-picker>summary { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px; list-style: none; width: 44px; height: 44px; border: 1px solid var(--control-line); border-radius: 6px; background: var(--surface); }
  .size-picker>summary::-webkit-details-marker { display: none; }
  .size-picker summary svg { width: 17px; height: 17px; }
  .size-picker output { font-size: 11px; line-height: 12px; font-variant-numeric: tabular-nums; }
  .size-picker[open]>summary { background: var(--selected); color: var(--link); }
  .size-popover { position: absolute; right: 0; top: 52px; width: min(264px, calc(100vw - 40px)); padding: 16px; z-index: 30; background: var(--surface); border: 1px solid var(--control-line); border-radius: 8px; box-shadow: 0 8px 24px #18242d22; }
  .canvas-actions { order: 3; width: 100%; }
  .canvas-frame { order: 4; width: min(100%, max(220px, calc((100svh - 420px)*.75))); align-self: center; }
  .canvas-status { order: 5; width: 100%; }
  .featured-rail { order: 6; width: 100%; margin-top: 24px; }
  .featured-rail .artwork-grid { max-width: none; gap: 12px; }
  .featured-rail h2 { margin-top: 0; }
  .artwork-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .artwork-title { font-size: 13px; line-height: 20px; min-height: 64px; padding: 10px; }
  .library-panel { padding: 24px 0 32px; }
  .library-panel h2 { font-size: 24px; }
  .guide { padding: 24px 0; gap: 20px; }
  .guide h1 { font-size: 20px; line-height: 30px; }
  .guide p { font-size: 14px; line-height: 24px; }
  .app-intro { padding: 24px 0; }
  .app-intro p { font-size: 14px; }
  .app-features { grid-template-columns: minmax(0, 1fr); gap: 24px; margin: 24px 0; }
  .faq summary { font-size: 14px; }
  footer { padding: 16px; gap: 4px 20px; }
  .game-dialog { padding: 20px; }
  .dialog-header h2 { font-size: 18px; }
  .share-actions { flex-direction: column; }
  .document { padding: 24px 16px 40px; }
  .document h1 { font-size: 26px; }
}
@media (max-width: 359px) {
  .brand { font-size: 20px; }
  .brand img { width: 30px; height: 30px; }
  .language-label select { max-width: 104px; }
  .game-tabs button { font-size: 13px; padding-inline: 4px; }
  .tools { grid-template-columns: minmax(176px, 1fr) 44px; gap: 6px; }
  .tool-options { width: 176px; }
  .size-picker { grid-column: 2; }
  .tools select { grid-column: 1/-1; grid-row: 2; }
  .swatches { grid-row: 3; }
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --ink: #f3f5f7; --background: #14171a; --surface: #20252a; --line: #3b4147; --control-line: #8c9da6; --muted: #b9c3cb; --soft: #2c343b; --selected: #173b43; --link: #70e4f5; }
  .primary { color: #13272b; }
  .primary:disabled { color: var(--muted); }
  .primary:hover:not(:disabled) { color: #13272b; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
