* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #07060c;
  background-image:
    radial-gradient(ellipse at 50% 0%, #241a3f 0%, #0d0a16 55%, #07060c 100%);
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: #e8e2d0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#frame {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* o tamanho vem do script, já casado com a grade de pixels físicos */
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 2px;
  box-shadow:
    0 0 0 3px #1c1730,
    0 0 0 5px #3c3158,
    0 0 40px rgba(120, 90, 200, 0.35),
    0 18px 60px rgba(0, 0, 0, 0.8);
}

/* ---------- Tela de boot (necessaria para liberar o audio) ---------- */

#boot {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 6, 12, 0.94);
  backdrop-filter: blur(3px);
  z-index: 20;
  cursor: pointer;
}

#boot.hidden {
  display: none;
}

.boot-inner {
  text-align: center;
  padding: 24px;
}

.boot-inner h1 {
  font-size: clamp(22px, 5vw, 46px);
  letter-spacing: 3px;
  font-weight: 800;
  color: #d8352e;
  text-shadow:
    0 2px 0 #5c110f,
    0 4px 14px rgba(216, 53, 46, 0.45);
}

.boot-inner p {
  margin-top: 6px;
  font-size: clamp(12px, 2.4vw, 20px);
  letter-spacing: 4px;
  color: #e6c761;
  text-transform: uppercase;
}

#boot-btn {
  margin-top: 26px;
  padding: 12px 40px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 3px;
  color: #10202e;
  background: linear-gradient(#ffe9a6, #e0b23f);
  border: 2px solid #8a6a1c;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

#boot-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.boot-inner small {
  display: block;
  margin-top: 14px;
  color: #6f6a86;
  letter-spacing: 1px;
}

/* ---------- Controles em tela (mobile) ---------- */

#touch {
  position: fixed;
  inset: auto 0 0 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 18px 20px 26px;
  z-index: 15;
  pointer-events: none;
}

body.touch #touch {
  display: flex;
}

.pad {
  position: relative;
  width: 150px;
  height: 150px;
  pointer-events: auto;
}

.tbtn {
  position: absolute;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 10px;
  background: rgba(60, 49, 88, 0.55);
  border: 2px solid rgba(190, 170, 255, 0.28);
  padding: 8px;
}

.tbtn[data-key="up"]    { left: 50px; top: 0; }
.tbtn[data-key="left"]  { left: 0; top: 50px; }
.tbtn[data-key="right"] { left: 100px; top: 50px; }
.tbtn[data-key="down"]  { left: 50px; top: 100px; }

.acts {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
}

.abtn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(190, 170, 255, 0.28);
  background: rgba(60, 49, 88, 0.55);
  padding: 6px;
}

.abtn.primary {
  width: 78px;
  height: 78px;
  background: rgba(150, 40, 40, 0.55);
}

.abtn.small {
  width: 46px;
  height: 46px;
}

.tbtn svg, .abtn svg {
  width: 100%;
  height: 100%;
  fill: #e5dcff;
}

.abtn text {
  fill: #e5dcff;
  font-size: 11px;
  font-weight: bold;
  font-family: sans-serif;
}

.tbtn:active, .abtn:active {
  filter: brightness(1.6);
}

/* ---------- Painel de volume ---------- */

#audio-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 18;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#mute-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 2px solid rgba(190, 170, 255, 0.28);
  background: rgba(28, 23, 48, 0.82);
  padding: 8px;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}

#mute-btn:hover {
  filter: brightness(1.3);
  transform: translateY(-2px);
}

#mute-btn svg {
  width: 100%;
  height: 100%;
  fill: #e6c761;
  stroke: #e6c761;
  stroke-linecap: round;
}

#mute-btn .icon-off {
  display: none;
}

#mute-btn.muted .icon-on {
  display: none;
}

#mute-btn.muted .icon-off {
  display: block;
}

#mute-btn.muted svg {
  fill: #7a7490;
  stroke: #7a7490;
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid rgba(190, 170, 255, 0.22);
  background: rgba(20, 16, 36, 0.88);
  opacity: 0.8;
  transition: opacity 0.18s ease;
}

#audio-panel:hover .sliders,
.sliders:focus-within {
  opacity: 1;
}

.sliders b {
  width: 26px;
  font-weight: 600;
  color: #e6c761;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sliders label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #b8afd4;
}

.sliders span {
  width: 52px;
  text-align: right;
}

.sliders input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 4px;
  border-radius: 2px;
  background: #3c3158;
  outline: none;
  cursor: pointer;
}

.sliders input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #e6c761;
  border: 2px solid #8a6a1c;
  cursor: pointer;
}

.sliders input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e6c761;
  border: 2px solid #8a6a1c;
  cursor: pointer;
}

body.touch #audio-panel {
  bottom: auto;
  top: 14px;
  right: 14px;
}

body.touch .sliders {
  display: none;
}
