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

* {
  box-sizing: border-box;
}

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

#game {
  position: relative;
  background: #141718;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #111;
  color: #f5f1e8;
  font-size: 18px;
  font-weight: 800;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

body.is-loading #crosshair,
body.is-loading #hud,
body.is-loading #startPanel {
  visibility: hidden;
  pointer-events: none;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
}

#crosshair::before {
  left: 8px;
  top: 1px;
  width: 2px;
  height: 16px;
}

#crosshair::after {
  left: 1px;
  top: 8px;
  width: 16px;
  height: 2px;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.bars,
#controls,
#message {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 20, 20, 0.72);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.bars {
  width: min(300px, 42vw);
  padding: 10px;
}

.bars label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  line-height: 1.5;
  color: #f3ead7;
}

.meter {
  height: 12px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.13);
  margin-bottom: 8px;
}

.meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #d94c4c, #f0a55a);
}

.meter.crystal span {
  background: linear-gradient(90deg, #38c8ff, #c8f8ff);
}

.meter.timer span {
  background: linear-gradient(90deg, #77d06d, #f0cf5a);
}

#message {
  position: absolute;
  left: 50%;
  top: max(128px, 18vh);
  transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 14px;
  font-size: 14px;
  text-align: center;
  color: #fff7df;
}

#startButton {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  background: #2f5c4f;
  color: white;
  font: inherit;
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

#startButton:hover {
  background: #3d725f;
}

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 72px);
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

#hotbar li {
  height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(18, 20, 20, 0.76);
  display: grid;
  grid-template-rows: 16px 1fr;
  align-items: center;
  justify-items: center;
  padding: 5px 6px 8px;
  text-align: center;
  color: #f2eadc;
}

.hotbar-key {
  justify-self: start;
  min-width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.hotbar-label {
  grid-row: 2;
  max-width: 100%;
  color: #fff4d9;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
}

#hotbar li.active {
  border-color: #ffd36b;
  box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.18);
}

#startPanel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 211, 107, 0.12), transparent 32%),
    rgba(3, 5, 7, 0.58);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#startPanel[hidden] {
  display: none;
}

.start-card {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  max-height: calc(100svh - 40px);
  max-height: calc(100dvh - 40px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(18, 20, 20, 0.86);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  padding: 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.start-card h1 {
  margin: 0 0 8px;
  max-width: 100%;
  overflow: hidden;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.start-card p {
  margin: 0 0 18px;
  color: #d8d2c5;
  font-size: 14px;
}

.mode-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

#startButton,
#startAutoButton {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  background: #2f5c4f;
  color: white;
  font: inherit;
  padding: 11px 12px;
  cursor: pointer;
}

#startAutoButton {
  background: #2f5c4f;
}

#startButton:disabled,
#startAutoButton:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#startButton:hover,
#startAutoButton:hover {
  background: #3d725f;
}

.start-card .gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(216, 210, 197, 0.68);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.gameblocks-credit a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.control-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.control-list div {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  align-items: start;
}

.control-list dt {
  color: #ffd36b;
  font-size: 12px;
  font-weight: 700;
}

.control-list dd {
  margin: 0;
  color: #f0eadf;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 720px) {
  #hud {
    padding: 10px;
  }

  .top-row {
    flex-direction: column;
  }

  .bars {
    width: 100%;
    min-width: 0;
  }

  #hotbar {
    left: auto;
    right: 10px;
    transform: none;
    grid-template-columns: repeat(2, 64px);
    bottom: 16px;
  }

  #hotbar li {
    height: 50px;
    grid-template-rows: 14px 1fr;
    padding: 4px 5px 6px;
  }

  .hotbar-key {
    min-width: 14px;
    height: 14px;
    font-size: 9px;
  }

  .hotbar-label {
    font-size: 10px;
  }

  #message {
    top: 188px;
    max-width: calc(100vw - 20px);
    font-size: 13px;
  }

  .start-card {
    padding: 18px;
  }

  .mode-actions {
    grid-template-columns: 1fr;
  }

  .control-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
