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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #333;
  font: 300 14px/18px 'Segoe UI', Verdana, Arial, sans-serif;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The recovered game draws into a fixed-size canvas (1024x768 by default) that
   only changes size through the resolution selector - we do not stretch it to
   the window, so the projection stays identical to the target. */
#canvas {
  display: block;
  background: #72D7EE;
}

/* ---- settings panel ---- */
#controls {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 240px;
  border-collapse: collapse;
  background: rgba(0, 0, 0, 0.55);
  color: #e8e8e8;
  font-size: 12px;
  border-radius: 6px;
  overflow: hidden;
  z-index: 10;
}

#controls th,
#controls td {
  padding: 3px 6px;
  text-align: left;
  font-weight: normal;
}

#controls tr:first-child td {
  padding: 6px;
  text-align: center;
}

#controls a {
  color: #ffd23f;
}

#controls #fps {
  color: #7fd47f;
  text-align: right;
  font-family: Consolas, monospace;
  min-height: 16px;
}

#controls select,
#controls input {
  width: 100%;
  font-size: 11px;
}

/* ---- hud ---- */
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  color: #fff;
  font-size: 20px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

#hud .hud {
  display: block;
  margin-bottom: 2px;
}

#hud .value {
  color: #ffd23f;
  font-weight: bold;
  font-family: Consolas, monospace;
}

#hud .fastest .value {
  color: #7fd47f;
}

#last_lap_time {
  display: none;
}

#instructions {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 10;
}

#instructions b {
  color: #ffd23f;
}

/* ---- attribution (MIT) ---- */
#credit {
  position: fixed;
  bottom: 14px;
  left: 14px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  z-index: 10;
}

#credit a {
  color: rgba(255, 210, 63, 0.75);
  text-decoration: none;
}

#credit a:hover {
  text-decoration: underline;
}

/* ---- back-home link (s.1you.kr site tab) ---- */
#homeLink {
  position: fixed;
  bottom: 14px;
  right: 14px;
  z-index: 10;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
}

#mainHomeLink {
  position: fixed;
  bottom: 14px;
  right: 120px;
  z-index: 10;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
}

#mainHomeLink:hover,
#homeLink:hover {
  background: rgba(0, 0, 0, 0.78);
}

/* On phones the settings table is hidden behind a ⚙ toggle (touch.js). */
#settingsToggle {
  display: none;
}

body.touch-ui #settingsToggle {
  display: block;
  position: fixed;
  top: 12px;
  right: 12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 21px;
  line-height: 46px;
  text-align: center;
  border: 2px solid rgba(255, 255, 255, 0.35);
  z-index: 13;
}

body.touch-ui #controls {
  display: none;
}

body.touch-ui #controls.open {
  display: table;
}

/* ---- touch controls (mobile; #touchUI display is toggled by touch.js) ---- */
#touchUI {
  display: none;
}

#stickZone,
#stickBase,
#stickKnob,
#pedalGas,
#pedalBrake {
  border: 0;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

body.touch-ui #touchUI {
  display: block;
}

/* Shrink the fixed-size canvas (1024x768) down to fit phone screens.
   Canvas geometry/screen coordinates are unchanged - only its visual size. */
body.touch-ui #racer {
  max-width: 100vw;
  max-height: 100vh;
}

body.touch-ui #canvas {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
}

/* The keyboard hint bar would sit on top of the joystick - move it to the top
   and swap its text (touch.js rewrites the wording for touch devices). */
body.touch-ui #instructions {
  top: 62px;
  bottom: auto;
}

/* left: joystick */
#stickZone {
  position: fixed;
  left: 16px;
  bottom: 24px;
  width: 220px;
  height: 220px;
  z-index: 12;
}

#stickBase {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  height: 140px;
  margin: -70px 0 0 -70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

#stickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66px;
  height: 66px;
  margin: -33px 0 0 -33px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #9aa4ad);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

/* right: pedals (lifted so the homeLink stays tappable underneath) */
#pedals {
  position: fixed;
  right: 14px;
  bottom: 58px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  z-index: 12;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#pedalGas,
#pedalBrake {
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.5);
}

#pedalGas {
  width: 92px;
  height: 92px;
  font-size: 30px;
  background: rgba(22, 140, 60, 0.55);
}

#pedalBrake {
  width: 72px;
  height: 72px;
  font-size: 22px;
  margin-bottom: 10px;
  color: #fff;
  background: rgba(170, 40, 40, 0.55);
}

#pedalGas.pressed,
#pedalBrake.pressed {
  background: rgba(255, 210, 63, 0.85);
  color: #222;
}
