:root {
  color-scheme: dark;
  font-family: "Courier New", Courier, monospace;
  background: #10131a;
  color: #fff8db;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 15%, rgba(242, 202, 92, 0.16), transparent 26%),
    linear-gradient(180deg, #18202a 0%, #10131a 68%, #090b10 100%);
}

.shell {
  width: min(100vw, 1280px);
  padding: 16px;
}

.game-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 32px);
  margin: 0 auto;
  border: 4px solid #fff8db;
  background: #2f333b;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.48);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.hud {
  position: absolute;
  inset: 14px 72px auto 18px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  pointer-events: none;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

.hud div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.hud span {
  font-size: clamp(10px, 1.4vw, 15px);
  color: #f1e6bd;
}

.hud strong {
  overflow: hidden;
  font-size: clamp(14px, 2.35vw, 25px);
  letter-spacing: 0;
  color: #ffffff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  border: 3px solid #fff8db;
  background: #cf3e32;
  color: #fff8db;
  font: 700 18px/1 "Courier New", Courier, monospace;
  cursor: pointer;
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.24);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shop-toggle,
.shield-shop-toggle {
  position: absolute;
  top: 14px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 23px;
  z-index: 3;
}

.shop-toggle {
  right: 14px;
}

.shield-shop-toggle {
  right: 66px;
  background: #2f4f78;
}

.pause-toggle {
  position: absolute;
  top: 14px;
  right: 118px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  background: #344150;
  font-size: 18px;
}

.ability-panel {
  position: absolute;
  top: 72px;
  right: 14px;
  z-index: 3;
  display: grid;
  gap: 5px;
  width: 150px;
  padding: 10px;
  border: 3px solid #fff8db;
  background: rgba(20, 24, 32, 0.82);
  color: #fff8db;
  pointer-events: none;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
}

.ability-panel span {
  color: #f1e6bd;
  font-size: 11px;
}

.ability-panel strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 15px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ability-panel em {
  color: #ffd35a;
  font-size: 13px;
  font-style: normal;
}

.ability-meter {
  width: 100%;
  height: 10px;
  border: 2px solid #7b8491;
  background: #121720;
}

#abilityMeterFill {
  width: 100%;
  height: 100%;
  background: #ffd35a;
}

.shop {
  position: absolute;
  top: 154px;
  right: 14px;
  z-index: 4;
  width: min(330px, calc(100% - 28px));
  max-height: calc(100% - 174px);
  overflow-y: auto;
  padding: 14px;
  border: 4px solid #fff8db;
  background: rgba(20, 24, 32, 0.94);
  transform: translateX(calc(100% + 22px));
  transition: transform 160ms ease;
}

.shop.open {
  transform: translateX(0);
}

.shop.pause-hidden {
  display: none;
}

.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shop h2,
.shop p {
  margin: 0;
}

.shop h2 {
  font-size: 26px;
}

.shop-head button {
  width: 38px;
  height: 38px;
  padding: 0;
}

#shopBank {
  margin-top: 8px;
  color: #ffd35a;
  font-weight: 700;
}

.shop-section-title {
  margin: 16px 0 0 0;
  color: #ffffff;
  font-size: 17px;
}

.car-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.car-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  padding: 10px;
  border: 2px solid #7b8491;
  background: #252b34;
  cursor: pointer;
}

.car-card.active {
  border-color: #ffd35a;
}

.car-card:focus {
  outline: 2px solid #63f07b;
  outline-offset: 2px;
}

.car-card h3,
.car-card p {
  margin: 0;
}

.car-card h3 {
  color: #ffffff;
  font-size: 18px;
}

.car-card p {
  color: #d4dddf;
  font-size: 13px;
}

.car-card > button:not(.ability-info) {
  grid-row: span 2;
  align-self: center;
  min-width: 86px;
  min-height: 38px;
  font-size: 14px;
}

.ability-info {
  grid-column: 1 / -1;
  min-height: 34px;
  padding: 6px 8px;
  border-width: 2px;
  border: 2px solid #7b8491;
  background: #344150;
  color: #ffd35a;
  font-size: 13px;
  text-align: left;
}

.ability-details {
  grid-column: 1 / -1;
  padding: 8px;
  border-left: 3px solid #ffd35a;
  background: rgba(255, 211, 90, 0.08);
}

.car-details {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 8px;
  border-left: 3px solid #63f07b;
  background: rgba(99, 240, 123, 0.08);
}

.car-details strong {
  color: #ffffff;
  font-size: 13px;
}

.upgrade-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.upgrade-panel button {
  min-height: 34px;
  padding: 6px;
  font-size: 12px;
}

.message {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(13, 18, 28, 0.58);
}

.message.hidden {
  display: none;
}

.pause-menu {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 12, 18, 0.62);
}

.pause-menu.hidden,
.pause-panel.hidden {
  display: none;
}

.pause-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(620px, 100%);
  max-height: 92%;
  overflow-y: auto;
  padding: 18px;
  border: 4px solid #fff8db;
  background: rgba(20, 24, 32, 0.96);
}

.pause-head,
.pause-tabs,
.help-row,
.controls-grid,
.help-suggestions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pause-head {
  justify-content: space-between;
}

.pause-head h2,
.pause-panel p {
  margin: 0;
}

.pause-tabs {
  flex-wrap: wrap;
}

.controls-grid {
  flex-wrap: wrap;
}

.help-suggestions {
  flex-wrap: wrap;
}

.pause-tabs button,
.pause-panel button,
#resumeButton {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
}

.pause-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 2px solid #7b8491;
  background: #252b34;
}

.help-row input {
  min-width: 0;
  flex: 1;
  min-height: 38px;
  padding: 8px;
  border: 2px solid #7b8491;
  background: #111720;
  color: #fff8db;
  font: 700 14px/1.2 "Courier New", Courier, monospace;
}

.help-answer {
  min-height: 62px;
  padding: 10px;
  border: 2px solid #4d5968;
  border-left: 4px solid #ffd35a;
  background: #151a21;
  line-height: 1.4;
}

.account-list {
  display: grid;
  gap: 8px;
}

.account-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 2px solid #7b8491;
  background: #151a21;
}

.account-row strong {
  overflow: hidden;
  color: #ffffff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-row span {
  color: #ffd35a;
  font-size: 12px;
}

.account-row button {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

.account-confirm {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 10, 16, 0.76);
}

.account-confirm.hidden {
  display: none;
}

.account-confirm-box {
  display: grid;
  gap: 12px;
  width: min(390px, 100%);
  padding: 16px;
  border: 3px solid #fff8db;
  background: #151a21;
}

.account-confirm-box p {
  margin: 0;
  line-height: 1.35;
}

.message h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(34px, 8vw, 82px);
  color: #ffd35a;
  text-shadow: 4px 4px 0 #9b342c;
}

.message p {
  max-width: 680px;
  margin: 0 auto;
  font-size: clamp(14px, 2.3vw, 22px);
  line-height: 1.35;
}

#startButton {
  justify-self: center;
  min-width: 132px;
  min-height: 46px;
}

.touch-controls {
  position: absolute;
  inset: auto 14px 14px 14px;
  display: none;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.touch-controls div {
  display: flex;
  gap: 8px;
}

.touch-controls button {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  pointer-events: auto;
  opacity: 0.9;
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    border-width: 0;
    max-height: 100vh;
  }

  .hud {
    inset: 8px 62px auto 8px;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 12px;
  }

  .shop-toggle {
    top: 8px;
    right: 8px;
  }

  .shop {
    top: 62px;
    right: 8px;
  }
}
