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

* {
  box-sizing: border-box;
}

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

body {
  background: #08110f;
  color: #f4fff9;
  touch-action: none;
  user-select: none;
}

#game-shell {
  display: grid;
  place-items: center;
}

#stage {
  position: relative;
  width: min(100%, calc(100vh * 16 / 9));
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #08110f;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#game-canvas:focus-visible {
  outline: 3px solid #68f0ae;
  outline-offset: -3px;
}

button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #3d5b51;
  border-radius: 6px;
  background: #10231d;
  color: #f4fff9;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:hover,
button:focus-visible {
  border-color: #68f0ae;
  color: #68f0ae;
  outline: none;
}

button:active {
  background: #18362c;
  transform: translateY(1px);
}

#hud {
  position: absolute;
  inset: 18px 138px auto 22px;
  z-index: 3;
  display: flex;
  gap: 30px;
  pointer-events: none;
}

#hud div {
  min-width: 76px;
}

#hud span,
#hud strong {
  display: block;
  letter-spacing: 0;
}

#hud span {
  color: #a9c8bc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 750;
}

#hud strong {
  margin-top: 2px;
  color: #f4fff9;
  font-size: 20px;
  line-height: 1;
}

#action-controls {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

#action-controls button {
  font-size: 20px;
}

#boost-button {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 86px;
  height: 72px;
  border-color: #68f0ae;
  background: #68f0ae;
  color: #08110f;
}

#boost-button span {
  font-size: 28px;
  line-height: 22px;
}

#boost-button small {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0;
}

.panel {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 7;
  width: min(430px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  padding: 24px;
  border: 1px solid #68f0ae;
  border-radius: 8px;
  background: rgba(8, 17, 15, 0.98);
  text-align: center;
}

.panel.compact {
  width: min(330px, calc(100% - 32px));
}

.panel[hidden],
#toast[hidden],
.result-actions button[hidden] {
  display: none;
}

.status-label {
  margin: 0;
  color: #68f0ae;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 850;
}

.panel h1,
.panel h2 {
  margin: 8px 0;
  color: #f4fff9;
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.1;
  text-wrap: balance;
}

.panel p {
  margin: 0;
  color: #b7cec5;
  font-size: 14px;
  line-height: 1.5;
}

.panel .controls-copy,
.panel .best-result {
  margin-top: 8px;
  color: #ffd166;
}

.panel > .primary,
.result-actions {
  margin-top: 20px;
}

.panel > .primary {
  min-width: 174px;
  padding: 0 16px;
}

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

.result-actions button {
  min-width: 150px;
  padding: 0 14px;
}

.result-actions #share-button {
  min-width: 44px;
  padding: 0;
  font-size: 20px;
}

button.primary {
  border-color: #68f0ae;
  background: #68f0ae;
  color: #08110f;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 26px;
  z-index: 9;
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid #ffd166;
  border-radius: 5px;
  background: #10231d;
  color: #f4fff9;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

body[data-game-state="ready"] #hud,
body[data-game-state="ready"] #action-controls,
body[data-game-state="ready"] #boost-button,
body[data-game-state="over"] #boost-button,
body[data-game-state="over"] #action-controls,
body[data-game-state="paused"] #boost-button,
body[data-game-state="paused"] #action-controls {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

body[data-fever="true"] #streak-value {
  color: #ff7b6b;
}

@media (max-width: 700px), (max-height: 390px) {
  button {
    min-width: 32px;
    min-height: 32px;
    border-radius: 4px;
  }

  #hud {
    inset: 9px 86px auto 10px;
    gap: 12px;
  }

  #hud div {
    min-width: 48px;
  }

  #hud span {
    font-size: 6px;
  }

  #hud strong {
    font-size: 12px;
  }

  #action-controls {
    top: 8px;
    right: 8px;
    gap: 4px;
  }

  #action-controls button {
    font-size: 14px;
  }

  #boost-button {
    right: 10px;
    bottom: 10px;
    width: 58px;
    height: 48px;
  }

  #boost-button span {
    font-size: 18px;
    line-height: 14px;
  }

  #boost-button small {
    font-size: 6px;
  }

  .panel,
  .panel.compact {
    width: min(360px, calc(100% - 20px));
    padding: 12px;
  }

  .status-label {
    font-size: 8px;
  }

  .panel h1,
  .panel h2 {
    margin: 4px 0;
    font-size: 18px;
  }

  .panel p {
    font-size: 9px;
  }

  .panel > .primary,
  .result-actions {
    margin-top: 10px;
  }

  .panel > .primary,
  .result-actions button {
    min-width: 108px;
    min-height: 30px;
    padding: 0 8px;
    font-size: 9px;
  }

  .result-actions #share-button {
    min-width: 32px;
    padding: 0;
    font-size: 14px;
  }

  #toast {
    bottom: 8px;
    padding: 5px 9px;
    font-size: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  button:active {
    transform: none;
  }
}
