/* 军哥卡丁车：safe-area-aware touch driving. Load after styles.css. */
.jg-touch-ui {
  --jg-touch-edge: 12px;
  --jg-pedal-size: clamp(60px, 9vw, 86px);
  --jg-action-size: clamp(48px, 6vw, 64px);
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
}
.jg-touch-ui [hidden] { display: none !important; }
.jg-race-toolbar {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: auto;
}
.jg-toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid #fff;
  border-radius: 13px;
  color: #133b56;
  background: rgba(248, 253, 255, .94);
  box-shadow: 0 3px 0 rgba(19, 59, 86, .4);
  font: 800 13px/1.2 var(--body, system-ui, sans-serif);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}
.jg-toolbar-button:hover { background: #d8f3ff; }
.jg-toolbar-button:focus-visible,
.jg-touch-button:focus-visible { outline: 3px solid #ffd568; outline-offset: 3px; }
.jg-toolbar-button:active { transform: translateY(2px); box-shadow: none; }
.jg-skip-intro {
  position: absolute;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  transform: translateX(-50%);
  min-width: 156px;
  min-height: 52px;
  border-color: #fff;
  background: #ff672b;
  color: #fff;
  box-shadow: 0 4px 0 #ba4723;
  font-size: 17px;
}
.jg-skip-intro:active { transform: translateX(-50%) translateY(2px); }
.jg-touch-driving { position: absolute; inset: 0; pointer-events: none; }
.jg-touch-steering,
.jg-touch-right {
  position: absolute;
  bottom: max(var(--jg-touch-edge), calc(env(safe-area-inset-bottom, 0px) + 8px));
  display: flex;
  gap: 10px;
  pointer-events: none;
}
.jg-touch-steering { left: max(var(--jg-touch-edge), calc(env(safe-area-inset-left, 0px) + 8px)); }
.jg-touch-right {
  right: max(var(--jg-touch-edge), calc(env(safe-area-inset-right, 0px) + 8px));
  flex-direction: column;
  align-items: flex-end;
}
.jg-touch-label {
  position: absolute;
  bottom: calc(100% + 8px);
  width: 100%;
  text-align: center;
  color: #fff;
  font: 800 12px/1.2 var(--body, system-ui, sans-serif);
  text-shadow: 0 2px 3px #133b56;
  pointer-events: none;
}
.jg-touch-actions,
.jg-touch-pedals { display: flex; align-items: center; gap: 8px; pointer-events: none; }
.jg-touch-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--jg-pedal-size);
  height: var(--jg-pedal-size);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, .95);
  border-radius: 23px;
  color: #133b56;
  background: rgba(216, 243, 255, .92);
  box-shadow: 0 4px 0 rgba(19, 59, 86, .65), inset 0 2px 0 #fff;
  text-shadow: none;
  font: 900 17px/1 var(--body, system-ui, sans-serif);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: background .08s, transform .08s;
}
.jg-touch-button[data-touch-action="left"],
.jg-touch-button[data-touch-action="right"] { font-size: 27px; }
.jg-touch-actions .jg-touch-button {
  width: var(--jg-action-size);
  height: var(--jg-action-size);
  border-radius: 17px;
  font-size: 13px;
  background: rgba(38, 157, 201, .94);
  color: #fff;
}
.jg-touch-button[data-touch-action="accelerate"] {
  color: #133b56;
  background: rgba(255, 213, 104, .96);
  border-color: #fff;
  box-shadow: 0 4px 0 #a97925, inset 0 2px 0 #fff5d6;
  text-shadow: none;
  font-size: 19px;
}
.jg-touch-button[data-touch-action="brake"] { background: rgba(248, 253, 255, .94); color: #133b56; }
.jg-touch-button[data-touch-action="drift"] { background: rgba(255, 103, 43, .96); box-shadow: 0 4px 0 #ba4723, inset 0 1px 0 #ffb685; }
.jg-touch-button[data-touch-action="item"] { background: rgba(38, 157, 201, .94); }
.jg-touch-button.is-held {
  background: #fff7da;
  color: #133b56;
  text-shadow: none;
  transform: translateY(3px) scale(.96);
  box-shadow: 0 1px 0 rgba(19, 59, 86, .55), 0 0 12px rgba(255, 213, 104, .3);
}
.jg-touch-hint {
  position: absolute;
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 15px));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 20px;
  color: #fff;
  background: rgba(19, 59, 86, .82);
  white-space: nowrap;
  font: 700 11px/1.2 var(--body, system-ui, sans-serif);
  pointer-events: none;
}
@media (max-width: 760px) {
  .jg-touch-hint { display: none; }
  .jg-toolbar-button { padding: 8px 9px; font-size: 12px; }
}
@media (orientation: portrait) {
  .jg-touch-ui { --jg-touch-edge: 10px; --jg-pedal-size: clamp(60px, 16vw, 86px); --jg-action-size: clamp(48px, 12vw, 64px); }
  .jg-touch-steering { gap: 8px; }
  .jg-touch-right { gap: 9px; }
  .jg-touch-hint { display: none; }
}
@media (orientation: landscape) and (max-height: 480px) {
  .jg-touch-ui { --jg-touch-edge: 9px; --jg-pedal-size: 58px; --jg-action-size: 44px; }
  .jg-touch-right { gap: 7px; }
  .jg-touch-button { border-radius: 18px; }
  .jg-touch-label { bottom: calc(100% + 5px); font-size: 10px; }
  .jg-touch-hint { display: none; }
  .jg-race-toolbar { gap: 5px; top: max(7px, env(safe-area-inset-top, 0px)); }
  .jg-toolbar-button { min-width: 44px; padding: 6px 9px; }
  .jg-skip-intro { bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px)); }
}
@media (prefers-reduced-motion: reduce) {
  .jg-touch-button { transition: none; }
}
