/* Web-shell equivalents of theme::color and theme::text; the game uses the Rust kit. */
:root {
  color-scheme: dark;
  --shell-background: #12171f;
  --shell-panel: #1d242f;
  --shell-text: #e0eef5;
  --shell-muted: #8c9eaf;
  --shell-primary: #ffbe3c;
  --shell-interact: #5ce2ff;
  --shell-border: rgb(238 242 248 / 24%);
  --shell-radius: 6px;
  --shell-space: 16px;
  --viewport-height: 100vh;
  --viewport-width: 100%;
}

@supports (height: 100dvh) {
  :root { --viewport-height: 100dvh; }
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--shell-background);
  color: var(--shell-text);
  font: 16px/1.5 system-ui, sans-serif;
}

[hidden] { display: none !important; }

#game-viewport {
  user-select: none;
  -webkit-user-select: none;
  position: fixed;
  top: var(--viewport-top, 0px);
  left: var(--viewport-left, 0px);
  width: var(--viewport-width);
  height: var(--viewport-height);
  box-sizing: border-box;
  /* The canvas fills the whole screen, under the notch and the home bar: the
     game keeps its controls clear of them (theme::safe_area). Shell controls
     keep their own safe-area offsets below. */
}

#game-surface {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Transparent until Bevy's first frame covers the loading message. */
#bevy {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* Measures env(safe-area-inset-*) in px for mobile.js (theme::safe_area). */
#safe-area-probe {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--shell-muted);
  letter-spacing: 0.08em;
  pointer-events: none;
}

.shell-panel {
  box-sizing: border-box;
  padding: var(--shell-space);
  background: var(--shell-panel);
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  box-shadow: 0 8px 32px rgb(0 0 0 / 35%);
}

.shell-panel h1,
.shell-panel h2,
.shell-panel p { margin: 0; }
.shell-panel h1 { font-size: 26px; line-height: 1.2; }
.shell-panel h2 { font-size: 16px; color: var(--shell-primary); }
.shell-panel p + p { margin-top: 8px; }
.shell-muted { color: var(--shell-muted); }
.shell-caption { font-size: 12.5px; color: var(--shell-muted); }
.shell-brand {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--shell-primary);
}

#rotate-device {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  background: var(--shell-background);
  overflow: auto;
}

.rotate-panel {
  width: min(100%, 360px);
  padding: 24px;
  text-align: center;
  border-top-color: var(--shell-primary);
}
.rotate-panel h1 { margin-bottom: 16px; }
.rotate-panel .shell-caption { margin-top: 24px; }
.rotate-symbol {
  display: block;
  width: 160px;
  height: 100px;
  margin: 16px auto;
  color: var(--shell-interact);
}

/* Above everything, the rotation prompt included: installing works upright. */
#install-gate {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  box-sizing: border-box;
  padding: max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  background: var(--shell-background);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.gate-panel {
  width: min(100%, 440px);
  margin: auto;
  padding: 24px;
  border-top-color: var(--shell-primary);
}
.shell-panel.gate-panel > * + * { margin-top: 12px; }
.gate-panel .shell-button { width: 100%; }
.gate-steps h2 { margin-bottom: 4px; }
.gate-steps ol { margin: 0; padding-left: 22px; }
.gate-steps li + li { margin-top: 4px; }
.gate-steps strong { color: var(--shell-text); }
.gate-launch { font-weight: 600; }
#gate-status:empty { display: none; }

.shell-button-primary {
  border-color: var(--shell-primary);
  color: var(--shell-background);
  background: var(--shell-primary);
}
.shell-button-primary:hover { border-color: var(--shell-text); }

#install-hint {
  position: absolute;
  z-index: 3;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: calc(env(safe-area-inset-right, 0px) + 8px);
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(480px, calc(100% - 16px));
  border-left: 2px solid var(--shell-primary);
}
#install-hint p { margin-top: 4px; font-size: 12.5px; }
#fullscreen-hint { color: var(--shell-muted); }

.shell-button {
  flex: none;
  min-width: 88px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--shell-border);
  border-radius: 2px;
  color: var(--shell-text);
  background: var(--shell-background);
  font: 600 13px/1.2 system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
.shell-button:focus-visible {
  outline: 2px solid var(--shell-interact);
  outline-offset: 3px;
}
.shell-button:hover { border-color: var(--shell-interact); }

.shell-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#shell-status {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  font-size: 12.5px;
  text-align: center;
  color: var(--shell-text);
  background: var(--shell-panel);
  border-radius: var(--shell-radius);
}
#shell-status:not(:empty) { padding: 8px 12px; }

/* Prevent Safari zooming toward the hidden input used by the canvas UI. */
#egui_text_agent { font-size: 16px; }
