html, body { margin: 0; background: #fff; }
.tug-game, .tug-game *, .tug-game *::before, .tug-game *::after { box-sizing: border-box; }
.tug-game {
    --mia-blue: #009cdd;
    width: 100%; max-width: 960px; margin: 0 auto;
    color: #000; background: #fff; border: 2px solid #000;
    font: 12px/1.45 Manrope, 'Avenir Next', 'Segoe UI', sans-serif;
}
.tug-game h2, .tug-game p { margin: 0; }
.tug-game h2 { font: 700 11px/1.4 Sora, 'Avenir Next', sans-serif; }
.tug-game button {
    border: 1px solid #000; border-radius: 4px; color: #000; background: #fff;
    font: 700 11px/1.2 Manrope, sans-serif; padding: 7px 10px; cursor: pointer;
}
.tug-game button:hover, .tug-game button[aria-pressed="true"], .tug-game .tug-primary { background: var(--mia-blue); }
.tug-game button:disabled { opacity: .5; cursor: default; }
.tug-game :focus-visible { outline: 3px solid #000; outline-offset: 3px; }
.tug-game [hidden] { display: none !important; }
.tug-toolbar, .tug-toolbar-actions, .tug-panel-heading, .tug-slider-label, .tug-challenge-summary, .tug-challenge-status {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.tug-toolbar { min-height: 48px; padding: 8px 12px; border-bottom: 2px solid #000; }
.tug-toolbar > strong { font: 700 12px Sora, sans-serif; white-space: nowrap; }
.tug-toolbar > strong span { font: 600 10px Manrope, sans-serif; margin-left: 8px; letter-spacing: .06em; }
.tug-toolbar-actions { justify-content: flex-end; }
.tug-game-area { position: relative; }
#gameCanvas { display: block; width: 100%; aspect-ratio: 4 / 3; background: var(--mia-blue); }
#gameCanvas:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }
.tug-mobile-hud-panel { display: contents; }
.tug-ship-control, .tug-hud { position: absolute; top: 12px; padding: 10px; border: 2px solid #000; border-radius: 4px; background: #fff; }
.tug-ship-control { left: 12px; width: 194px; }
.tug-hud { right: 12px; width: 184px; }
.tug-panel-heading { margin-bottom: 8px; }
.tug-panel-heading button { padding: 5px 8px; }
.tug-slider-label { margin: 9px 0 5px; font-size: 10px; }
.tug-slider-label strong { font-size: 10px; }
#shipSpeedSlider { accent-color: var(--mia-blue); width: 100%; margin: 0; min-height: 22px; }
.tug-toggle-row { display: flex; gap: 5px; }
.tug-toggle-row button { flex: 1; }
.tug-force-type { display: inline-block; padding: 3px 6px; margin-bottom: 8px; background: #000; color: #fff; font-size: 9px; font-weight: 700; }
.tug-hud h2 { font: 400 9px Manrope, sans-serif; text-transform: uppercase; }
.tug-bp-display { display: block; font: 700 25px/1.5 Sora, sans-serif; }
.tug-bar { height: 5px; overflow: hidden; background: #dedede; }
.tug-bar > div { height: 100%; width: 0; background: var(--mia-blue); }
.tug-response-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tug-response-grid span { display: block; font-size: 9px; }
.tug-response-grid strong { display: block; font: 700 13px/1.5 Sora, sans-serif; font-variant-numeric: tabular-nums; }
.tug-challenge { padding: 12px 14px; border-top: 2px solid #000; }
.tug-challenge-summary > div { flex: 1; }
.tug-challenge-summary p { font-size: 11px; margin-top: 3px; }
.tug-challenge-status { margin: 10px 0 4px; font-size: 11px; font-variant-numeric: tabular-nums; }
#challengeInstruction { margin-bottom: 9px; }
.tug-controls { padding: 10px 14px; border-top: 1px solid #000; }
.tug-controls .tug-panel-heading { margin-bottom: 0; }
#desktopControlDiagram { margin-top: 8px; }
#playInstructions { font-size: 11px; }
#playInstructions span { margin: 0 8px; }
.tug-explanation { margin-top: 8px !important; }
.tug-model-note { margin-top: 5px !important; font-size: 10px; color: #444; }
.tug-touch-controls, #mobileHudToggle, .tug-touch-help { display: none; }
.tug-pause-overlay { position: absolute; inset: 0; z-index: 5; background: rgb(255 255 255 / .86); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.tug-pause-overlay strong { font: 700 22px Sora, sans-serif; }
#towModeModal { top: 24px; bottom: auto; margin: 0 auto; max-height: calc(100dvh - 48px); width: min(420px, calc(100% - 32px)); padding: 26px; border: 2px solid #000; border-radius: 4px; font: inherit; color: #000; background: #fff; }
#towModeModal::backdrop { background: rgb(255 255 255 / .88); }
#towModeModal h2 { font-size: 21px; margin-bottom: 12px; }
#towModeModal p { margin-bottom: 18px; }
#towModeModal .tug-primary { width: 100%; min-height: 44px; }
#towModeModal .tug-modal-label { margin: 18px 0 10px; font-size: 11px; }
#towModeModal .tug-toggle-row button { padding: 12px 6px; }
#towModeModal button span { display: block; margin-top: 5px; font-size: 10px; font-weight: 400; }
.tug-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px !important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tug-game:fullscreen { width: 100%; height: 100%; max-width: none; overflow: auto; }
.tug-game:fullscreen .tug-game-area { max-width: min(960px, calc((100dvh - 180px) * 4 / 3)); margin: auto; }
@media (max-width: 640px), (pointer: coarse) {
    .tug-touch-controls { position: absolute; bottom: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
    .tug-touch-joystick-area, .tug-touch-rotate-area { display: flex; flex-direction: column; align-items: center; gap: 3px; }
    .tug-touch-controls span { font-size: 9px; font-weight: 700; text-transform: uppercase; background: #fff; padding: 1px 4px; }
    .tug-touch-joystick-base { width: 84px; height: 84px; border: 2px solid #000; border-radius: 50%; background: rgb(255 255 255 / .8); position: relative; pointer-events: auto; touch-action: none; user-select: none; }
    #joystickKnob { position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid #000; background: var(--mia-blue); pointer-events: none; }
    .tug-touch-rotate-area > div { display: flex; gap: 7px; }
    .tug-touch-rotate-area button { width: 48px; height: 48px; font-size: 26px; background: rgb(255 255 255 / .85); border: 2px solid #000; pointer-events: auto; touch-action: none; user-select: none; }
    .tug-touch-rotate-area button.is-active { background: var(--mia-blue); }
    .tug-touch-help { display: block; }
}
@media (max-width: 640px) {
    .tug-toolbar { padding: 6px 8px; gap: 5px; }
    .tug-toolbar > strong span { display: none; }
    .tug-toolbar-actions { gap: 5px; }
    .tug-toolbar-actions button { font-size: 10px; padding: 8px 6px; min-height: 36px; }
    #mobileHudToggle { display: inline-block; }
    .tug-game-area { display: grid; grid-template-columns: minmax(0, 1fr); }
    #gameCanvas { grid-area: 1 / 1; }
    .tug-mobile-hud-panel { display: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-top: 2px solid #000; }
    .tug-game.is-mobile-hud-open .tug-mobile-hud-panel { display: grid; }
    .tug-ship-control, .tug-hud { position: static; width: auto; min-width: 0; border: 0; border-radius: 0; padding: 8px; }
    .tug-ship-control { border-right: 1px solid #000; }
    .tug-hud h2 { font-size: 8px; }
    .tug-hud .tug-bp-display { font-size: 20px; }
    .tug-response-grid { gap: 5px; }
    .tug-response-grid span { font-size: 8px; }
    .tug-response-grid strong { font-size: 11px; }
    .tug-panel-heading { flex-wrap: wrap; }
    .tug-touch-controls { position: relative; grid-area: 1 / 1; bottom: auto; left: auto; right: auto; align-self: end; margin: 0 9px 9px; }
    .tug-pause-overlay { grid-area: 1 / 1; position: relative; }
    .tug-challenge { padding: 9px 10px; }
    .tug-challenge-summary { flex-wrap: wrap; }
    .tug-challenge-summary p { font-size: 10px; }
    .tug-challenge-status, #challengeInstruction { font-size: 10px; }
    .tug-controls { padding: 9px 10px; }
    #playInstructions { display: none; }
    .tug-explanation { font-size: 11px; }
    .tug-model-note { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
    .tug-game *, .tug-game *::before, .tug-game *::after { scroll-behavior: auto; transition: none; animation: none; }
}
