:root { --ink: #2d1b4e; --gold: #ffd166; --coral: #ff7a4d; --mint: #7dffd0; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #3b2a63; }
body { font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: #fff; }
canvas { display: block; touch-action: none; }

#hud { position: fixed; top: 10px; left: 12px; right: 12px; pointer-events: none; z-index: 5; }
.hud-row { display: flex; gap: 8px; flex-wrap: wrap; }
.hud-chip {
  background: rgba(45, 27, 78, 0.68); border: 1px solid rgba(255, 209, 102, 0.5);
  border-radius: 999px; padding: 5px 12px; font-size: 14px; backdrop-filter: blur(3px);
}
.hud-chip b { color: var(--gold); }
#hud-status { margin-top: 6px; font-size: 14px; color: var(--gold); text-shadow: 0 1px 4px #000; }

.overlay {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: rgba(30, 15, 55, 0.62); backdrop-filter: blur(4px); z-index: 10;
}
.overlay.hidden { display: none; }
.panel {
  text-align: center; max-width: min(520px, 92vw); padding: 28px 26px;
  border-radius: 18px; background: rgba(45, 27, 78, 0.92);
  border: 2px solid var(--gold); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.panel h1 { font-size: clamp(28px, 7vw, 44px); color: var(--gold); letter-spacing: 1px; }
.panel.win h1 { color: var(--mint); }
.panel.lose h1 { color: var(--coral); }
.tag { margin: 8px 0 14px; color: #f3e6ff; font-size: 15px; }
.keys {
  text-align: left; display: grid; gap: 6px; font-size: 13.5px; color: #d9c8ff;
  background: rgba(0,0,0,0.25); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
}
.keys b { color: var(--gold); }
.big-btn {
  font: inherit; font-weight: 700; font-size: 18px; cursor: pointer;
  background: linear-gradient(180deg, #ffd166, #ff8a3d);
  color: #2d1b4e; border: none; border-radius: 999px; padding: 12px 38px;
  box-shadow: 0 6px 20px rgba(255, 138, 61, 0.45);
}
.big-btn:active { transform: translateY(2px); }
.link-home { display: block; margin-top: 14px; color: #cbb2ff; font-size: 13px; }

#touch-ui { position: fixed; inset: auto 0 0 0; z-index: 8; display: none; pointer-events: none; }
body.touch #touch-ui { display: flex; justify-content: space-between; align-items: flex-end; padding: 18px; }
#pad-joystick {
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(45, 27, 78, 0.45); border: 2px solid rgba(255, 209, 102, 0.5);
  position: relative; pointer-events: auto; touch-action: none;
}
#pad-knob {
  width: 52px; height: 52px; border-radius: 50%; position: absolute;
  left: 50%; top: 50%; margin: -26px 0 0 -26px;
  background: radial-gradient(circle at 35% 35%, #ffe29a, #ff8a3d);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
#touch-right { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: auto; }
#btn-jump {
  width: 92px; height: 92px; border-radius: 50%; font: inherit; font-weight: 800;
  font-size: 16px; color: #2d1b4e; border: 2px solid rgba(255,209,102,0.7);
  background: radial-gradient(circle at 35% 30%, #ffe29a, #ff7a4d);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4); touch-action: none;
}
#cam-btns { display: flex; gap: 10px; }
#btn-cam-left, #btn-cam-right {
  width: 58px; height: 58px; border-radius: 14px; font-size: 20px; color: #ffd166;
  background: rgba(45, 27, 78, 0.55); border: 2px solid rgba(255, 209, 102, 0.5);
  touch-action: none;
}
.pressed { filter: brightness(1.5); }
