:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #101722; touch-action: none; user-select: none; }
button { font: inherit; }
#game { width: 100%; height: 100%; display: block; outline: none; }
.hud-top {
  position: fixed; z-index: 20; top: calc(10px + var(--safe-top)); left: calc(14px + var(--safe-left)); right: calc(14px + var(--safe-right));
  height: 38px; display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.brand { font-size: 13px; font-weight: 850; letter-spacing: .12em; text-shadow: 0 2px 8px #000; margin-right: auto; }
.brand span { opacity: .55; font-weight: 650; }
.state-badge { padding: 7px 10px; border: 1px solid rgba(255,255,255,.22); background: rgba(8,13,20,.65); backdrop-filter: blur(10px); border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.icon-btn { pointer-events: auto; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; color: #fff; background: rgba(8,13,20,.7); backdrop-filter: blur(10px); font-size: 18px; }
.loading-panel { position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(430px, calc(100vw - 40px)); padding: 22px; border: 1px solid rgba(255,255,255,.18); border-radius: 14px; background: rgba(10,15,23,.92); box-shadow: 0 24px 80px rgba(0,0,0,.5); backdrop-filter: blur(14px); }
.loading-panel.hidden { display: none; }
.loading-title { font-weight: 900; letter-spacing: .14em; font-size: 12px; margin-bottom: 12px; }
.loading-text { font-size: 15px; margin-bottom: 11px; }
.loading-details { min-height: 18px; margin-top: 9px; font-size: 11px; color: rgba(255,255,255,.58); line-height: 1.4; }
.progress { height: 5px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.1); }
.progress > div { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#6de4ff,#92ffbf); transition: width .18s ease; }
.settings-panel { position: fixed; z-index: 45; top: calc(58px + var(--safe-top)); right: calc(14px + var(--safe-right)); width: min(330px, calc(100vw - 28px)); padding: 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; background: rgba(8,13,20,.91); box-shadow: 0 18px 60px rgba(0,0,0,.45); backdrop-filter: blur(14px); transform: translateX(calc(100% + 30px)); transition: transform .22s ease; pointer-events: auto; }
.settings-panel.open { transform: translateX(0); }
.settings-panel h2 { margin: 0 0 12px; font-size: 16px; }
.diagnostics { padding: 10px; margin-bottom: 12px; border-radius: 8px; background: rgba(255,255,255,.06); font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.file-btn { display: block; width: 100%; padding: 10px 12px; margin-top: 8px; border: 1px solid rgba(109,228,255,.4); border-radius: 8px; background: rgba(109,228,255,.09); color: #eaffff; text-align: center; cursor: pointer; font-weight: 750; font-size: 12px; }
.file-btn.secondary { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.06); }
.file-btn.danger { border-color: rgba(255,120,120,.35); background: rgba(255,80,80,.08); }
.small-note { margin: 12px 0 0; color: rgba(255,255,255,.55); font-size: 10px; line-height: 1.45; }

.control-settings { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.control-settings h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .04em; color: rgba(255,255,255,.86); }
.toggle-row, .range-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; font-size: 11px; color: rgba(255,255,255,.72); }
.toggle-row input { width: 18px; height: 18px; accent-color: #78dfff; flex: 0 0 auto; }
.range-row { min-height: 28px; }
.range-row strong { color: #bcefff; font-size: 11px; }
.range-input { width: 100%; accent-color: #78dfff; }
.joystick { position: fixed; z-index: 30; left: calc(34px + var(--safe-left)); bottom: calc(26px + var(--safe-bottom)); width: 132px; height: 132px; touch-action: none; }
.joystick-ring { position: absolute; inset: 0; border: 2px solid rgba(255,255,255,.24); border-radius: 50%; background: radial-gradient(circle,rgba(255,255,255,.09),rgba(5,10,16,.18)); box-shadow: inset 0 0 24px rgba(0,0,0,.22), 0 8px 30px rgba(0,0,0,.25); }
.joystick-ring::before, .joystick-ring::after { content:""; position:absolute; background:rgba(255,255,255,.13); }
.joystick-ring::before { left: 50%; top: 15%; bottom: 15%; width: 1px; }
.joystick-ring::after { top: 50%; left: 15%; right: 15%; height: 1px; }
.joystick-stick { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; transform: translate(-50%,-50%); border: 1px solid rgba(255,255,255,.5); border-radius: 50%; background: rgba(210,244,255,.28); box-shadow: 0 8px 20px rgba(0,0,0,.35), inset 0 0 16px rgba(255,255,255,.16); }
.action-buttons { position: fixed; z-index: 30; right: calc(30px + var(--safe-right)); bottom: calc(24px + var(--safe-bottom)); display: flex; align-items: flex-end; gap: 16px; }
.action-btn { width: 78px; height: 78px; border: 1px solid rgba(255,255,255,.38); border-radius: 50%; color: #fff; background: rgba(18,28,40,.55); box-shadow: 0 8px 28px rgba(0,0,0,.32), inset 0 0 18px rgba(255,255,255,.08); backdrop-filter: blur(8px); font-weight: 900; font-size: 12px; letter-spacing: .05em; touch-action: none; }
.action-btn small { display: block; margin-top: 2px; font-size: 8px; opacity: .55; }
.action-btn.pressed { transform: scale(.92); background: rgba(109,228,255,.28); }
.jump-btn { width: 92px; height: 92px; background: rgba(104,162,255,.2); }
.crosshair { position: fixed; z-index: 10; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255,255,255,.5); box-shadow: 0 0 8px rgba(255,255,255,.4); pointer-events: none; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translate(-50%,30px); padding: 9px 13px; border-radius: 8px; background: rgba(8,13,20,.88); border: 1px solid rgba(255,255,255,.16); opacity: 0; transition: .2s ease; font-size: 12px; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.orientation-hint { display: none; position: fixed; z-index: 100; inset: 0; background: #0d1520; align-items: center; justify-content: center; flex-direction: column; gap: 10px; text-align: center; padding: 28px; }
.orientation-hint .phone-icon { font-size: 48px; }
.orientation-hint span { max-width: 310px; opacity: .6; font-size: 13px; }
@media (orientation: portrait) and (max-width: 900px) { .orientation-hint { display: flex; } }
@media (pointer: fine) { .joystick, .action-buttons { opacity: .72; } }
@media (max-height: 430px) {
  .joystick { width: 112px; height: 112px; left: calc(20px + var(--safe-left)); bottom: calc(14px + var(--safe-bottom)); }
  .joystick-stick { width: 50px; height: 50px; }
  .action-buttons { right: calc(20px + var(--safe-right)); bottom: calc(13px + var(--safe-bottom)); gap: 12px; }
  .action-btn { width: 66px; height: 66px; }
  .jump-btn { width: 78px; height: 78px; }
}
