:root {
  --bg: #07060d;
  --teal: #3dffc5;
  --teal-dim: #1d8f74;
  --text: #e8f7f2;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Segoe UI", system-ui, sans-serif;
}

#app {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

#screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  outline: none;
}

/* ---------- Touch controls ---------- */
#touch-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  touch-action: none;
}
#touch-layer.active { display: block; }

.tc-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  pointer-events: auto;
}

.tc-stick-base {
  position: absolute;
  width: var(--stick, 132px);
  height: var(--stick, 132px);
  margin: calc(var(--stick, 132px) / -2) 0 0 calc(var(--stick, 132px) / -2);
  border-radius: 50%;
  border: 2px solid rgba(61, 255, 197, 0.45);
  background: radial-gradient(circle, rgba(61, 255, 197, 0.10) 0%, rgba(7, 6, 13, 0.35) 70%);
  box-shadow: 0 0 18px rgba(61, 255, 197, 0.25), inset 0 0 22px rgba(61, 255, 197, 0.12);
  opacity: var(--tc-opacity, 0.85);
  pointer-events: none;
  transition: opacity 0.2s;
}
.tc-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  margin: -23% 0 0 -23%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #b9ffe9 0%, #3dffc5 35%, #127a60 100%);
  box-shadow: 0 0 16px rgba(61, 255, 197, 0.8);
}

.tc-btn {
  position: absolute;
  border-radius: 50%;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  border: 2px solid rgba(61, 255, 197, 0.55);
  background: radial-gradient(circle at 50% 35%, rgba(61, 255, 197, 0.22) 0%, rgba(7, 6, 13, 0.55) 72%);
  box-shadow: 0 0 14px rgba(61, 255, 197, 0.25), inset 0 0 16px rgba(61, 255, 197, 0.15);
  opacity: var(--tc-opacity, 0.85);
  touch-action: none;
  transform: scale(1);
  transition: transform 0.06s, box-shadow 0.06s, background 0.06s;
}
.tc-btn svg { width: 54%; height: 54%; fill: none; stroke: #c9fff0; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(61,255,197,0.9)); }
.tc-btn.pressed {
  transform: scale(0.9);
  background: radial-gradient(circle at 50% 40%, rgba(61, 255, 197, 0.65) 0%, rgba(7, 6, 13, 0.55) 80%);
  box-shadow: 0 0 26px rgba(61, 255, 197, 0.85), inset 0 0 18px rgba(255, 255, 255, 0.35);
}
.tc-btn.cooldown { filter: grayscale(0.8) brightness(0.6); }
.tc-btn .tc-cd {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(0,0,0,0.6) var(--cd, 0%), transparent 0);
  pointer-events: none;
}
.tc-btn.small { font-size: 11px; }
.tc-btn.big { border-width: 3px; }
.tc-btn.jade { border-color: rgba(120, 255, 170, 0.6); }

.tc-pause {
  position: absolute;
  top: calc(10px + var(--safe-t));
  right: calc(12px + var(--safe-r));
  width: 44px;
  height: 44px;
  border-radius: 12px;
  pointer-events: auto;
  border: 2px solid rgba(61, 255, 197, 0.5);
  background: rgba(7, 6, 13, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: var(--tc-opacity, 0.85);
}
.tc-pause::before, .tc-pause::after {
  content: "";
  width: 6px;
  height: 18px;
  border-radius: 2px;
  background: #c9fff0;
  box-shadow: 0 0 6px rgba(61, 255, 197, 0.9);
}

/* ---------- Rotate hint (portrait phones) ---------- */
#rotate-hint {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(7, 6, 13, 0.96);
  z-index: 50;
  font-size: 18px;
  text-align: center;
  color: var(--teal);
  text-shadow: 0 0 10px rgba(61, 255, 197, 0.7);
}
#rotate-hint.show { display: flex; }
.rotate-icon {
  width: 70px;
  height: 110px;
  border: 4px solid var(--teal);
  border-radius: 14px;
  box-shadow: 0 0 18px rgba(61, 255, 197, 0.6);
  animation: rot 1.8s ease-in-out infinite;
}
@keyframes rot { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); } }

/* ---------- Boot / loading ---------- */
#boot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center, #10241f 0%, var(--bg) 70%);
  z-index: 40;
  transition: opacity 0.6s;
}
#boot.hide { opacity: 0; pointer-events: none; }
.boot-title {
  font-size: clamp(32px, 7vw, 72px);
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #0b0b12;
  -webkit-text-stroke: 2px var(--teal);
  text-shadow: 0 0 22px rgba(61, 255, 197, 0.8);
}
.boot-bar {
  width: min(60vw, 420px);
  height: 10px;
  border: 2px solid var(--teal-dim);
  border-radius: 6px;
  overflow: hidden;
  background: #050409;
}
#boot-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #127a60, var(--teal));
  box-shadow: 0 0 12px var(--teal);
  transition: width 0.15s;
}
#boot-text { font-size: 14px; opacity: 0.8; letter-spacing: 0.08em; }
