:root {
  --earth: #2e1f14;
  --earth-light: #4a3422;
  --green: #2f4a23;
  --gold: #d9a521;
  --red: #a8341f;
  --cream: #f1e3c6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #1a120b;
  color: var(--cream);
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

#game {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game canvas {
  display: block;
  touch-action: none;
}

/* Loading screen */
#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(circle at 50% 35%, #3a2817, #1a120b 75%);
  transition: opacity .5s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.loading-shield { font-size: 64px; animation: pulse 1.6s ease-in-out infinite; }
.loading-title {
  font-size: 42px; font-weight: 900; letter-spacing: 6px;
  color: var(--gold); text-shadow: 0 3px 0 #5b3c12;
}
.loading-sub { font-size: 18px; letter-spacing: 3px; color: var(--cream); opacity: .85; }
.loading-bar {
  width: 200px; height: 10px; border-radius: 6px;
  background: #00000040; overflow: hidden; margin-top: 12px;
  border: 1px solid #ffffff20;
}
.loading-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  animation: fill 1.8s ease forwards;
}
.loading-tip { font-size: 13px; opacity: .6; margin-top: 8px; }

@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.12)} }
@keyframes fill { from{width:0%} to{width:100%} }

/* Account / sign-in modal */
#authOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 20px;
}
#authOverlay[hidden] { display: none; }
.au-modal {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(160deg, var(--earth-light), var(--earth));
  border: 3px solid var(--gold);
  border-radius: 18px;
  padding: 22px 22px 26px;
  box-shadow: 0 12px 40px #000a;
  color: var(--cream);
}
.au-modal h2 { margin: 0 0 4px; color: var(--gold); font-size: 24px; letter-spacing: 1px; }
.au-modal p { margin: 6px 0 14px; font-size: 14px; opacity: .85; line-height: 1.4; }
.au-modal .au-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.au-modal label { font-size: 13px; opacity: .8; }
.au-modal input {
  font: inherit; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--gold); background: #1a120b; color: var(--cream);
}
.au-modal button {
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 12px; border-radius: 10px; border: none; width: 100%;
  background: var(--red); color: #fff; margin-top: 4px;
}
.au-modal button.secondary { background: transparent; border: 1px solid var(--gold); color: var(--cream); }
.au-modal button.ghost { background: transparent; border: none; color: var(--gold); width: auto; padding: 6px; }
.au-modal .au-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.au-modal .au-tabs button { background: #00000030; border: 1px solid var(--gold); }
.au-modal .au-tabs button.active { background: var(--green); }
.au-modal .au-err { color: #ffb4a4; font-size: 13px; min-height: 18px; margin-top: 6px; }
.au-modal .au-top { display: flex; justify-content: space-between; align-items: center; }
.au-modal .au-close { width: auto; background: transparent; color: var(--cream); font-size: 22px; padding: 0 6px; margin: 0; }
.au-modal .au-badge { font-size: 13px; opacity: .8; margin-bottom: 10px; }

#installBtn {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 40;
  background: var(--gold);
  color: var(--earth);
  border: none;
  border-radius: 24px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 4px 12px #00000060;
  cursor: pointer;
}
