@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&display=swap');

:root {
  --face: #1b0f30;
  --ink: #2a0e4a;          /* garis tepi teks supaya terbaca di atas gambar */
  --pink: #ff6fc4;
  --pink-hot: #ff3d9a;
  --lilac: #ecc4ff;
  --steel: #8b8797;
  --teal: #35e0c0;
  --orange: #ff8f3d;
  --red: #ff3d4f;
  --amber: #ffb020;
  --green: #5cf0b0;
  --font: 'Fredoka', 'Nunito', 'Arial Rounded MT Bold', 'Trebuchet MS', Arial, sans-serif;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-drag: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: transparent !important;
  color: #eee;
  font-family: var(--font);
}

/* Speedo bulat - transparan, di pojok kanan bawah */
#cockpit {
  position: fixed;
  right: 25px;
  bottom: 25px;
  width: 240px;
  height: 280px;
  background: none;
  border: none;
  box-shadow: none;
  transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--scale, 1));
  transform-origin: right bottom;
}
#cockpit.mode-move { cursor: move; }
#cockpit.mode-resize { cursor: ns-resize; }

/* ============ Badan speedo (SVG) ============ */
.gauge-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.55));
}

.ear-outer {
  fill: url(#earOuterGrad);
  stroke: var(--steel);
  stroke-width: 7;
  stroke-linejoin: round;
}
.ear-inner {
  fill: url(#earInnerGrad);
  stroke: #a77bd0;
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.bezel-edge {
  fill: none;
  stroke: #2f2a3b;
  stroke-width: 1;
}
.bezel {
  fill: none;
  stroke: url(#bezelGrad);
  stroke-width: 7;
}
.face { fill: var(--face); }
.anime { filter: brightness(0.74) saturate(1.2) contrast(1.05); }
.face-rim {
  fill: none;
  stroke: rgba(236, 196, 255, 0.28);
  stroke-width: 1;
}

.rpm-bg {
  fill: none;
  stroke: rgba(18, 8, 31, 0.85);
  stroke-width: 5;
  stroke-linecap: butt;
}
.rpm-active {
  fill: none;
  stroke: url(#rpmGrad);
  stroke-width: 5;
  stroke-linecap: butt;
  stroke-dasharray: 290.3;
  stroke-dashoffset: 290.3;
  filter: drop-shadow(0 0 3px rgba(255, 130, 70, 0.7));
  transition: stroke-dashoffset 0.08s linear;
}

.tick {
  stroke: var(--lilac);
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0.8;
}
.tick.major { stroke-width: 2; opacity: 1; }
.tick.hot { stroke: var(--pink-hot); }
.tick-text {
  fill: var(--lilac);
  stroke: var(--ink);
  stroke-width: 2.6px;
  stroke-linejoin: round;
  paint-order: stroke fill;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
}
.tick-text.hot { fill: #ff8fcb; }

/* Jarum speed: digambar menghadap kanan, diputar oleh script.js */
#needle {
  transform: rotate(135deg);
  transition: transform 0.18s ease-out;
}
.needle-body {
  stroke: var(--pink-hot);
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(255, 61, 154, 0.9));
}
.needle-core {
  stroke: #ffd3ee;
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* ============ Lapisan HUD ============ */
.panel-center {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.panel-center > *,
.icon-row > * {
  position: absolute;
  transform: translate(-50%, -50%);
}

/* ---- Ikon status ---- */
.status-icon {
  width: 17px;
  height: 17px;
  color: var(--lilac);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, opacity 0.15s ease;
}
.status-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(20, 5, 40, 0.95));
}
.status-icon.on {
  color: #fff;
  opacity: 1;
}
.status-icon.active {
  color: var(--green);
  opacity: 1;
}
.status-icon.danger {
  color: var(--red);
  opacity: 1;
  animation: pulse 0.9s infinite alternate;
}
.status-icon.hazard {
  color: var(--amber);
  opacity: 1;
  animation: blink 0.7s infinite alternate;
}
.belt-icon.danger { animation: pulse 0.9s infinite alternate; }

#iconLight  { left: 93px;  top: 124px; }
#warningBox { left: 120px; top: 122px; }
#iconEngine { left: 147px; top: 124px; }
#iconSignalL { left: 82px;  top: 147px; }
#iconSignalR { left: 158px; top: 147px; }
.signal-icon { width: 15px; height: 15px; }

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.4; }
}
@keyframes blink {
  from { opacity: 1; }
  to { opacity: 0.25; }
}

/* ---- Gear ---- */
.gear-wrap {
  left: 120px;
  top: 147px;
  transition: opacity 0.35s ease;
}
.gear-val {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  border: 2.5px solid var(--steel);
  background: var(--face);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: #ff9ad5;
  box-shadow: 0 0 8px rgba(255, 111, 196, 0.25);
}
.gear-wrap::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 3px);
  width: 14px;
  height: 7px;
  transform: translateX(-50%);
  background: var(--pink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 0 3px rgba(255, 111, 196, 0.7));
}

/* ---- Speed ---- */
.speed-wrap {
  left: 120px;
  top: 192px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  transition: opacity 0.35s ease;
}
.speed-val {
  font-size: 40px;
  font-weight: 700;
  color: var(--pink);
  /* garis tepi gelap di sekeliling angka */
  text-shadow:
    2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink),
    1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink),
    1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink),
    0 0 12px rgba(255, 111, 196, 0.55);
}
.speed-unit {
  margin-top: 1px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: lowercase;
  color: var(--lilac);
  text-shadow:
    1.5px 0 0 var(--ink), -1.5px 0 0 var(--ink), 0 1.5px 0 var(--ink), 0 -1.5px 0 var(--ink);
}

/* ---- Bar fuel & health ---- */
.status-bars {
  left: 120px;
  top: 226px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  transition: opacity 0.35s ease;
}
.bar-icon {
  width: 11px;
  height: 11px;
  margin-top: -3px;
  flex: none;
}
.bar-icon svg {
  width: 100%;
  height: 100%;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 2px rgba(20, 5, 40, 0.95));
}
.fuel-icon svg   { fill: var(--teal); stroke: var(--ink); stroke-width: 1.4; }
.health-icon svg { fill: var(--pink-hot); stroke: var(--ink); stroke-width: 1.4; }

.bar-col {
  width: 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.bar-text {
  font-size: 7.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--lilac);
  text-shadow: 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 1px 0 var(--ink), 0 -1px 0 var(--ink);
}

.fuel-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(18, 8, 31, 0.85);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(236, 196, 255, 0.2);
}
.fuel-bar-fill {
  width: 100%;
  height: 100%;
  background: var(--teal);
  box-shadow: 0 0 6px rgba(53, 224, 192, 0.6);
  transition: width 0.2s ease, background 0.2s ease;
}
.fuel-bar-fill.critical {
  background: var(--red);
  box-shadow: 0 0 6px rgba(255, 61, 79, 0.65);
}

.health-bar {
  width: 100%;
  height: 6px;
  display: block;
  overflow: hidden;
  border-radius: 3px;
}
.hb-bg {
  fill: none;
  stroke: rgba(18, 8, 31, 0.85);
  stroke-width: 6;
}
.hb-active {
  fill: none;
  stroke: var(--pink-hot);
  stroke-width: 6;
  stroke-linecap: butt;
  stroke-dasharray: 110;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 2px rgba(255, 61, 154, 0.7));
  transition: stroke-dashoffset 0.2s ease, stroke 0.2s ease;
}
.hb-active.critical {
  stroke: var(--red);
  animation: pulse 0.9s infinite alternate;
}

/* ---- Jam di pil bawah ---- */
.clock-badge {
  left: 120px;
  top: 273px;
  min-width: 58px;
  height: 19px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 2.5px solid var(--steel);
  background: #2a1650;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.clock-val {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.5px;
  color: var(--lilac);
}

.template-fallback { display: none !important; }

/* ============ Menu Setting (di atas speedo) ============ */
.settings-menu {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 6px;
  transform: translateX(-50%) scale(calc(1 / var(--scale, 1)));
  transform-origin: 50% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px;
  background: rgba(27, 15, 48, 0.88);
  border: 1px solid rgba(236, 196, 255, 0.25);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  cursor: default;
  z-index: 10;
}
.settings-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.settings-items {
  display: flex;
  gap: 4px;
}
.settings-items button {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--lilac);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(236, 196, 255, 0.2);
  border-radius: 6px;
  padding: 3px 11px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.settings-items button:hover {
  color: #fff;
  background: rgba(255, 111, 196, 0.25);
}
.settings-items button:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 1px;
}
.settings-items button.active {
  color: var(--pink);
  border-color: rgba(255, 111, 196, 0.7);
  background: rgba(255, 111, 196, 0.15);
}
.settings-hint {
  display: none;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  color: #ff9ad5;
  white-space: nowrap;
}
.settings-hint.show { display: block; }

@media (prefers-reduced-motion: reduce) {
  .status-icon.danger, .status-icon.hazard, .belt-icon.danger, .hb-active.critical { animation: none; }
}

/* wrapper ikon: tidak ikut digeser, hanya jadi acuan koordinat */
.panel-center > .icon-row {
  inset: 0;
  transform: none;
}
