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

* {
  box-sizing: border-box;
}

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

button,
kbd {
  font: inherit;
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
  background: #07151a;
}

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

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

body.is-loading #hud,
body.is-loading #minimap,
body.is-loading #wind,
body.is-loading #help,
body.is-loading #overlay {
  visibility: hidden;
  pointer-events: none;
}

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 216px;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.hud-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat {
  min-width: 92px;
  border: 1px solid rgba(255, 232, 178, 0.2);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(18, 53, 61, 0.82), rgba(8, 25, 31, 0.76));
  padding: 8px 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.stat span {
  display: block;
  color: #b8dbd4;
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  letter-spacing: 0;
}

.mode-actions button {
  border: 1px solid rgba(255, 232, 178, 0.24);
  border-radius: 6px;
  background: linear-gradient(180deg, #2e5962, #17343c);
  color: #fff7e6;
  padding: 8px 11px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.mode-actions button:hover {
  background: linear-gradient(180deg, #3c6c75, #214750);
}

.mode-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#minimap {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(255, 232, 178, 0.24);
  border-radius: 8px;
  background: rgba(5, 17, 22, 0.78);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

#wind {
  position: fixed;
  right: 32px;
  top: 212px;
  width: 150px;
  height: 28px;
  color: #d7eee7;
  font-size: 13px;
  text-align: center;
}

#wind span::before {
  content: "Wind";
  margin-right: 8px;
  color: #9cc9c1;
}

#feed {
  width: min(440px, 100%);
  display: grid;
  gap: 6px;
  pointer-events: none;
}

.message {
  border-radius: 6px;
  background: rgba(8, 25, 31, 0.82);
  color: #f8fff7;
  padding: 8px 10px;
  border-left: 3px solid #77cfd8;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
}

.message.danger {
  border-left-color: #ee715d;
}

.message.reward {
  border-left-color: #f1c85b;
}

#help {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: none;
  color: #d3e7df;
  font-size: 13px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

kbd {
  color: #ffffff;
  font: inherit;
  font-weight: 850;
}

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(5, 17, 22, 0.72);
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#overlay.hidden {
  display: none;
}

#overlay h1 {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(34px, 5vw, 64px);
  letter-spacing: 0;
  white-space: nowrap;
}

#overlay p {
  margin: 0;
  max-width: 520px;
  color: #d9e9e3;
  font-size: 18px;
}

.start-panel {
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  max-height: calc(100dvh - 32px);
  display: grid;
  justify-items: center;
  gap: 14px;
  border: 1px solid rgba(255, 232, 178, 0.22);
  border-radius: 8px;
  background: rgba(6, 22, 28, 0.9);
  padding: 24px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(12px) saturate(1.08);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.start-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(560px, 100%);
  margin: 0 auto;
}

.start-controls span {
  padding: 8px 10px;
  border: 1px solid rgba(214, 237, 227, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #ecfff8;
  font-size: 13px;
}

.start-controls kbd {
  color: #ffffff;
  font: inherit;
  font-weight: 850;
}

.mode-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.mode-actions button {
  min-width: 132px;
}

#overlay .gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(217, 233, 227, 0.72);
  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;
}

@media (max-width: 760px) {
  #hud {
    right: 12px;
    left: 12px;
    top: 12px;
  }

  .stat {
    min-width: 74px;
    padding: 6px 8px;
  }

  .stat strong {
    font-size: 17px;
  }

  #minimap {
    width: 128px;
    height: 128px;
    top: auto;
    right: 12px;
    bottom: 12px;
  }

  #wind {
    display: none;
  }

  .mode-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(320px, calc(100vw - 48px));
    margin: 0 auto;
  }

  #overlay {
    padding: 18px 12px;
  }

  #overlay p {
    font-size: 16px;
  }

  .start-panel {
    max-height: calc(100vh - 36px);
    max-height: calc(100svh - 36px);
    max-height: calc(100dvh - 36px);
    gap: 10px;
    padding: 18px 12px;
  }

  .start-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .start-controls span {
    padding: 6px 8px;
    font-size: 12px;
  }

  .mode-actions button {
    min-width: 0;
    width: 100%;
  }
}
