:root {
  color-scheme: dark;
  --bg:#111116; --surface:#191920; --input:#111116; --border:#36343f;
  --text:#f1eef1; --muted:#b7b2bf; --dim:#a29cab; --mint:#bcf48a; --amber:#f1be76;
  --mono:"Menlo", "DejaVu Sans Mono", monospace;
  --body:"Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --ease:cubic-bezier(.23,1,.32,1);
}
*, *::before, *::after { box-sizing:border-box; }
html { scroll-padding-top:18px; }
body { margin:0; min-width:0; background:var(--bg); color:var(--text); font:16px/1.6 var(--body); }
body::before { content:""; position:absolute; inset:0 0 auto; height:810px; pointer-events:none; z-index:-1; background:radial-gradient(ellipse at 78% 18%,#201927,transparent 52%),radial-gradient(circle,#d1b9df20 1px,transparent 1px) 0 0/23px 23px; mask-image:linear-gradient(#000,transparent); }
button, input, select, textarea { font:inherit; color:inherit; }
button, a, select { -webkit-tap-highlight-color:transparent; }
button, select { cursor:pointer; }
button { border:1px solid var(--border); background:var(--surface); }
button:active, .small-button:active { transform:scale(.97); }
a { color:inherit; }
:focus-visible { outline:2px solid var(--mint); outline-offset:4px; }
[hidden] { display:none !important; }
h1,h2,h3,p { margin:0; }
.shell { width:min(1320px, calc(100% - 96px)); margin-inline:auto; }
.skip { position:fixed; top:8px; left:8px; z-index:10; transform:translateY(-160%); background:var(--bg); padding:10px; }
.skip:focus { transform:none; }
.mast { background:#15151a; border-bottom:1px solid #312e38; }
.mast-inner { min-height:76px; display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:20px; }
.brand { width:max-content; display:flex; align-items:center; gap:12px; text-decoration:none; font:800 19px/1.15 var(--mono); letter-spacing:-.07em; }
.brand img { border-radius:7px; image-rendering:pixelated; }
.brand b { color:var(--mint); }
.brand small { display:block; color:var(--muted); margin-top:4px; font:600 11px/1.2 var(--body); letter-spacing:.12em; }
.nav { display:flex; height:100%; align-items:center; gap:8px; }
.nav button { border-color:transparent; background:transparent; color:var(--muted); min-height:44px; padding:0 15px; border-radius:6px; white-space:nowrap; font-size:14px; font-weight:700; }
.nav button[aria-current] { color:var(--mint); background:#252d24; border-color:#3a4a36; }
#library-count { display:inline-block; margin-left:3px; padding:1px 4px; border-radius:3px; background:#2e2c36; font:12px var(--mono); }
.utility { justify-self:end; min-height:44px; display:flex; align-items:center; gap:8px; border:0; background:none; color:var(--muted); font-size:14px; }
.utility span:first-child { border:1px solid #756f82; width:21px; height:21px; border-radius:50%; font:700 14px/19px var(--mono); }
.intro { display:flex; align-items:center; justify-content:space-between; padding:43px 0 33px; gap:24px; }
.kicker { display:flex; align-items:center; gap:10px; color:var(--mint); letter-spacing:.15em; font:700 12px/1.3 var(--mono); }
.kicker i { width:8px; height:8px; background:var(--mint); box-shadow:3px 3px 0 #578856; }
h1 { margin:14px 0 13px; font-size:clamp(32px,4.05vw,59px); letter-spacing:-.065em; line-height:1.14; font-weight:900; }
h1 em { color:var(--mint); font-style:normal; }
.intro-text { color:#cfc7d4; font-size:15px; }
.mobile-break { display:none; }
.stamp { color:#e0be9f; border:1px solid #665144; outline:1px dashed #695342; outline-offset:-7px; transform:rotate(6deg); padding:17px 21px 16px; text-align:center; font:600 10px/1.3 var(--mono); letter-spacing:.18em; margin-right:11px; }
.stamp b { display:block; font:800 20px/1.1 var(--mono); letter-spacing:-.09em; margin-bottom:5px; }
.stamp b span { padding:0 4px; }
.stamp-controls { display:flex; align-items:center; justify-content:center; gap:7px; margin-bottom:9px; color:var(--amber); }
.stamp-controls span:last-child { opacity:.55; }
.workbench { display:grid; grid-template-columns:minmax(0, .9fr) minmax(0, 1.2fr); gap:18px; align-items:stretch; }
.panel { border:1px solid var(--border); border-radius:12px; background:var(--surface); min-width:0; overflow:hidden; }
.panel-bar { min-height:54px; display:flex; align-items:center; gap:10px; border-bottom:1px solid var(--border); padding:0 19px; background:#1e1d26; }
.panel-bar h2 { font-size:17px; font-weight:800; letter-spacing:.02em; }
.section-icon { width:19px; display:grid; place-items:center; color:var(--mint); font-size:20px; }
.screen-icon { width:16px; height:12px; border:1.5px solid #c8b5df; border-radius:3px; box-shadow:0 3px 0 -2px #c8b5df; }
.panel-code, .monitor-status { margin-left:auto; color:var(--dim); white-space:nowrap; font:11px var(--mono); letter-spacing:.065em; }
.monitor-status { display:flex; align-items:center; gap:7px; }
.monitor-status i { width:7px; height:7px; border-radius:50%; background:var(--mint); box-shadow:0 0 8px #bcf48870; }
.creator form { padding:17px 19px 15px; }
.prompt-label, .fields label > span, legend { display:block; margin-bottom:7px; font-size:14px; font-weight:750; }
.prompt-frame { background:var(--input); border:1px solid #4a4654; border-radius:7px; }
.prompt-frame:focus-within { border-color:var(--mint); box-shadow:0 0 0 2px #bcf48822; }
textarea { display:block; width:100%; border:0; background:none; border-radius:7px; padding:13px 13px 3px; min-height:83px; line-height:1.6; resize:vertical; outline:none !important; }
textarea::placeholder { color:#b0a8bb; }
.prompt-foot { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:1px 13px 9px; color:var(--dim); font-size:11px; }
#limit { font-family:var(--mono); white-space:nowrap; }
.ideas { display:flex; flex-wrap:wrap; gap:7px; margin:8px 0 12px; }
.ideas button { min-height:44px; padding:0 9px; color:#d4ccde; background:#24212c; border-color:#423b4e; border-radius:5px; font-size:12px; }
.fields { display:grid; grid-template-columns:.62fr 1.2fr 1.3fr; gap:9px; }
.fields label { min-width:0; }
select { width:100%; min-height:44px; border:1px solid #41404a; border-radius:5px; background:#15151c; padding:0 23px 0 8px; font-size:13px; font-weight:650; appearance:none; background-image:linear-gradient(45deg, transparent 50%,#c3bbce 50%),linear-gradient(135deg,#c3bbce 50%,transparent 50%); background-position:calc(100% - 14px) 50%,calc(100% - 10px) 50%; background-size:4px 4px; background-repeat:no-repeat; }
.device-field { border:0; padding:0; margin:14px 0 14px; min-inline-size:0; }
.devices { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); border:1px solid #413d4b; border-radius:6px; background:#131319; padding:3px; gap:3px; }
.devices label { position:relative; cursor:pointer; }
.devices input { position:absolute; width:1px; height:1px; opacity:0; }
.devices span { display:grid; place-items:center; min-height:44px; font-size:12px; color:#d1c9dc; white-space:nowrap; border-radius:4px; border:1px solid transparent; }
.devices input:checked + span { color:var(--mint); border-color:#57714a; background:#2b3927; font-weight:800; }
.devices input:focus-visible + span { outline:2px solid var(--mint); outline-offset:-2px; }
.primary { min-height:46px; padding:0 15px; background:var(--mint); color:#162010; border:1px solid #d8ffaa; border-radius:6px; font-weight:900; box-shadow:0 2px 0 #68984c; }
.create-button { width:100%; min-height:50px; position:relative; }
.create-button > span:first-child { margin-right:6px; }
.button-tail { position:absolute; right:16px; }
.build-note { margin-top:9px; color:var(--dim); font-size:11px; }
.form-error { color:#ffb3b3; margin:0 0 8px; font-size:14px; }
.monitor-body { padding:15px 17px 12px; }
.bezel { background:#101015; border:1px solid #49434f; border-radius:13px; padding:9px; box-shadow:inset 0 0 0 3px #26232e; }
.glass { position:relative; display:grid; place-items:center; background:#0e0f14; border:1px solid #53495f; border-radius:6px; overflow:hidden; aspect-ratio:16/9; isolation:isolate; }
#screen { width:100%; height:100%; object-fit:contain; image-rendering:pixelated; position:absolute; inset:0; }
.bezel[data-device="tablet"] .glass { aspect-ratio:4/3; max-width:540px; margin:auto; }
.bezel[data-machine="p6"] .glass { aspect-ratio:4/3; max-width:480px; margin:auto; }
.bezel[data-device="phone"] .glass { max-width:360px; margin:auto; }
.scanlines { position:absolute; inset:0; pointer-events:none; z-index:1; background:repeating-linear-gradient(transparent 0 3px,#0003 4px 5px); }
.screen-cover { position:absolute; z-index:2; inset:0; display:grid; place-items:center; overflow:auto; text-align:center; padding:9px; background:radial-gradient(ellipse,#080914c9 0%, #08091480 38%, #08091400 77%); }
.screen-text { width:min(92%, 540px); }
#game-label { color:#ffcd8a; font:700 clamp(10px,1.35vw,13px) var(--mono); letter-spacing:.16em; text-shadow:1px 2px #1a1330; }
#game-title { margin:4px 0 9px; font:900 clamp(20px,3.4vw,49px)/1.01 var(--mono); letter-spacing:-.09em; text-wrap:balance; overflow-wrap:anywhere; color:#fff6dc; text-shadow:3px 4px #3c255f,0 0 24px #7c60c380; }
#game-title[data-jp] { font-family:var(--body); font-size:clamp(20px,3vw,40px); letter-spacing:-.04em; line-height:1.15; }
#game-message { color:white; font-size:14px; text-shadow:0 0 4px #000; margin:3px auto 8px; }
.play-button { padding:0 16px; min-height:44px; border:1px solid #e7cf9b; border-radius:4px; color:#fff3d8; background:#1c1729ed; font-size:13px; font-weight:800; box-shadow:0 3px 0 #5c4677; }
.play-button span { font-size:11px; margin-right:5px; }
.game-hud { position:absolute; z-index:2; top:0; left:0; width:100%; padding:5px 10px; font:bold 11px var(--mono); color:#fff8e1; background:#070811bc; text-align:left; pointer-events:none; }
.player-actions { display:flex; justify-content:space-between; gap:7px; align-items:center; min-height:54px; padding-top:6px; }
.game-meta { display:flex; align-items:center; gap:8px; font-weight:800; font-size:13px; min-width:0; }
#game-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.work-indicator { color:#e8c687; background:#342b22; border:1px solid #604730; border-radius:4px; padding:3px 6px; font-size:10px; white-space:nowrap; }
.player-buttons, .social-row { display:flex; flex-wrap:wrap; align-items:center; gap:5px; }
.small-button { min-height:44px; min-width:44px; border:1px solid #4a4357; background:#292433; color:#e1d8ed; padding:0 10px; border-radius:5px; font-size:13px; line-height:1.15; text-decoration:none; display:inline-grid; place-items:center; white-space:nowrap; }
#sound { font-size:18px; }
#sound[aria-pressed="true"] { color:var(--mint); }
.control-row { border-top:1px solid #342e3e; margin-top:6px; padding-top:8px; color:var(--dim); font-size:12px; }
#instructions span { margin:0 5px; }
.touch-pad { display:flex; align-items:center; gap:5px; margin-bottom:6px; touch-action:none; }
.touch-pad button { border-radius:5px; min-width:44px; min-height:44px; color:#e8dced; background:#25212f; touch-action:none; user-select:none; }
.touch-pad button[data-pressed] { color:#1a2113; background:var(--mint); }
#touch-action { margin-left:auto; padding-inline:14px; font-size:13px; }
.shelf { padding:31px 0 32px; }
.shelf-heading { display:flex; align-items:end; justify-content:space-between; gap:14px; margin-bottom:14px; }
.shelf-heading h2 { font-size:25px; margin-top:4px; }
#shelf-note { font-size:13px; color:var(--muted); }
.cards { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.card { width:100%; min-width:0; padding:0; display:block; overflow:hidden; color:var(--text); text-align:left; background:#1b1923; border:1px solid #423a4b; border-radius:8px; transition:transform 160ms var(--ease), border-color 140ms var(--ease); }
.card canvas { display:block; width:100%; aspect-ratio:2.45; height:auto; object-fit:cover; image-rendering:pixelated; border-bottom:1px solid #423a4b; }
.card-body { display:block; padding:9px 10px 11px; }
.card strong { display:block; font-size:15px; overflow-wrap:anywhere; }
.card small { display:block; color:#c4b7d1; font-size:11px; }
.shelf-empty { color:var(--muted); }
.footer { display:flex; justify-content:space-between; gap:12px; padding:16px 0 24px; border-top:1px solid #39343f; color:var(--dim); font-size:12px; }
.footer span:first-child { font-family:var(--mono); font-weight:800; color:var(--mint); }
dialog { width:min(480px, calc(100% - 24px)); background:#20202a; color:var(--text); border:1px solid #585064; border-radius:12px; padding:20px; box-shadow:0 24px 80px #0009; }
dialog::backdrop { background:#07070bb5; }
dialog[open] { animation:dialog-in 160ms var(--ease) both; }
@keyframes dialog-in { from { transform:translateY(6px); opacity:0; } to { transform:none; opacity:1; } }
.dialog-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.dialog-head h2 { font-size:22px; }
.dialog-head button { font-size:22px; }
.dialog-status { color:var(--mint); font-size:14px; min-height:1.5em; margin-top:10px; }
.share-label { display:block; margin:15px 0 3px; font-size:13px; color:var(--muted); }
.share-field { display:flex; gap:7px; }
.share-field input { min-width:0; width:100%; padding:8px; border:1px solid #605970; background:#14121d; border-radius:5px; }
.social-row { margin-top:13px; }
.help-steps { padding-left:22px; margin:0; }
.help-steps li + li { margin-top:14px; }
.toast { position:fixed; z-index:5; right:16px; bottom:calc(16px + env(safe-area-inset-bottom)); width:max-content; max-width:calc(100vw - 32px); padding:9px 14px; border:1px solid #627856; border-radius:7px; color:#e9ffd9; background:#273622; box-shadow:0 3px 12px #0008; }
.toast:empty { display:none; }
@media (hover:hover) {
  button:not(.primary):hover, a.small-button:hover { border-color:#8b7a9b; color:white; }
  .primary:hover { background:#d2ffad; }
  .card:hover { transform:translateY(-2px); border-color:#b3a1c4; }
}
@media (max-width:1120px) { .shell { width:calc(100% - 48px); } .fields { gap:6px; } .monitor-body { padding-inline:12px; } }
@media (max-width:940px) {
  .workbench { grid-template-columns:1fr 1fr; gap:12px; }
  .panel-bar { padding-inline:12px; }
  .creator form { padding-inline:12px; }
  .fields { grid-template-columns:.65fr 1.25fr 1.35fr; }
  select { font-size:12px; padding-left:5px; }
  .panel-code { display:none; }
  .player-actions { flex-wrap:wrap; }
}
@media (max-width:700px) {
  .shell { width:calc(100% - 28px); }
  .mast-inner { min-height:96px; grid-template-columns:1fr auto; gap:0; padding-top:8px; }
  .brand img { width:32px; height:32px; }
  .brand { font-size:17px; }
  .nav { grid-row:2; grid-column:1 / -1; overflow:auto; }
  .nav button { min-height:44px; }
  .utility { grid-column:2; grid-row:1; }
  .intro { padding:29px 0 22px; }
  .stamp { display:none; }
  .workbench { grid-template-columns:1fr; }
  .intro-text { font-size:14px; line-height:1.65; }
  .mobile-break { display:initial; }
  .monitor-body { padding:9px; }
  #game-title { font-size:clamp(23px,6vw,43px); }
  #game-title[data-jp] { font-size:clamp(20px,5.4vw,40px); }
  #game-label { font-size:11px; }
  .shelf-heading { align-items:start; flex-direction:column; gap:2px; }
  .cards { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .device-field { margin-block:11px; }
  .player-actions { min-height:48px; }
}
@media (max-width:360px) {
  .ideas { gap:4px; }
  .ideas button { padding:0 5px; font-size:11px; }
  .nav button { padding-inline:11px; }
  .game-meta { gap:5px; }
  .prompt-foot { padding-inline:8px; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.001ms !important; transition-duration:.001ms !important; } }
.export-button { margin-top:12px; width:100%; }
.monitor:not([data-playing]) .touch-pad, [data-touch="no"] .touch-pad { display:none; }
[data-touch="yes"] .touch-pad + p { font-size:13px; }
.small-button:disabled { opacity:.65; cursor:default; }
