
/****************************************/
/* common styles used for v1 through v4 */
/****************************************/

body          { font-family: Arial, Helvetica, sans-serif; background-color: black; color: white; }
a { color: magenta; }
#stats        { border: 2px solid lime; }
#controls     { width: 28em; float: left; padding: 1em; font-size: 0.7em; }
#controls th  { text-align: right; vertical-align: middle; }
#instructions { clear: left; float: left; width: 17em; padding: 1em; border: 1px solid black; box-shadow: 0 0 5px lime; }
#racer        { position: relative; z-index: 0; width: 640px; height: 480px; margin-left: 20em; border: 2px solid magenta; }
#canvas       { position: absolute; z-index: 0; width: 640px; height: 480px; z-index: 0; background-color: black; /* default color when drawing out of bounds (eg, we are up a high hill and the background is too low)*/ }

/**************************************************/
/* rudimentary heads up display (only used in v4) */
/**************************************************/

#hud                   { position: absolute; z-index: 1; width: 640px; padding: 5px 0; font-family: Verdana, Geneva, sans-serif; font-size: 0.8em; background-color: rgba(255,0,0,0.4); color: black; border-bottom: 2px solid black; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; }
#hud .hud              { background-color: rgba(255,255,255,0.6); padding: 5px; border: 1px solid black; margin: 0 5px; transition-property: background-color; transition-duration: 2s; -webkit-transition-property: background-color; -webkit-transition-duration: 2s; }
#hud #speed            { float: right; }
#hud #current_lap_time, #hud #current_level, #hud #turbo_left { float: left;  }
#hud #last_lap_time    { float: left; display: none;  }
#hud #fast_lap_time, #hud #remaining_time    { display: block; width: 12em;  margin: 0 auto; text-align: center; transition-property: background-color; transition-duration: 2s; -webkit-transition-property: background-color; -webkit-transition-duration: 2s; }
#hud .value            { color: black; font-weight: bold; }
#hud .fastest          { background-color: rgba(255,215,0,0.5); }
#hud .magenta       { background-color: magenta; }

@keyframes anim-heartbeat {
    0%   {font-size: 175%;}
    25%  {font-size: 150%;}
    50%  {font-size: 125%;}
    100% {font-size: 100%;}
}

.warninglow {
    color: red;
    font-weight: bold;
    animation-name: anim-heartbeat;
    animation-duration: 5s;
    animation-iteration-count: infinite;
}

/* Fullscreen mode (on double click, managed in JS */
#canvas:fullscreen {
	width: auto;
    height: 100%; /* height is smaller than width, so resize by height and adapt width automatically */
}
#canvas:-webkit-full-screen {
	width: auto;
    height: 100%;
}

#canvas:-moz-full-screen {
	width: auto;
    height: 100%;
}

#canvas:-ms-fullscreen {
    width: auto;
    height: auto;
    margin: auto;
}

/* Mobile gamepad */
#gamepad {
    clear: left; width: 17em; border: 1px solid black; box-shadow: 0 0 5px lime;
    margin-left: 20em;
    width: 640px;
    height: 300px;
    background: rgba(255,0,0,0.4);
    position: relative;
    text-align: center;
    display: inline-block;
}
.gamepad-button {
    background: grey;
    width: 33%;
    height: 50%;
    display: block;
    float: left;

    /* Disable selection of text for gamepad buttons (so that user can press without selecting the text) */
   -moz-user-select: none;
   -khtml-user-select: none;
   -webkit-user-select: none;
   /*
     Introduced in IE 10.
     See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
   */
   -ms-user-select: none;
   user-select: none;
}
.gamepad-button span {
    display: inline-block;
    vertical-align: middle;
}
.gamepad-button:active { background: blue; }
#gamepad-turbo { }
#gamepad-up { }
#gamepad-left { clear: both; }
#gamepad-right { float: right; }
#gamepad-down { }
*/


*{box-sizing:border-box}body{margin:0;background:#090313;font:14px system-ui;color:#e4dbff}header{padding:9px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}header span{width:100%;font-size:12px;color:#b7a6ca}button,select,summary{min-height:34px;padding:6px;background:#190e30;color:#fff;border:1px solid #ef4ebf}a{color:#96ffcc}details{margin:0 9px 6px}#controls{float:none;width:100%;max-width:480px;padding:5px}#instructions{float:none;clear:none;width:auto;padding:4px 9px;box-shadow:none}#instructions p{display:inline;margin-right:8px;font-size:12px}#racer{margin:8px auto;max-width:calc(100vw - 16px);width:min(800px,calc((100vh - 260px)*1.3333));height:auto;aspect-ratio:4/3;overflow:hidden}#canvas{width:100%;height:100%;position:absolute}#hud{width:100%;font-size:clamp(9px,2.2vw,12px);display:flex;flex-wrap:wrap;gap:3px;background:#130027bc;color:white}#hud .hud{margin:0;padding:3px;background:#eee9ffcb}#hud #remaining_time{width:auto}#gamepad{display:flex;margin:4px auto;width:min(800px,calc(100vw - 16px));height:auto;gap:5px;background:none;box-shadow:none}#gamepad .gamepad-button{float:none;width:20%;height:40px;touch-action:none;background:#25113f;color:white}#gamepad .gamepad-button:active{background:#6b2161}:focus-visible{outline:3px solid #aaff55;outline-offset:-3px}@media(max-width:500px){#racer{width:calc(100vw - 16px)}header{font-size:12px}#controls{font-size:11px}}@media(max-height:520px){header{padding:4px;gap:4px}header strong,#instructions{display:none}details{font-size:11px;margin-bottom:2px}summary{min-height:24px;padding:3px}#racer{width:min(calc(100vw - 16px),calc((100vh - 130px)*1.3333));margin:3px auto}#gamepad .gamepad-button{height:30px;font-size:10px;padding:2px}}@media(prefers-reduced-motion:reduce){.warninglow{animation:none}#hud .hud{transition:none}}
