
  @font-face { font-family: 'Fusion Pixel'; src: url('media/studio/fonts/fusion-pixel-12px-zh_hans.woff2') format('woff2'); font-display: swap; }
  :root {
    --pink: #ff4fa3; --pink2: #ff9fc4; --cyan: #4fe3ff; --violet: #b48cff; --gold: #ffd45e; --green: #5dff8f; --red: #ff4f6a;
    --bg: #07050d; --panel: #0e0a18; --panel2: #140f22; --line: #2a1f3d; --dim: #8b7fa8; --text: #f2ecff;
  }
  * { box-sizing: border-box; }
  html, body { -webkit-tap-highlight-color: transparent; margin: 0; background: var(--bg); color: var(--text); }
  body {
    font-family: "DotGothic16", "Microsoft YaHei", monospace; font-size: 13px; line-height: 1.5;
    background:
      linear-gradient(rgba(255,79,163,.04) 1px, transparent 1px) 0 0 / 100% 3px,
      radial-gradient(circle at 50% -10%, #2a0f2e 0, transparent 55%), var(--bg);
    padding: 14px;
  }
  a { color: var(--cyan); }
  .frame { position: relative; max-width: 1180px; margin: 0 auto; border: 2px solid var(--pink); box-shadow: 0 0 0 4px #2a0a20, 0 0 40px rgba(255,79,163,.25); padding: 10px; background: #0a0712; }
  @media (min-width: 641px) {
    html:not(.fx) .frame > .spider-snd { position: absolute; left: 6px; right: auto; top: auto; bottom: 6px; }
  }
  .top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border: 1px solid var(--line); padding: 8px 12px; background: var(--panel); }
  .logo { display: flex; align-items: center; gap: 10px; font-size: 22px; letter-spacing: 1px; font-weight: bold; }
  .logo canvas { width: 32px; height: 32px; image-rendering: pixelated; background: #1d1430; border: 1px solid var(--pink); }
  .logo b { color: var(--pink); }
  .mood { font-size: 12px; color: var(--dim); white-space: nowrap; }
  .ticker { flex: 1; min-width: 200px; overflow: hidden; white-space: nowrap; color: var(--dim); font-size: 12px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 10px; }
  .ticker span { display: inline-block; animation: tick 40s linear infinite; padding-left: 100%; }
  .ticker em { font-style: normal; color: var(--pink2); }
  .clock { font-size: 18px; color: var(--cyan); border: 1px solid var(--cyan); padding: 2px 10px; box-shadow: inset 0 0 10px rgba(79,227,255,.2); }
  .lang-switch { display: flex; align-items: center; gap: 5px; flex: none; height: 32px; padding: 0 8px; border: 1px solid var(--cyan); background: #0b1020; color: var(--cyan); box-shadow: inset 0 0 10px rgba(79,227,255,.12); }
  .lang-switch .globe { font-size: 14px; line-height: 1; }
  .lang-switch select { max-width: 150px; border: 0; outline: 0; padding: 0; color: var(--text); background: transparent; font: 12px "DotGothic16", "Microsoft YaHei", monospace; cursor: pointer; }
  .lang-switch select option { color: var(--text); background: var(--panel); }
  .lang-switch:focus-within { outline: 2px solid var(--pink); outline-offset: 2px; }
  .bar { display: inline-block; vertical-align: middle; width: 70px; height: 6px; background: #241a35; margin-left: 6px; }
  .bar i { display: block; height: 100%; background: var(--green); transition: width .6s; }

  .grid { display: grid; gap: 8px; margin-top: 8px; }
  .cards { grid-template-columns: repeat(4, 1fr); }
  .panel { position: relative; background: var(--panel); border: 1px solid var(--line); padding: 10px 12px; min-width: 0; }
  .panel::before { content: ""; position: absolute; inset: -1px; border: 1px solid transparent; border-image: linear-gradient(135deg, rgba(255,79,163,.6), transparent 30%, transparent 70%, rgba(79,227,255,.5)) 1; pointer-events: none; }
  .ph { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; margin-bottom: 6px; }
  .ph h2 { min-width: 0; max-width: 100%; margin: 0; font-size: 13px; letter-spacing: 1px; font-weight: normal; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
  .tag { font-size: 10px; border: 1px solid currentColor; padding: 0 5px; color: var(--pink); white-space: nowrap; }
  .card .big { font-size: 22px; color: #fff; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  .card .sub { min-height: 1.5em; }
  .card .sub { color: var(--dim); font-size: 11px; }
  .card .sub.up { color: var(--green); } .card .sub.down { color: var(--red); }
  .card .meter { height: 4px; background: #241a35; margin-top: 6px; }
  .card .meter i { display: block; height: 100%; transition: width .8s; }
  .up { color: var(--green); } .down { color: var(--red); }

  .main { grid-template-columns: 1.55fr 1fr; }
  .cam { padding: 0; overflow: clip; }
  .cam .ph { padding: 8px 12px 0; }
  .cam canvas { display: block; width: 100%; aspect-ratio: 16 / 9; image-rendering: pixelated; }
  .studio-controls { padding: 7px 10px 8px; border-top: 1px solid var(--line); background: #100c1d; }
  .studio-roster-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .studio-roster-row > button, .studio-roster button { font: inherit; font-size: 11px; line-height: 1.4; color: var(--dim); background: #191127; border: 1px solid #3b2b51; padding: 4px 7px; cursor: pointer; touch-action: manipulation; }
  .studio-roster-row > button { flex: none; min-height: 36px; white-space: nowrap; }
  .studio-roster-row > button:hover, .studio-roster button:hover { color: #fff; border-color: var(--cyan); }
  .studio-roster-row button:focus-visible, #studio:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
  .studio-roster { display: flex; flex-wrap: wrap; flex: 1 1 0; min-width: 0; gap: 4px; padding: 3px 0 5px; }
  .studio-roster button { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; border-color: color-mix(in srgb, var(--actor-color) 45%, #292037); color: var(--actor-color); padding: 7px; }
  .studio-roster button canvas { width: 20px; height: 20px; image-rendering: pixelated; flex: none; }
  .studio-roster button[aria-pressed="true"] { background: #30213e; box-shadow: inset 0 -2px 0 var(--actor-color); }
  .studio-roster button { position: relative; }
  .studio-roster button[data-performing="true"]::after { content: ''; position: absolute; right: 1px; top: 1px; width: 3px; height: 3px; background: var(--actor-color); box-shadow: 0 0 0 1px #100c1d; }
  .studio-screen { position: relative; min-width: 0; height: clamp(240px, 56vh, 520px); height: clamp(240px, 56svh, 520px); overflow: hidden; }
  .studio-status { position: absolute; left: 12px; top: 8px; max-width: 68.75%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--status-color, var(--pink2)); font: 12px/1 'Fusion Pixel', 'Microsoft YaHei', monospace; text-shadow: 1px 1px #100c1d; pointer-events: none; }
  .studio-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  @media (max-width: 520px) { .studio-controls { padding: 5px 6px; } .studio-roster-row > button { font-size: 10px; padding: 4px 5px; } }
  .rec { color: var(--red); animation: blink 1.2s steps(2) infinite; }
  .term { font-size: 12px; height: 100%; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
  .term pre { margin: 0; flex: 1 1 0; height: 300px; min-height: 220px; max-height: 340px; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; white-space: pre-wrap; font-family: inherit; color: #cfc3ea; }
  .term pre .t { color: var(--dim); } .term pre .ok { color: var(--green); } .term pre .w { color: var(--gold); } .term pre .p { color: var(--pink); } .term pre .c { color: var(--cyan); }
  .cursor { display: inline-block; width: 7px; height: 12px; background: var(--pink); vertical-align: -1px; animation: blink 1s steps(2) infinite; }

  .lower { grid-template-columns: 1.2fr 1fr 1fr; }
  .chart { min-height: 0; overflow: hidden; }
  /* the canvas is out of flow: its bitmap size can never feed back into the layout */
  .chart-box { position: relative; height: 170px; min-height: 0; overflow: hidden; }
  .chart-box canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
  .chart .val { font-size: 26px; color: var(--green); text-align: right; text-shadow: 0 0 10px rgba(93,255,143,.4); }
  .works { list-style: none; margin: 0; padding: 0; }
  .works li { border: 1px solid var(--line); padding: 8px 10px; margin-bottom: 6px; background: var(--panel2); }
  .works li b { color: #fff; font-weight: normal; font-size: 14px; }
  .works li .st { float: right; max-width: 100%; margin: 0 0 4px 8px; font-size: 10px; white-space: normal; overflow-wrap: anywhere; }
  .works li p { margin: 2px 0 0; color: var(--dim); font-size: 12px; }
  .works li.locked { color: #4a3f60; border-style: dashed; }
  .links { list-style: none; padding: 0; margin: 0; }
  .links li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
  .links li > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .links .ok { color: var(--green); white-space: nowrap; }
  .about { color: #cfc3ea; font-size: 12px; margin: 10px 0 0; }
  footer { text-align: center; color: var(--dim); font-size: 11px; margin-top: 10px; }

  .lbrow { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: inherit; gap: 8px; min-width: 0; }
  .lb { display: flex; flex-direction: column; min-width: 0; margin: 0; }
  .lb-list { list-style: none; margin: 0; padding: 0; height: 232px; max-height: 232px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; font-size: 13px; scrollbar-width: thin; scrollbar-color: var(--pink) transparent; }
  .lb-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto 62px; gap: 6px; padding: 3px 6px; border-bottom: 1px dashed var(--line); align-items: center; }
  .lb-row:nth-child(odd) { background: rgba(255,255,255,.02); }
  .lb-rank { color: var(--dim); text-align: right; }
  .lb-name { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lb-char { color: var(--dim); font-size: 10px; }
  .lb-time { color: var(--dim); font-size: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
  @media (max-width: 520px) { .lb-row { grid-template-columns: 26px minmax(0, 1fr) auto auto 56px; gap: 4px; padding: 3px 4px; font-size: 12px; } .lb-char, .lb-time { font-size: 9px; } }
  .lb-score { color: var(--gold); text-align: right; }
  .lb-row.top1 .lb-rank, .lb-row.top1 .lb-name { color: var(--gold); }
  .lb-row.top2 .lb-rank, .lb-row.top2 .lb-name { color: #d8e0f0; }
  .lb-row.top3 .lb-rank, .lb-row.top3 .lb-name { color: #ffb07a; }
  .lb-row.me { background: rgba(255,79,163,.18); outline: 1px solid var(--pink); }
  .lb-empty { color: var(--dim); padding: 10px 4px; }
  .lb-retry { margin: 6px 0 0; font-size: 12px; color: var(--red); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .lb-retry[hidden] { display: none; }
  .lb-retry button, .lb-btns button.retry { background: var(--gold); color: #1a1030; border: 0; font: 12px "DotGothic16", monospace; padding: 4px 10px; cursor: pointer; }
  .ad { display: flex; flex-direction: column; min-width: 0; margin: 0; }
  .ad-body { flex: 1; display: flex; gap: 14px; align-items: center; justify-content: center; border: 2px dashed var(--line); padding: 12px; min-height: 200px;
    background: repeating-linear-gradient(45deg, rgba(255,212,94,.04) 0 10px, transparent 10px 20px); }
  #adSpin { width: 120px; height: 120px; image-rendering: pixelated; flex: none; }
  .ad-copy b { color: var(--gold); font-size: 18px; font-weight: normal; letter-spacing: 2px; }
  .ad-copy p { margin: 6px 0 0; color: #cfc3ea; font-size: 12px; line-height: 1.5; }
  .ad-copy .dim, .ad-note { color: var(--dim) !important; font-size: 10px !important; }
  .work-stores { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
  .work-stores a { display: inline-block; padding: 4px 0; color: var(--cyan); font-size: 13px; text-underline-offset: 3px; }
  .work-stores a:hover, .work-stores a:focus-visible { color: var(--pink); }
  .legal-h { margin: 0 0 4px; font-size: 12px; font-weight: normal; color: var(--gold); letter-spacing: 1px; }
  .legal-apps { margin-bottom: 8px; }
  .legal-apps .app { color: #fff; }
  .legal-docs { display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .lb-tip { color: var(--dim); font-size: 11px; margin: 6px 0 0; }
  .lb-modal { position: fixed; inset: 0; background: rgba(7,5,13,.72); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
  .lb-modal[hidden] { display: none; }
  .lb-box { width: min(380px, 100%); min-height: 0; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; background: var(--panel); border: 2px solid var(--pink); box-shadow: 0 0 0 4px #2a0a20, 0 0 40px rgba(255,79,163,.4); padding: 16px 18px; }
  .lb-box h3 { margin: 0 0 8px; color: var(--gold); text-align: center; letter-spacing: 2px; animation: blink 1s steps(2) 3; }
  .lb-box p { margin: 0 0 10px; text-align: center; color: var(--text); }
  .lb-box b { color: var(--gold); font-size: 20px; font-weight: normal; }
  .lb-box label { display: block; color: var(--dim); font-size: 12px; }
  .lb-box input { display: block; width: 100%; margin-top: 6px; background: #07050d; border: 1px solid var(--cyan); color: #fff; font: 16px "DotGothic16", monospace; padding: 6px 8px; outline: none; }
  .lb-box input:focus { box-shadow: 0 0 0 2px rgba(79,227,255,.3); }
  .lb-btns { display: flex; gap: 8px; margin-top: 12px; }
  .lb-btns button { flex: 1; min-width: 0; min-height: 44px; overflow-wrap: anywhere; background: var(--pink); color: #fff; border: 0; font: 14px "DotGothic16", monospace; padding: 8px; cursor: pointer; box-shadow: inset 0 -3px 0 #a0205e; }
  .lb-btns button.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); box-shadow: none; }
  .lb-btns button:disabled { opacity: .5; cursor: default; }
  .cc-label { margin-top: 10px; }
  .cc-pick { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
  .cc-pick input { margin-top: 0 !important; flex: 1; min-width: 0; }
  .cc-flag { min-width: 26px; text-align: center; font-size: 18px; }
  .lb-box select { display: block; width: 100%; min-height: 44px; margin-top: 6px; background: #07050d; border: 1px solid var(--line); color: #fff; font: 16px "DotGothic16", monospace; padding: 5px 6px; }
  .flag { display: inline-block; width: 16px; height: 12px; margin-right: 5px; object-fit: cover; vertical-align: -1px; border: 1px solid rgba(255,255,255,.16); }
  .flag-cc { display: inline-block; margin-right: 5px; padding: 0 3px; border: 1px solid var(--line); color: var(--dim); font: 10px/13px monospace; vertical-align: 1px; letter-spacing: .5px; }
  .flag-cc[hidden] { display: none; }
  .lb-msg { min-height: 1.4em; margin: 8px 0 0 !important; color: var(--cyan) !important; font-size: 12px; }

  /* Moderated public guestbook; scrolls within the phone info dock. */
  .guestbook { margin-top: 8px; grid-area: guestbook; }
  .gb-intro, .gb-status, .gb-count, .gb-hint { color: var(--dim); font-size: 12px; }
  .gb-intro { margin: 0 0 14px; line-height: 1.7; }
  .gb-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; }
  .gb-list { list-style: none; margin: 0; padding: 0; }
  .gb-entry { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .gb-entry:first-child { padding-top: 0; }
  .gb-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
  .gb-meta strong { color: var(--pink2); overflow-wrap: anywhere; }
  .gb-meta time { color: var(--dim); font-size: 11px; }
  .gb-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; line-height: 1.7; }
  .gb-reply { border-left: 2px solid var(--cyan); margin-top: 10px; padding: 6px 0 6px 10px; background: #111324; }
  .gb-reply strong { color: var(--cyan); }
  .gb-form { min-width: 0; }
  .gb-form label { display: block; margin: 0 0 12px; }
  .gb-form input, .gb-form textarea { display: block; box-sizing: border-box; width: 100%; margin-top: 5px; padding: 9px; border: 1px solid var(--line); border-radius: 0; background: #090711; color: var(--text); font: inherit; }
  .gb-form textarea { min-height: 110px; resize: vertical; }
  .gb-form input:focus, .gb-form textarea:focus { outline: 1px solid var(--cyan); border-color: var(--cyan); }
  .gb-form .gb-honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
  .gb-count { display: block; text-align: right; }
  .gb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
  .gb-button { min-height: 40px; padding: 7px 12px; background: #201331; border: 1px solid var(--pink); color: var(--text); cursor: pointer; font: inherit; touch-action: manipulation; }
  .gb-button:hover { background: #352047; }
  .gb-button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
  .gb-button:disabled { opacity: .4; cursor: default; }
  .gb-feedback { margin: 10px 0 0; min-height: 1.5em; font-size: 12px; }
  .gb-feedback.success { color: var(--green); } .gb-feedback.error { color: var(--pink2); }
  @media (min-width: 1600px) and (min-aspect-ratio: 4/3) { .guestbook { margin-top: 0; } }
  @media (max-width: 640px) { .gb-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; } .gb-form input, .gb-form textarea { font-size: 16px; } }
/* Shared Live / game stage, based on the approved layout trial. */
.frame { max-width: 1440px; display:grid; gap:12px; grid-template-columns:minmax(0, 1fr) 320px; grid-template-rows:auto; grid-template-areas:"top top" "cards cards" "stage sidebar" "lower lower" "ad ad" "guestbook guestbook" "foot foot" "credit credit"; padding:16px; }
.frame > .grid {margin:0}
.top {grid-area:top}
.cards {grid-area:cards; gap:12px}
.term {height:250px}
.term pre {height:195px}
.lb {max-height:340px; overflow:auto}
.lower {grid-area:lower; display:grid; grid-template-columns: .8fr 1.3fr 1fr; gap:12px}
.lower > * {grid-area:auto}
.ad {grid-area:ad}
.ad-body {min-height:110px; padding:12px; display:flex; justify-content:center; gap:36px; align-items:center}
#adSpin {width:84px;height:84px}
.guestbook {grid-area:guestbook; margin:0}
footer {grid-area:foot}
.geo-credit {grid-area:credit}
.layout-stage {grid-area:stage;padding:0;align-self:start;overflow:hidden;background:linear-gradient(145deg,#171025,#0c0915)}
.stage-toolbar {display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);padding:12px 16px;gap:12px;background:#100b1d}
.stage-tabs {display:flex;gap:6px}
.stage-tabs button {min-height:44px;font:inherit;cursor:pointer;color:var(--dim);background:transparent;border:1px solid transparent;padding:10px 16px}
.stage-tabs button[aria-selected=true] {color:var(--cyan);border-color:#315867;background:#142733;box-shadow:inset 0 -2px var(--cyan)}
.stage-tabs button:focus-visible {outline:2px solid var(--pink);outline-offset:2px}
.stage-index {font-size:10px;letter-spacing:2px;color:var(--dim)}
.layout-stage [hidden] {display:none!important}
.layout-stage .cam, .layout-stage .arc {border:0;margin:0;padding:14px;grid-area:auto;box-shadow:none}
.layout-stage .panel::before {display:none}
.layout-stage .cam .ph, .layout-stage .arc .ph {margin-bottom:12px}
.layout-stage #studio {display:block;width:100%;height:100%;aspect-ratio:auto}
.layout-stage .arcade {display:block;margin:0}
.layout-stage .arc {--fit:none;min-height:0;display:flex;flex-direction:column;justify-content:flex-start}
.layout-stage .studio-controls {padding-top:12px}
.layout-stage .help {margin-top:16px;font-size:11px;line-height:1.8}
@media(max-width:1000px){.frame {grid-template-columns:minmax(0,1fr);grid-template-areas:"top" "cards" "stage" "sidebar" "lower" "ad" "guestbook" "foot" "credit"} .lower {grid-template-columns:1fr 1fr}.lower .legal {grid-column:1/-1}}
@media(max-width:640px){body{padding:6px}.frame {padding:8px;gap:8px}.stage-toolbar{padding:8px}.stage-index{display:none}.stage-tabs{width:100%}.stage-tabs button{flex:1;padding:10px 5px}.layout-stage .cam,.layout-stage .arc {padding:8px}.layout-stage .arc{min-height:0}.lower{grid-template-columns:1fr}.ad-body{gap:12px}.stage-tabs button{font-size:12px}}
/* One shared audio control for the visible stage. */
.site-layout #bgmBtn {display:none!important}
.stage-audio {display:flex;align-items:center;gap:8px;color:var(--dim);font-size:11px}
.stage-audio button {min-height:36px;font:inherit;color:var(--cyan);background:#142733;border:1px solid #315867;padding:7px 10px;cursor:pointer;white-space:nowrap}
.stage-audio button:focus-visible {outline:2px solid var(--pink)}

/* Keep the right rail independent of the taller stage's grid tracks. */
.layout-sidebar {grid-area:sidebar;display:flex;flex-direction:column;gap:12px;min-width:0;align-self:start}
.layout-sidebar > .panel {min-width:0;min-height:0}
.layout-sidebar .term {height:250px;flex:none}
.layout-sidebar .lb {height:320px;max-height:none;flex:none;overflow:hidden}
.layout-sidebar .lb-list {height:auto;min-height:0;max-height:none;flex:1 1 0;overflow-y:auto}
.layout-sidebar .ph,.layout-sidebar .lb-tip,.layout-sidebar .lb-retry {flex:none}

/* Touch controls overlay the original playfield without extending it. */
.layout-stage .arc {min-height:0;justify-content:flex-start}
.site-layout .game-title-tools {display:flex;align-items:center;gap:10px;flex:none}
.site-layout .game-pause {position:absolute;left:6px;top:30%;z-index:2;display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;padding:0;border:1px solid rgba(79,227,255,.42);border-radius:8px;background:rgba(9,7,18,.45);color:var(--text);font:20px/1 monospace;cursor:pointer;touch-action:manipulation;-webkit-user-select:none;user-select:none}
.site-layout .game-pause[aria-pressed=true] {color:var(--cyan);border-color:#315867;background:#142733}
.site-layout .game-surface {position:relative;width:100%;min-width:0;max-width:calc((100vh - 148px) * 1.5);max-width:calc((100svh - 148px) * 1.5);margin-inline:auto;background:#090712;border:1px solid #2a2440;overflow:hidden;isolation:isolate}
.site-layout .game-surface #game {display:block;width:100%;height:auto;aspect-ratio:3/2;max-width:none;margin:0;border:0;box-shadow:none;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.site-layout .game-down {position:absolute;right:6px;bottom:6px;z-index:2;display:inline-flex;align-items:center;justify-content:center;flex:none;width:clamp(48px,10%,100px);height:auto;aspect-ratio:1;padding:0;border:0;background:transparent;color:var(--cyan);cursor:pointer;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.site-layout .game-down::before {content:"";position:absolute;inset:6px;border:1px solid rgba(79,227,255,.42);border-radius:20%;background:rgba(79,227,255,.07);transition:background .08s,border-color .08s}
.site-layout .game-down canvas {position:relative;width:48%;height:auto;aspect-ratio:1;image-rendering:pixelated;opacity:.68;pointer-events:none}
.site-layout .game-down[aria-pressed=true]::before {border-color:var(--cyan);background:rgba(79,227,255,.2)}
.site-layout .game-down[aria-pressed=true] canvas {opacity:1}
.site-layout .game-down:focus-visible, .site-layout .game-pause:focus-visible {outline:2px solid var(--pink);outline-offset:-3px}
@media(max-width:640px){.site-layout .game-title-row h2 {font-size:11px;letter-spacing:0}.site-layout .game-title-tools {gap:7px}.site-layout .game-title-tools .tag {display:none}}
/* Keep phone controls proportional to the small playfield. The transparent
   target stays easy to press while the visible button leaves the road clear. */
@media(max-width:640px), (max-width:1000px) and (max-height:520px) {
  .site-layout .game-down {width:52px;height:52px;right:3px;bottom:3px}
  .site-layout .game-down::before {inset:6px;border-radius:9px;background:rgba(9,7,18,.3)}
  .site-layout .game-down canvas {width:24px;height:24px;opacity:.8}
  .site-layout .game-pause {left:3px;top:34%;width:44px;height:44px;border:0;border-radius:0;background:transparent;font-size:14px}
  .site-layout .game-pause::before {content:"";position:absolute;inset:7px;border:1px solid rgba(79,227,255,.4);border-radius:6px;background:rgba(9,7,18,.32)}
  .site-layout .game-pause > span {position:relative;pointer-events:none}
  .site-layout .game-pause[aria-pressed=true] {background:transparent}
  .site-layout .game-pause[aria-pressed=true]::before {border-color:var(--cyan);background:rgba(20,39,51,.8)}
}
@media(max-width:640px) {
  .site-layout .layout-stage .arc {padding:8px 0 0}
  .site-layout .game-title-row {padding:0 8px}
  .site-layout .game-surface {border-left:0;border-right:0;border-bottom:0}
}
@media(max-width:360px) {
  .site-layout .game-down {width:48px;height:48px}
}
@media(prefers-reduced-motion:reduce){.site-layout .game-down::before {transition:none}}

.site-layout .game-surface #game:focus-visible {outline:2px solid var(--cyan);outline-offset:-2px}


/* Fluid page layout on phones and desktops; canvases retain their own ratios. */
html { -webkit-text-size-adjust:100%;text-size-adjust:100%; }
[hidden] {display:none!important}
input,textarea,select {-webkit-user-select:text;user-select:text}
@keyframes tick {to {transform:translateX(-100%)}}
@keyframes blink {50% {opacity:0}}
.geo-credit {font-size:10px;text-align:right;opacity:.65}
.geo-credit a {color:var(--dim)}
/* Keep the pet's sound switch beside the footer credit, clear of language input. */
.site-layout .frame > button.spider-snd {position:static;grid-area:credit;justify-self:start;align-self:center;width:44px;height:44px;line-height:40px;left:auto;right:auto;top:auto;bottom:auto}
.site-layout .geo-credit {align-self:center;padding-left:56px}
.stage-tabs,.stage-tabs button,.stage-audio,.game-surface {min-width:0}
.stage-tabs button {line-height:1.4;touch-action:manipulation}
.stage-audio {flex-wrap:wrap;justify-content:flex-end}
.stage-toolbar {flex-wrap:wrap}
.layout-sidebar .term pre {min-height:0;max-height:none;overflow-wrap:anywhere}
.site-layout .layout-stage .cam .ph {padding:0}
.layout-stage #studio {outline-offset:-2px}
.layout-stage .studio-roster button canvas {width:20px;height:20px;aspect-ratio:1}
.game-surface #game {image-rendering:pixelated;background:#000;cursor:pointer}
.top > * {min-width:0}
footer {overflow-wrap:anywhere}
@media(min-width:641px) and (max-width:1000px) {
  .layout-sidebar {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}
  .layout-sidebar .term {height:300px}
  .layout-sidebar .lb {height:300px}
}
@media(min-width:641px) and (max-width:900px) {
  .cards {grid-template-columns:repeat(2,minmax(0,1fr))}
}
/* Keep every friend visible and the icon art small inside generous touch targets. */
@media(max-width:640px), (pointer:coarse) {
  .studio-roster-row {align-items:end;gap:6px}
  .studio-roster {display:grid;grid-template-columns:repeat(auto-fit,minmax(44px,1fr));gap:4px 3px;padding:0}
  .studio-roster button {min-width:44px;min-height:44px;padding:10px}
  .studio-roster-row > button {width:56px;min-height:44px;padding:5px 3px;font-size:11px;line-height:1.35;white-space:normal;overflow-wrap:anywhere}
  .stage-audio button,.gb-button {min-height:44px}
  .lang-switch {min-height:44px}
  .lang-switch select {font-size:16px}
}
@media(max-width:640px) {
  .top {display:grid;grid-template-columns:minmax(0,1fr) 108px;grid-template-areas:"brand language" "mood clock" "ticker ticker";gap:6px 8px;padding:8px}
  .logo {grid-area:brand;gap:7px;font-size:clamp(13px,3.8vw,16px);letter-spacing:0;white-space:nowrap}
  .logo canvas {width:24px;height:24px;flex:none}
  .ticker {grid-area:ticker;min-width:0;border:0;padding:0;line-height:1.6}
  .mood {grid-area:mood;font-size:11px}
  .mood .bar {width:44px;margin-left:4px}
  .lang-switch {grid-area:language;gap:3px;margin:0;padding:0 5px;width:108px}
  .lang-switch .globe {font-size:12px;flex:none}
  .lang-switch select {width:100%;min-width:0;max-width:none;height:40px}
  .clock {grid-area:clock;justify-self:end;min-height:32px;display:flex;align-items:center}
  .clock {font-size:15px;padding:2px 6px}
  .cards {grid-template-columns:repeat(2,minmax(0,1fr))}
  .card {padding:8px}
  .card .big {font-size:20px}
  .stage-tabs {width:auto;flex:1 1 0;gap:4px}
  .stage-tabs button {min-width:0;flex:1 1 0;white-space:normal}
  .stage-audio {width:auto;flex:none;justify-content:flex-end}
  .stage-audio button {white-space:nowrap}
  .ph h2 {font-size:12px;letter-spacing:0;overflow-wrap:anywhere}
  .card .ph {align-items:flex-start;flex-wrap:wrap;gap:3px}
  .layout-sidebar .term {height:230px}
  .layout-sidebar .lb {height:300px}
  .works li b,.about,.legal-h,.lb-box label,.lb-box p {overflow-wrap:anywhere}
  .links .ok {white-space:normal}
  .ad-body {flex-wrap:wrap;text-align:center}
  .ad-copy b {font-size:16px;letter-spacing:1px}
}
@media(max-width:1000px) and (max-height:520px) and (orientation:landscape) {
  .studio-screen {height:clamp(200px,calc(100vh - 154px),320px);height:clamp(200px,calc(100svh - 154px),320px)}
  .stage-tabs {width:auto;flex:1 1 180px}
  .stage-audio {width:auto;flex:0 1 auto}
}
@media(prefers-reduced-motion:reduce) {.ticker span,.rec,.cursor {animation:none}}
