html, body {
  margin: 0;
  height: 100%;
  background: #1b140f;
  color: #f3e6cf;
  font: 15px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "PingFang SC", "Hiragino Sans", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-sizing: border-box;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.boot-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1b140f;
  transition: opacity 0.3s;
}

.boot-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.boot-card {
  width: min(360px, 80vw);
  text-align: center;
}

.boot-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 14px;
  color: #ffcc66;
}

.boot-bar {
  height: 8px;
  border-radius: 4px;
  background: #3a2b20;
  overflow: hidden;
  margin-bottom: 10px;
}

#boot-progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #c96b1c, #ffcc66);
  transition: width 0.2s;
}

#boot-msg.error {
  color: #ff8a7a;
}

/* ---------------------------------------------------------------- HUD shell */

#hud {
  position: absolute;
  pointer-events: none;
}

#hud > * {
  pointer-events: auto;
}

.toolbar {
  position: absolute;
  display: flex;
  gap: 8px;
}

.toolbar.vertical {
  flex-direction: column;
}

.toolbar.floating {
  opacity: 0.55;
  gap: 4px;
}

.toolbar.floating:hover,
.toolbar.floating:focus-within {
  opacity: 1;
}

.tool {
  width: 44px;
  height: 44px;
  padding: 9px;
  border: 1px solid #6b4a2f;
  border-radius: 10px;
  background: #2a1d14;
  color: #ffcc66;
  cursor: pointer;
}

.toolbar.floating .tool.full {
  display: none;
}

.toolbar.floating .tool {
  width: 34px;
  height: 34px;
  padding: 6px;
}

.tool:hover,
.tool:focus-visible {
  background: #3c2a1c;
  outline: 2px solid #ffcc66;
  outline-offset: 1px;
}

.tool svg {
  width: 100%;
  height: 100%;
  display: block;
}

.keybar {
  position: absolute;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.keybar.vertical {
  flex-direction: column;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-content: center;
}

.rotate-hint {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  color: #c9a67a;
  pointer-events: none;
}

.keybar.floating {
  opacity: 0.6;
}

.key {
  min-width: 48px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #6b4a2f;
  border-radius: 10px;
  background: #2a1d14;
  color: #f3e6cf;
  font: 600 14px/1 inherit;
  font-family: inherit;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.key.latch {
  color: #9fd3ff;
}

.key.on {
  background: #ffcc66;
  color: #2a1d14;
  border-color: #ffcc66;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  max-width: 90%;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(20, 14, 10, 0.92);
  color: #f3e6cf;
  border: 1px solid #6b4a2f;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- modals */

.modal-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 4, 0.6);
  z-index: 10;
  padding: 12px;
  box-sizing: border-box;
}

.modal {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 20px;
  border-radius: 14px;
  background: #241912;
  border: 1px solid #6b4a2f;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal h2 {
  margin: 0 0 6px;
  color: #ffcc66;
  font-size: 20px;
}

.modal h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #c9a67a;
}

.modal p {
  margin: 6px 0;
}

.modal .small {
  font-size: 13px;
  color: #d9c7aa;
}

.modal .warn {
  color: #ffb38a;
  font-size: 13px;
}

.modal select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #6b4a2f;
  background: #1b140f;
  color: #f3e6cf;
  font: inherit;
}

.row.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  cursor: pointer;
}

.row.check input {
  width: 20px;
  height: 20px;
  accent-color: #ffcc66;
}

.row.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #6b4a2f;
  background: #2f2218;
  color: #f3e6cf;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
  border-color: #ffcc66;
}

.btn.primary {
  background: #ffcc66;
  color: #2a1d14;
  border-color: #ffcc66;
  font-weight: 600;
}

.btn.danger {
  color: #ffb38a;
}

.settings > .btn.primary {
  width: 100%;
  margin-top: 14px;
}

.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
}

.badge a {
  color: #ffcc66;
}

.egg-btn {
  width: 44px;
  height: 44px;
  padding: 8px;
  border: 1px dashed #6b4a2f;
  border-radius: 50%;
  background: transparent;
  color: #ffcc66;
  cursor: pointer;
}

.egg-btn:hover svg {
  animation: spin 2.4s linear infinite;
}

.egg {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.egg-icon {
  width: 72px;
  height: 72px;
  color: #ffcc66;
  animation: spin 9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .egg-icon,
  .egg-btn:hover svg {
    animation: none;
  }
}

[hidden] {
  display: none !important;
}
