/* ---------- page bits not in the base sheet ---------- */

.hero { padding-bottom: 24px; }
.section { margin: 48px 0; scroll-margin-top: 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 14px; }
.section-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 17px; font-weight: 400; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.toolbar .btn { padding: 10px 16px; }
.note-panel { padding: 16px 18px; color: var(--dim); font-size: 15px; line-height: 1.55; }
.note-panel b { color: var(--text); font-weight: 500; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; color: var(--text); }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 18px; padding: 18px; }
.keys div { display: flex; align-items: center; gap: 5px; font-size: 14.5px; color: var(--dim); }
.keys div span { margin-left: 6px; }
kbd {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px;
  font: 500 12.5px var(--font); color: var(--text);
  background: var(--chip); border: 1px solid var(--card-line); border-bottom-width: 2px; border-radius: 7px;
}

/* ---------- stage ---------- */

.stage { display: flex; justify-content: center; }
.device { container-type: inline-size; width: min(100%, 960px, calc((100vh - 150px) * 4 / 3)); min-width: 280px; }
.stage[data-view="device"] .device { width: min(100%, 520px, calc((100vh - 110px) * 0.633)); }

.shell { position: relative; }
.glass {
  background: #050505;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 18px 50px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: grid; place-items: center;
}
.screen {
  position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  background: #000; border-radius: 4px; outline: none;
  container-type: inline-size;
}
.glass:fullscreen { border-radius: 0; padding: 0; background: #000; }
.glass:fullscreen .screen { width: min(100vw, 133.334vh); border-radius: 0; }

.controls { display: none; }

/* ----- full handheld (RG35XX Pro: 81 x 128 mm, black) ----- */

.stage[data-view="device"] .shell {
  aspect-ratio: 81 / 128;
  background: linear-gradient(160deg, #2a2a2c 0%, #1c1c1e 38%, #161617 100%);
  border-radius: 5cqw 5cqw 13cqw 5cqw;
  box-shadow:
    0 30px 70px var(--shadow),
    inset 0 0.5cqw 0.4cqw rgba(255, 255, 255, 0.09),
    inset 0 -1cqw 1.4cqw rgba(0, 0, 0, 0.55),
    inset 0.5cqw 0 0.6cqw rgba(255, 255, 255, 0.03);
}
.stage[data-view="device"] .glass {
  position: absolute; left: 2.6cqw; right: 2.6cqw; top: 2.6cqw; height: 73.5cqw;
  padding: 0; border-radius: 2.6cqw;
  background: linear-gradient(135deg, #0d0d0e, #020202 60%);
  box-shadow: inset 0 0 0 0.25cqw rgba(255, 255, 255, 0.05), 0 0.4cqw 0.8cqw rgba(0, 0, 0, 0.5);
}
.stage[data-view="device"] .glass:not(:fullscreen) .screen { width: 87cqw; border-radius: 0.6cqw; }
.stage[data-view="device"] .controls { display: block; position: absolute; left: 0; right: 0; top: 78cqw; bottom: 0; }

.controls button { font: inherit; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ring {
  position: absolute; top: 3cqw; width: 33cqw; height: 33cqw; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #19191a, #121213);
  box-shadow: inset 0 0.6cqw 1cqw rgba(0, 0, 0, 0.7), inset 0 -0.3cqw 0.4cqw rgba(255, 255, 255, 0.05), 0 0.2cqw 0 rgba(255, 255, 255, 0.04);
}
.dpad-ring { left: 6cqw; }
.face-ring { right: 6cqw; }

/* d-pad: one cross that tips towards the pressed side */
.dpad { position: absolute; inset: 4.5cqw; transition: transform .06s; transform-style: preserve-3d; }
.dpad::before, .dpad::after {
  content: ""; position: absolute; background: #232325; border-radius: 1.4cqw;
  box-shadow: 0 0.5cqw 0.6cqw rgba(0, 0, 0, 0.6), inset 0 0.3cqw 0.3cqw rgba(255, 255, 255, 0.08);
}
.dpad::before { left: 34%; right: 34%; top: 0; bottom: 0; }
.dpad::after { top: 34%; bottom: 34%; left: 0; right: 0; }
.dpad .arm { position: absolute; z-index: 1; background: transparent; }
.dpad .arm::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  border: 1.5cqw solid transparent; border-bottom-color: #0c0c0d; border-top-width: 0;
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
}
.dpad .up { left: 34%; right: 34%; top: 0; height: 34%; }
.dpad .down { left: 34%; right: 34%; bottom: 0; height: 34%; --r: 180deg; }
.dpad .left { top: 34%; bottom: 34%; left: 0; width: 34%; --r: -90deg; }
.dpad .right { top: 34%; bottom: 34%; right: 0; width: 34%; --r: 90deg; }
.dpad .arm.on::after, .dpad .arm:active::after { border-bottom-color: #cbaa0f; }
.dpad .hub { position: absolute; z-index: 1; left: 44%; top: 44%; width: 12%; height: 12%; border-radius: 50%; background: #111; box-shadow: inset 0 0.2cqw 0.3cqw #000; }
.dpad.t-up { transform: perspective(60cqw) rotateX(14deg); }
.dpad.t-down { transform: perspective(60cqw) rotateX(-14deg); }
.dpad.t-left { transform: perspective(60cqw) rotateY(-14deg); }
.dpad.t-right { transform: perspective(60cqw) rotateY(14deg); }
.dpad.t-up.t-left { transform: perspective(60cqw) rotateX(11deg) rotateY(-11deg); }
.dpad.t-up.t-right { transform: perspective(60cqw) rotateX(11deg) rotateY(11deg); }
.dpad.t-down.t-left { transform: perspective(60cqw) rotateX(-11deg) rotateY(-11deg); }
.dpad.t-down.t-right { transform: perspective(60cqw) rotateX(-11deg) rotateY(11deg); }

/* face buttons */
.face {
  position: absolute; width: 9.6cqw; height: 9.6cqw; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #323235, #1d1d1f 70%);
  box-shadow: 0 0.6cqw 0.7cqw rgba(0, 0, 0, 0.65), inset 0 0.3cqw 0.3cqw rgba(255, 255, 255, 0.1);
  font-family: var(--font) !important; font-weight: 600 !important; font-size: 4.4cqw !important; line-height: 1;
  transition: transform .05s, box-shadow .05s;
}
.face.x { left: 50%; top: 2.2cqw; margin-left: -4.8cqw; color: #3b6fe0; }
.face.b { left: 50%; bottom: 2.2cqw; margin-left: -4.8cqw; color: #e0c020; }
.face.y { top: 50%; left: 2.2cqw; margin-top: -4.8cqw; color: #35b058; }
.face.a { top: 50%; right: 2.2cqw; margin-top: -4.8cqw; color: #d8413a; }
.face.on, .face:active, .menu-btn.on, .menu-btn:active {
  transform: translateY(0.45cqw) scale(0.95);
  box-shadow: 0 0.1cqw 0.2cqw rgba(0, 0, 0, 0.7), inset 0 0.4cqw 0.6cqw rgba(0, 0, 0, 0.6);
  filter: brightness(1.35);
}

.menu-btn {
  position: absolute; left: 50%; top: 4.2cqw; width: 5.6cqw; height: 5.6cqw; margin-left: -2.8cqw; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #2c2c2e, #19191b 70%); color: #55555a;
  box-shadow: 0 0.4cqw 0.5cqw rgba(0, 0, 0, 0.6), inset 0 0.2cqw 0.2cqw rgba(255, 255, 255, 0.08);
  transition: transform .05s;
}
.menu-btn span { font: 600 2.6cqw var(--font); }

.pill-wrap { position: absolute; top: 30cqw; width: 12cqw; text-align: center; }
.pill-wrap.select { left: 36.5cqw; }
.pill-wrap.start { left: 51.5cqw; top: 28cqw; }
.pill {
  display: block; width: 9cqw; height: 3.5cqw; margin: 0 auto; border-radius: 2cqw; transform: rotate(-28deg);
  background: linear-gradient(#2b2b2d, #1a1a1c);
  box-shadow: 0 0.4cqw 0.5cqw rgba(0, 0, 0, 0.6), inset 0 0.2cqw 0.2cqw rgba(255, 255, 255, 0.09);
  transition: transform .05s, filter .05s;
}
.pill.on, .pill:active { transform: rotate(-28deg) translateY(0.35cqw) scale(0.95); filter: brightness(1.5); }
.pill-wrap span { display: block; margin-top: 2.6cqw; font: 500 1.9cqw var(--font); letter-spacing: 0.08em; color: #5a5a5e; transform: rotate(-28deg); }

/* sticks */
.stick-well {
  position: absolute; top: 44cqw; width: 23cqw; height: 23cqw; border-radius: 50%;
  background: radial-gradient(circle, #060606 55%, #141415 72%);
  box-shadow: inset 0 0.8cqw 1.4cqw #000, 0 0.25cqw 0 rgba(255, 255, 255, 0.05);
}
.stick-well.left { left: 16.5cqw; }
.stick-well.right { right: 16.5cqw; }
.stick {
  position: absolute; inset: 3.4cqw; border-radius: 50%; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 50% 42%, #1a1a1c 0 38%, #2d2d30 42%, #222224 60%, #161618 100%);
  box-shadow: 0 0.9cqw 1.2cqw rgba(0, 0, 0, 0.75), inset 0 0.3cqw 0.4cqw rgba(255, 255, 255, 0.1);
  transform: translate(calc(var(--sx, 0) * 3.6cqw), calc(var(--sy, 0) * 3.6cqw));
  transition: transform .09s ease-out;
}
.stick.drag { transition: none; cursor: grabbing; }

.speaker { position: absolute; right: 7cqw; bottom: 4.6cqw; display: flex; gap: 1.1cqw; transform: rotate(-32deg); }
.speaker i { display: block; width: 1.1cqw; height: 4.4cqw; border-radius: 1cqw; background: #070707; box-shadow: 0 0.15cqw 0 rgba(255, 255, 255, 0.06); }

/* ---------- muOS-style interface (designed on a 640 x 480 grid) ---------- */

.mu, .game, .dropveil { position: absolute; inset: 0; }
.game { background: #000; }
.game iframe { width: 100%; height: 100%; border: 0; display: block; }
.dropveil { display: grid; place-items: center; background: rgba(16, 8, 8, 0.82); color: #efd614; font: 500 4cqw "Noto Sans", sans-serif; border: 0.6cqw dashed #cbaa0f; }
.dropveil[hidden], .game[hidden] { display: none; }

.mu {
  --px: calc(100cqw / 640);
  --accent: #cbaa0f; --accent2: #9c7400; --ink: #100808;
  font-family: "Noto Sans", system-ui, sans-serif; font-weight: 500; color: #fff;
  font-size: calc(22 * var(--px)); line-height: 1;
  background: linear-gradient(#444444, #000000);
  user-select: none; -webkit-user-select: none; cursor: default;
}
.mu.launch { background: #001844 url(/g/wall.webp?v=1) center / cover; }
.mu-head {
  position: absolute; left: 0; right: 0; top: 0; height: calc(42 * var(--px));
  display: flex; align-items: center; justify-content: space-between; padding: 0 calc(10 * var(--px));
  font-size: calc(24 * var(--px)); text-shadow: 0 calc(1 * var(--px)) calc(2 * var(--px)) rgba(0, 0, 0, 0.7);
}
.mu-title { position: absolute; left: 25%; right: 25%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mu-status { display: flex; align-items: center; gap: calc(7 * var(--px)); }
.gl {
  display: inline-block; flex: none; width: calc(24 * var(--px)); height: calc(24 * var(--px)); background: currentColor;
  -webkit-mask: var(--g) center / contain no-repeat; mask: var(--g) center / contain no-repeat;
}
.mu-status .gl.net { color: var(--accent); }
.mu-status .gl.bat { color: #e8e8e8; }

.mu-foot {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(44 * var(--px));
  display: flex; align-items: center; gap: calc(12 * var(--px)); padding: 0 calc(18 * var(--px));
  font-size: calc(24 * var(--px)); text-shadow: 0 calc(1 * var(--px)) calc(2 * var(--px)) rgba(0, 0, 0, 0.7);
}
.mu-foot span { display: inline-flex; align-items: center; gap: calc(8 * var(--px)); cursor: pointer; }
.mu-foot .gl { color: var(--accent); width: calc(26 * var(--px)); height: calc(26 * var(--px)); }

/* main menu grid */
.mu-grid {
  position: absolute; left: calc(16 * var(--px)); top: calc(60 * var(--px));
  display: grid; grid-template-columns: repeat(4, calc(140 * var(--px))); gap: calc(20 * var(--px)) calc(16 * var(--px));
}
.mu-cell {
  height: calc(140 * var(--px)); border-radius: calc(14 * var(--px)); display: grid; place-items: center; cursor: pointer;
  background: rgba(96, 96, 96, 0.72); color: #d6d6d6;
  box-shadow: calc(4 * var(--px)) calc(6 * var(--px)) calc(10 * var(--px)) rgba(0, 0, 0, 0.45);
}
.mu-cell .gl { width: calc(88 * var(--px)); height: calc(88 * var(--px)); }
.mu-cell.sel { background: linear-gradient(rgba(203, 170, 15, 0.92), rgba(156, 116, 0, 0.92)); color: #e9e2c4; }
.mu-label {
  position: absolute; left: calc(15 * var(--px)); right: calc(15 * var(--px)); top: calc(380 * var(--px)); height: calc(50 * var(--px));
  border-radius: calc(10 * var(--px)); background: rgba(96, 96, 96, 0.72); color: #e8e8e8;
  display: grid; place-items: center; font-size: calc(24 * var(--px));
  box-shadow: calc(4 * var(--px)) calc(6 * var(--px)) calc(10 * var(--px)) rgba(0, 0, 0, 0.45);
}

/* lists */
.mu-list { position: absolute; left: 0; right: 0; top: calc(43 * var(--px)); height: calc(387 * var(--px)); overflow: hidden; }
.mu-row {
  height: calc(43 * var(--px)); display: flex; align-items: center; gap: calc(11 * var(--px));
  padding: 0 calc(12 * var(--px)) 0 calc(13 * var(--px)); border-radius: calc(6 * var(--px)); cursor: pointer;
  text-shadow: 0 calc(1 * var(--px)) calc(2 * var(--px)) rgba(0, 0, 0, 0.6);
}
.mu-row .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-bottom: calc(2 * var(--px)); }
.mu-row .val { flex: none; max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mu-row.sel { background: var(--accent); color: var(--ink); text-shadow: none; }
.mu-empty { position: absolute; left: 8%; right: 8%; top: 38%; text-align: center; color: #b8b8b8; line-height: 1.45; }
.mu-count { color: #e8e8e8; font-size: calc(20 * var(--px)); }

/* text pages, boot, off, toast */
.mu-text { position: absolute; left: calc(22 * var(--px)); right: calc(22 * var(--px)); top: calc(56 * var(--px)); bottom: calc(50 * var(--px)); font-weight: 400; font-size: calc(20 * var(--px)); line-height: 1.5; color: #e8e8e8; white-space: pre-line; overflow: hidden; }
.mu-boot { position: absolute; inset: 0; background: #000 url(/g/boot.webp?v=1) center / contain no-repeat; }
.mu-off { position: absolute; inset: 0; background: #000; display: grid; place-items: end center; padding-bottom: 6%; color: #2f2f2f; font-size: calc(18 * var(--px)); cursor: pointer; }
.mu-toast {
  position: absolute; left: 50%; bottom: calc(56 * var(--px)); transform: translateX(-50%); max-width: 88%;
  padding: calc(10 * var(--px)) calc(18 * var(--px)); border-radius: calc(8 * var(--px));
  background: #100808; border: calc(2 * var(--px)) solid #efd614; color: #e8e8e8; font-size: calc(19 * var(--px)); line-height: 1.3; text-align: center;
}

@media (max-width: 640px) {
  .glass { padding: 6px; border-radius: 10px; }
  .toolbar .btn { flex: 1 1 44%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .dpad, .stick, .face, .pill, .menu-btn { transition: none; }
}
