:root {
  --bg0: #0b1210;
  --bg1: #132019;
  --panel: rgba(18, 28, 23, 0.92);
  --line: rgba(212, 175, 105, 0.28);
  --text: #f3eee3;
  --muted: #a9b5aa;
  --accent: #d4af69;
  --accent-strong: #e6c57a;
  --track: rgba(255, 255, 255, 0.08);
  --fill: linear-gradient(90deg, #8a6a2f, #d4af69 55%, #f0d79a);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --bar-h: 56px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

body.immersive #app,
body.immersive #unity-container {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1a1408;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  box-shadow: 0 8px 20px rgba(212, 175, 105, 0.28);
}

.btn.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.btn-icon {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 2px;
  position: relative;
}

.btn-icon::after {
  content: "";
  position: absolute;
  right: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.unity-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  background: #231F20;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px 500px at 50% 30%, rgba(212, 175, 105, 0.1), transparent 60%),
    rgba(8, 12, 10, 0.88);
  z-index: 10;
}

.loading-card {
  width: min(420px, 100%);
  padding: 28px 24px 22px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 28%, #f3e0ad, #c59645 52%, #6a4a1b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 10px 24px rgba(0,0,0,0.35);
}

.loading-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.loading-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--fill);
  transition: width 0.12s linear;
}

.loading-percent {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.unity-warning {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 15;
  width: min(520px, calc(100% - 24px));
  display: none;
}

.banner-item {
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(20, 28, 24, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}

.banner-item.error {
  background: rgba(120, 24, 24, 0.92);
  border-color: rgba(255, 120, 120, 0.35);
}

.banner-item.warning {
  background: rgba(90, 70, 18, 0.92);
  border-color: rgba(240, 200, 90, 0.35);
}

.rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background:
    radial-gradient(700px 450px at 50% 40%, rgba(212, 175, 105, 0.14), transparent 60%),
    rgba(7, 10, 9, 0.96);
}

.rotate-overlay[hidden] { display: none !important; }

.rotate-card {
  width: min(420px, 100%);
  text-align: center;
  padding: 28px 22px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.rotate-card h2 {
  margin: 18px 0 8px;
  font-size: 22px;
}

.rotate-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 15px;
}

.phone-tilt {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.phone-body {
  width: 34px;
  height: 58px;
  border: 3px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(212, 175, 105, 0.2);
  animation: tilt-phone 1.6s ease-in-out infinite;
}

@keyframes tilt-phone {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(90deg); }
  60% { transform: rotate(90deg); }
}

.install-prompt {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(16px + var(--safe-top))
    calc(16px + var(--safe-right))
    calc(16px + var(--safe-bottom))
    calc(16px + var(--safe-left));
  background: rgba(0, 0, 0, 0.62);
}

.install-prompt[hidden] { display: none !important; }

.install-card {
  width: min(440px, 100%);
  padding: 22px 20px 18px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.install-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.install-card p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.install-steps {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
}

.install-steps:empty {
  display: none;
}

.install-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.install-actions .btn {
  width: 100%;
  justify-content: center;
  display: inline-flex;
}

body.needs-rotate #unity-container {
  filter: blur(2px);
}

body.game-ready #unity-container {
  min-height: 0;
  height: 100%;
}

@media (max-width: 720px) {
  .btn.primary { padding: 10px 12px; }
  .btn.primary .btn-icon { margin: 0; }
}
