:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #111614;
  color: #f6f1e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  background: #17251f;
}

.game-shell {
  position: relative;
  width: min(100vw, 1440px);
  height: min(100vh, 900px);
  display: grid;
  place-items: center;
  padding: 12px;
}

canvas {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 24px);
  aspect-ratio: 16 / 9;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #8fd4f0;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

.home-screen {
  position: absolute;
  inset: 12px;
  z-index: 30;
  display: grid;
  grid-template-rows: minmax(112px, 0.8fr) auto 1fr;
  justify-items: center;
  padding: 36px 24px;
  overflow-y: auto;
  background: rgba(8, 17, 13, 0.86);
  border: 4px solid #d9c887;
  box-shadow: inset 0 0 0 4px #315d43;
}

.home-screen[hidden],
.menu-button[hidden],
.home-achievements[hidden],
.home-stats[hidden],
.home-loadout[hidden] {
  display: none;
}

.home-screen__logo {
  align-self: start;
  margin: 0;
  line-height: 0;
}

.home-screen__logo img {
  width: min(260px, 55vw);
  max-height: 34vh;
  object-fit: contain;
  image-rendering: pixelated;
}

.home-screen__menu {
  grid-row: 2;
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
}

.home-screen__button {
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  border: 3px solid #d9c887;
  border-radius: 0;
  background: #123c27;
  color: #f1e8bd;
  cursor: pointer;
  font: 800 17px/1 "Courier New", monospace;
  letter-spacing: 0;
  text-transform: uppercase;
  box-shadow:
    inset 0 0 0 2px #638267,
    5px 5px 0 rgba(4, 12, 8, 0.7);
}

.home-screen__button:hover,
.home-screen__button:focus-visible {
  background: #315d43;
  color: #ffffff;
  outline: 3px solid #f2c84b;
  outline-offset: 3px;
}

.home-screen__button:disabled {
  cursor: default;
  opacity: 0.62;
}

.home-loadout {
  position: absolute;
  inset: 12px;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 17, 13, 0.94);
}

.home-stats {
  position: absolute;
  inset: 12px;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 17, 13, 0.94);
}

.home-achievements {
  position: absolute;
  inset: 12px;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 17, 13, 0.94);
}

.home-achievements__panel,
.home-stats__panel {
  width: min(780px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px;
  border: 3px solid #d9c887;
  background: #1c2722;
  box-shadow: inset 0 0 0 2px #315d43;
}

.home-achievements__header,
.home-stats__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.home-achievements__header h2,
.home-stats__header h2 {
  margin: 0;
  color: #f2c84b;
  font: 800 26px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.home-achievements__header button,
.home-stats__header button {
  min-width: 86px;
  min-height: 44px;
  border: 2px solid #d9c887;
  border-radius: 0;
  background: #123c27;
  color: #f1e8bd;
  cursor: pointer;
  font: 800 14px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.achievements-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.achievement-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 11px;
  border: 1px solid rgba(217, 200, 135, 0.38);
  background: rgba(8, 17, 13, 0.42);
  color: #f1e8bd;
  font: 800 13px/1.25 "Courier New", monospace;
}

.achievement-item[data-unlocked="false"] {
  opacity: 0.62;
  filter: saturate(0.45);
}

.achievement-item__details {
  display: grid;
  gap: 4px;
}

.achievement-item__details strong {
  color: #f2c84b;
  text-transform: uppercase;
}

.achievement-item__details span {
  color: #d7cfad;
}

.achievement-item__status {
  min-width: 86px;
  padding: 7px 9px;
  border: 1px solid rgba(217, 200, 135, 0.5);
  color: #f2c84b;
  text-align: center;
  text-transform: uppercase;
}

.achievement-item[data-unlocked="false"] .achievement-item__status {
  color: #b9c0b8;
}

.game-stats-list {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(180px, 1.1fr);
  gap: 8px 14px;
  margin: 0;
}

.game-stats-list dt,
.game-stats-list dd {
  min-height: 34px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgba(217, 200, 135, 0.38);
  background: rgba(8, 17, 13, 0.42);
  color: #f1e8bd;
  font: 800 13px/1.25 "Courier New", monospace;
}

.game-stats-list dt {
  color: #f2c84b;
  text-transform: uppercase;
}

.home-loadout__panel {
  width: min(720px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px;
  border: 3px solid #d9c887;
  background: #1c2722;
  box-shadow: inset 0 0 0 2px #315d43;
}

.home-loadout__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.home-loadout__header h2 {
  margin: 0;
  color: #f2c84b;
  font: 800 26px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.now-playing {
  position: absolute;
  left: 36px;
  bottom: 34px;
  z-index: 40;
  width: min(390px, calc(100% - 72px));
  min-height: 58px;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: stretch;
  border: 2px solid #d9c887;
  background: rgba(12, 26, 20, 0.94);
  box-shadow: 4px 4px 0 rgba(4, 12, 8, 0.58);
}

.now-playing[hidden] {
  display: none;
}

.now-playing__toggle {
  border: 0;
  border-right: 2px solid #638267;
  border-radius: 0;
  background: #123c27;
  color: #f2c84b;
  cursor: pointer;
  font: 800 12px/1 "Courier New", monospace;
  letter-spacing: 0;
  text-transform: uppercase;
}

.now-playing__toggle:hover,
.now-playing__toggle:focus-visible {
  background: #315d43;
  outline: 2px solid #f2c84b;
  outline-offset: -4px;
}

.now-playing__toggle[aria-pressed="true"] {
  color: #9ca8a0;
}

.now-playing__details {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 12px;
  font-family: "Courier New", monospace;
  letter-spacing: 0;
}

.now-playing__details strong,
.now-playing__details span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-playing__details strong {
  color: #f1e8bd;
  font-size: 14px;
}

.now-playing__details span {
  color: #a9b8ad;
  font-size: 12px;
}

#startButton {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  min-width: 174px;
  min-height: 46px;
  border: 3px solid #d9c887;
  border-radius: 0;
  background: #123c27;
  color: #f1e8bd;
  cursor: pointer;
  font: 700 15px/1 "Courier New", monospace;
  text-transform: uppercase;
  box-shadow:
    inset 0 0 0 2px #638267,
    5px 5px 0 rgba(4, 12, 8, 0.45);
}

#startButton:hover,
#startButton:focus-visible {
  background: #315d43;
  outline: 2px solid #f2c84b;
  outline-offset: 2px;
}

#startButton:disabled {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.touch-aim-controls {
  position: absolute;
  top: 50%;
  right: 34px;
  z-index: 18;
  display: none;
  grid-template-rows: repeat(2, 52px);
  gap: 8px;
  transform: translateY(-50%);
  touch-action: none;
  user-select: none;
}

.touch-aim-controls[hidden] {
  display: none;
}

.touch-aim-controls button {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 3px solid #d9c887;
  border-radius: 0;
  background: rgba(18, 60, 39, 0.94);
  color: #f1e8bd;
  cursor: pointer;
  font: 800 20px/1 "Courier New", monospace;
  box-shadow:
    inset 0 0 0 2px #638267,
    4px 4px 0 rgba(4, 12, 8, 0.5);
}

.touch-aim-controls button:active {
  background: #315d43;
  color: #ffffff;
  transform: translate(2px, 2px);
}

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

.menu-button {
  position: absolute;
  top: 40px;
  right: 40px;
  z-index: 20;
  width: 42px;
  height: 42px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 0 10px;
  border: 2px solid #d9c887;
  border-radius: 0;
  background: #0b2b1b;
  cursor: pointer;
}

.menu-button span {
  width: 100%;
  height: 2px;
  background: #f1e8bd;
}

.menu-button:hover,
.menu-button[aria-expanded="true"] {
  background: #315d43;
}

.game-menu {
  position: absolute;
  inset: 12px;
  z-index: 10;
  display: grid;
  place-items: start;
  padding: 72px 0 0 16px;
  background: rgba(10, 14, 12, 0.78);
}

.game-menu[hidden],
.pitch-list[hidden] {
  display: none;
}

.game-menu__panel {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100% - 88px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: #1c2722;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.game-menu h2 {
  margin: 0 0 20px;
  font-size: 26px;
}

.game-menu__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.game-menu button {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: #f4d35e;
  color: #1d211e;
  cursor: pointer;
  font: 700 15px/1 system-ui, sans-serif;
}

.game-menu .game-menu__exit {
  border: 1px solid #b76455;
  background: #4a2420;
  color: #f6ddd6;
}

.game-menu .game-menu__exit:hover,
.game-menu .game-menu__exit:focus-visible {
  background: #69332c;
  outline: 2px solid #e7a294;
  outline-offset: 2px;
}

.menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-top: 18px;
  padding: 11px 12px;
  border: 1px solid #638267;
  background: #26332d;
  color: #f1e8bd;
  cursor: pointer;
  font: 700 15px/1 "Courier New", monospace;
}

.menu-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #f2c84b;
}

.pitch-list {
  display: grid;
  gap: 1px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  background: rgba(255, 255, 255, 0.12);
}

.pitch-list li {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 16px;
  padding: 11px 12px;
  background: #26332d;
  font-size: 14px;
}

.pitch-list li span:first-child {
  font-weight: 700;
}

.loadout-step {
  display: grid;
  gap: 16px;
}

.loadout-step__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px 0;
  color: #f1e8bd;
}

.loadout-step__heading h3 {
  margin: 0;
  color: #f2c84b;
  font: 800 22px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.loadout-step__heading span {
  color: #b8c5b3;
  font: 700 12px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.loadout-step__nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.loadout-step__nav button {
  min-width: 140px;
  min-height: 44px;
  border: 2px solid #d9c887;
  border-radius: 0;
  background: #123c27;
  color: #f1e8bd;
  cursor: pointer;
  font: 800 13px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.loadout-step__nav button:last-child {
  background: #f4d35e;
  color: #1d211e;
}

.loadout-items fieldset {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

.loadout-items legend {
  width: 100%;
  margin: 10px 0 8px;
  color: #f2c84b;
  font: 800 15px/1 "Courier New", monospace;
  text-align: center;
  text-transform: uppercase;
}

.loadout-carousel {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: stretch;
  gap: 7px;
}

.loadout-carousel__viewport {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.loadout-carousel__viewport::-webkit-scrollbar {
  display: none;
}

.loadout-carousel__viewport:focus-visible {
  outline: 2px solid #f4d35e;
  outline-offset: 2px;
}

.loadout-carousel__track {
  display: flex;
  gap: 8px;
  min-width: min-content;
  padding: 2px;
}

.loadout-carousel__arrow {
  min-width: 0;
  border: 2px solid #638267;
  background: #123c27;
  color: #f4d35e;
  cursor: pointer;
  font: 900 26px/1 "Courier New", monospace;
}

.loadout-carousel__arrow:hover,
.loadout-carousel__arrow:focus-visible {
  border-color: #f4d35e;
  background: #1d5a38;
}

.loadout-carousel__arrow:disabled {
  cursor: default;
  opacity: 0.32;
}

.loadout-item {
  display: grid;
  grid-template-columns: 20px 58px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 78px;
  padding: 8px 9px;
  background: #26332d;
  color: #f5f0d8;
  cursor: pointer;
}

.loadout-content-group .loadout-item {
  flex: 0 0 clamp(190px, 24vw, 250px);
  grid-template-columns: 20px 58px minmax(0, 1fr);
  min-height: 104px;
  scroll-snap-align: start;
}

.loadout-settings {
  display: grid;
  gap: 2px;
}

.loadout-settings-group .loadout-item {
  flex: 0 0 clamp(150px, 18vw, 210px);
  min-height: 62px;
  scroll-snap-align: start;
}

.loadout-item--option {
  grid-template-columns: 20px minmax(0, 1fr);
  min-height: 62px;
}

.loadout-item:has(input:checked) {
  outline: 2px solid #f4d35e;
  outline-offset: -2px;
}

.loadout-item:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

.loadout-item input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #f4d35e;
}

.loadout-item__preview {
  display: grid;
  box-sizing: border-box;
  width: 58px;
  height: 58px;
  padding: 4px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #638267;
  background: #18211d;
}

.loadout-item__preview img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.loadout-item[data-slot="bat"] .loadout-item__preview img {
  max-width: 86%;
  max-height: 86%;
}

.loadout-item__weather-preview {
  display: flex;
}

.loadout-item__weather-preview > span {
  align-self: stretch;
  flex: 1;
}

.loadout-item__bat-preview {
  width: 56px;
  height: 8px;
  border-radius: 4px;
  transform: rotate(-32deg);
}

.loadout-item__details {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.loadout-item__heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.loadout-item__heading strong {
  font: 700 14px/1.15 "Courier New", monospace;
}

.loadout-item__modifiers {
  font-size: 12px;
  line-height: 1.3;
}

.development-controls {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #638267;
}

.development-controls h3 {
  margin: 0 0 10px;
  color: #a9c1ad;
  font: 700 13px/1 "Courier New", monospace;
  text-transform: uppercase;
}

.development-controls__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-menu .development-controls button {
  min-height: 38px;
  border: 1px solid #638267;
  background: #26332d;
  color: #f1e8bd;
  font: 700 13px/1 "Courier New", monospace;
}

.loadout-item__modifiers {
  color: #a9c1ad;
  font-family: "Courier New", monospace;
}

@media (max-width: 620px) {
  .home-screen {
    grid-template-rows: minmax(82px, 0.5fr) auto 0.7fr;
    padding: 24px 18px;
  }

  .home-screen__logo img {
    width: min(180px, 48vw);
    max-height: 28vh;
  }

  .home-screen__button {
    min-height: 46px;
  }

  .home-loadout {
    inset: 8px;
    padding: 10px;
  }

  .home-achievements,
  .home-stats {
    inset: 8px;
    padding: 10px;
  }

  .home-loadout__panel {
    padding: 14px;
  }

  .home-achievements__panel,
  .home-stats__panel {
    padding: 14px;
  }

  .achievement-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .game-stats-list {
    grid-template-columns: 1fr;
  }

  .now-playing {
    left: 24px;
    bottom: 24px;
    width: calc(100% - 48px);
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .touch-aim-controls {
    right: 24px;
    grid-template-rows: repeat(2, 48px);
  }

  .touch-aim-controls button {
    width: 48px;
    height: 48px;
  }

  .pitch-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .game-menu {
    inset: 8px;
    padding: 64px 0 0 8px;
  }

  .game-menu__panel {
    width: calc(100% - 16px);
    max-height: calc(100% - 72px);
    padding: 16px;
  }

  .loadout-item {
    grid-template-columns: 18px 50px minmax(0, 1fr);
    gap: 7px;
    min-height: 70px;
    padding: 7px;
  }

  .loadout-carousel {
    grid-template-columns: 30px minmax(0, 1fr) 30px;
    gap: 5px;
  }

  .loadout-carousel__arrow {
    font-size: 22px;
  }

  .loadout-content-group .loadout-item {
    flex-basis: min(68vw, 230px);
    grid-template-columns: 18px 50px minmax(0, 1fr);
    min-height: 96px;
  }

  .loadout-settings-group .loadout-item {
    flex-basis: min(62vw, 200px);
  }

  .loadout-item__preview {
    width: 50px;
    height: 50px;
    padding: 4px;
  }

  .loadout-item__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}
