* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #14110f; }
body {
  background:
    radial-gradient(ellipse at 50% 30%, #3a2f27 0%, #1b1613 60%, #0d0b09 100%);
  font-family: "Press Start 2P", monospace;
}
#stage { position: fixed; inset: 0; display: grid; place-items: center; }
#tv { position: absolute; left: 50%; top: 50%; width: 1170px; padding-top: 120px; transform: translate(-50%, -50%); transform-origin: center center; }

/* корпус */
.body {
  display: flex; gap: 22px; padding: 34px 30px 34px 34px;
  background: linear-gradient(160deg, #8a5a32 0%, #6b4223 45%, #4a2d17 100%);
  border-radius: 34px;
  box-shadow: inset 0 3px 0 rgba(255,220,170,.35), inset 0 -6px 0 rgba(0,0,0,.35), 0 30px 60px rgba(0,0,0,.7);
  position: relative;
}
.body::before { /* текстура дерева */
  content: ""; position: absolute; inset: 0; border-radius: 34px; pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 2px, transparent 2px 9px);
}
.bezel {
  padding: 16px; border-radius: 46px / 40px; background: #1a1a1c;
  box-shadow: inset 0 0 0 4px #0b0b0c, inset 0 6px 14px #000, 0 2px 0 rgba(255,255,255,.12);
}
.screen {
  position: relative; width: 900px; height: 600px; overflow: hidden; background: #000;
  border-radius: 7% / 9%;
  box-shadow: inset 0 0 60px rgba(0,0,0,.8), 0 0 28px rgba(120,200,255,.15);
  animation: flicker 4s infinite;
}
#game {
  display: block; width: 900px; height: 600px; image-rendering: pixelated;
  filter: contrast(1.12) saturate(1.18) brightness(1.05);
  outline: none; cursor: default;
}
.fx { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.scan { background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.28) 2px 3px); mix-blend-mode: multiply; }
.vig { background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%); }
.glare { background: linear-gradient(125deg, rgba(255,255,255,.10) 0%, rgba(255,255,255,0) 28%); }
@keyframes flicker {
  0%, 100% { opacity: 1; } 47% { opacity: .985; } 48% { opacity: .96; } 50% { opacity: 1; } 83% { opacity: .98; }
}

/* боковая панель */
.panel {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 8px 0;
  background: linear-gradient(180deg, #2b2623, #1d1917); border-radius: 18px;
  box-shadow: inset 0 0 0 3px #12100f, inset 0 3px 8px #000;
}
.brand { color: #e8c98a; font-size: 10px; line-height: 1.6; text-align: center; margin-top: 16px; letter-spacing: 1px; text-shadow: 0 1px 0 #000; }
.grill { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; width: 78px; }
.grill i { display: block; height: 6px; border-radius: 3px; background: #0b0a09; box-shadow: 0 1px 0 rgba(255,255,255,.1); }
.knob {
  width: 70px; height: 70px; border-radius: 50%; border: 0; cursor: pointer; position: relative;
  background: radial-gradient(circle at 35% 30%, #d9d2c6, #7d766b 70%, #4d483f);
  box-shadow: 0 5px 0 #0c0b0a, 0 8px 14px rgba(0,0,0,.6), inset 0 -3px 5px rgba(0,0,0,.4);
}
.knob span { position: absolute; left: 50%; top: 7px; width: 6px; height: 22px; margin-left: -3px; background: #1b1814; border-radius: 3px; transform-origin: 50% 28px; transform: rotate(35deg); }
.knob:active { transform: translateY(2px); }
.knob.dec { cursor: default; } .knob.dec span { transform: rotate(-50deg); }
.led { width: 12px; height: 12px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 10px #ff3b30, 0 0 3px #fff inset; margin-top: auto; margin-bottom: 14px; }

/* антенна и ножки */
.antenna { position: absolute; top: 0; left: 0; right: 0; height: 80px; pointer-events: none; }
.ant { position: absolute; bottom: 26px; left: 50%; width: 5px; height: 110px; background: linear-gradient(#ddd, #888); border-radius: 3px; transform-origin: bottom center; }
.a1 { transform: rotate(-32deg); } .a2 { transform: rotate(28deg); }
.ant::after { content: ""; position: absolute; top: -4px; left: -3px; width: 11px; height: 11px; border-radius: 50%; background: #ccc; }
.ant-base { position: absolute; bottom: 20px; left: 50%; width: 90px; height: 18px; margin-left: -45px; background: #2a2522; border-radius: 40px 40px 0 0; }
.legs { display: flex; justify-content: space-between; padding: 0 90px; height: 26px; }
.legs span { width: 70px; height: 26px; background: linear-gradient(#3a2412, #1b1009); border-radius: 0 0 12px 12px; }


.kwrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.klabel { color: #e8c98a; font-size: 8px; letter-spacing: 1px; text-shadow: 0 1px 0 #000; }
.knob span { transition: transform .15s; }
.knob:focus-visible { outline: 2px solid #ffd23f; outline-offset: 3px; }

/* ---------- сенсорный режим (телефоны и планшеты) ---------- */
html, body, #game, #touch { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#touch, #rotate { display: none; }
html.touch body { background: #000; }
html.touch #tv { padding-top: 0; width: 900px; }
html.touch .antenna, html.touch .panel, html.touch .legs { display: none; }
html.touch .body { padding: 0; background: none; box-shadow: none; border-radius: 0; display: block; }
html.touch .body::before { display: none; }
html.touch .bezel { padding: 0; background: none; box-shadow: none; border-radius: 0; }
html.touch .screen { border-radius: 14px; }

html.touch #touch { display: block; position: fixed; inset: 0; pointer-events: none; z-index: 10; --u: min(11vw, 17vh); }
#touch button {
  pointer-events: auto; position: absolute; width: var(--u); height: var(--u); border-radius: 50%; padding: 0;
  background: rgba(20, 20, 44, .5); border: 2px solid rgba(255, 255, 255, .55); color: #fff;
  font: calc(var(--u) * .42) sans-serif; line-height: 1; display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent; touch-action: none; cursor: pointer;
}
#touch button.on { background: rgba(255, 210, 63, .65); border-color: #ffd23f; }
#touch .tl, #touch .tr, #touch .tm { position: absolute; display: none; }
body.scene-play #touch .game { display: block; }
#touch .tl { left: calc(env(safe-area-inset-left, 0px) + 12px); bottom: 12px; width: calc(var(--u) * 2.3); height: var(--u); }
#touch .tl button:nth-child(1) { left: 0; bottom: 0; } #touch .tl button:nth-child(2) { left: calc(var(--u) * 1.3); bottom: 0; }
#touch .tr { right: calc(env(safe-area-inset-right, 0px) + 12px); bottom: 12px; width: calc(var(--u) * 2.5); height: calc(var(--u) * 2.3); }
#touch .b-jump { right: 0; bottom: 0; width: calc(var(--u) * 1.2); height: calc(var(--u) * 1.2); }
#touch .b-atk { right: calc(var(--u) * 1.35); bottom: 0; }
#touch .b-star { right: 0; bottom: calc(var(--u) * 1.3); }
#touch .b-shield { right: calc(var(--u) * 1.35); bottom: calc(var(--u) * 1.1); }
#touch .tm { left: 50%; bottom: 8px; transform: translateX(-50%); width: calc(var(--u) * 3.6); height: calc(var(--u) * .5); }
#touch .sm { position: static; width: calc(var(--u) * .56); height: calc(var(--u) * .56); font: calc(var(--u) * .2) "Press Start 2P", monospace; background: rgba(20, 20, 44, .4); }
#touch .tm .sm { position: relative; display: inline-grid; margin: 0 2px; }
#touch .tm { display: none; white-space: nowrap; }
body.scene-play #touch .tm { display: block; }
#touch .tb { position: absolute; left: calc(env(safe-area-inset-left, 0px) + 10px); top: 10px; display: none; font-size: calc(var(--u) * .3); }
body.scene-menu #touch .tb { display: grid; }
@media (orientation: portrait) {
  html.touch #rotate { display: flex; position: fixed; inset: 0; z-index: 30; background: #14110f; color: #ffd23f; align-items: center; justify-content: center; text-align: center; padding: 24px; font: 12px/1.8 "Press Start 2P", monospace; }
  html.touch #rotate div { font-size: 12px; }
}
