:root {
  color-scheme: dark;
  --bg-0: #05091a;
  --bg-1: #091737;
  --bg-2: #142a58;
  --glass: rgba(14, 30, 69, 0.78);
  --line: rgba(84, 167, 255, 0.42);
  --text: #e7f2ff;
  --muted: #9eb8d8;
  --accent-a: #38c8ff;
  --accent-b: #4b8fff;
  --warn: #ffc96d;
  --danger: #ff6f91;
}

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

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: radial-gradient(70% 50% at 15% 12%, #214173 0%, rgba(33, 65, 115, 0) 55%), radial-gradient(52% 45% at 90% 86%, #3a2d6b 0%, rgba(58, 45, 107, 0) 62%), var(--bg-0);
  font-family: "SF Pro Display", "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  overscroll-behavior: none none;
}

#app-shell {
  position: relative;
  width: 100vw;
  height: var(--app-height, 100dvh);
  min-height: 100vh;
  isolation: isolate;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #070d1f;
  touch-action: none;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ui-screen {
  position: absolute;
  inset: 0;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.top-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.glass-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 38, 84, 0.75), rgba(8, 20, 50, 0.86));
  border-radius: 20px;
  backdrop-filter: blur(9px);
  box-shadow: inset 0 1px 0 rgba(181, 224, 255, 0.16), 0 22px 42px rgba(2, 6, 20, 0.4);
}

.game-btn {
  border: 1px solid rgba(151, 213, 255, 0.82);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: #f7fdff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 12px 14px;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 8px 20px rgba(29, 132, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.game-btn.secondary {
  background: linear-gradient(180deg, rgba(23, 47, 96, 0.92), rgba(12, 31, 74, 0.96));
  color: var(--text);
  border-color: rgba(88, 142, 221, 0.75);
  box-shadow: inset 0 1px 0 rgba(214, 232, 255, 0.1);
}

.game-btn.warn {
  background: linear-gradient(160deg, #ffd988 0%, #ff9e4d 100%);
  color: #1f1506;
  border-color: rgba(255, 237, 167, 0.92);
}

.game-btn:active {
  transform: translateY(1px);
}

.hud-btn {
  border-radius: 13px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.title {
  color: var(--text);
  font-size: 46px;
  margin: 0;
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 10px 28px rgba(30, 89, 188, 0.4);
}

.subtitle {
  color: #d7e9ff;
  font-size: 16px;
  margin: 2px 0 0;
  font-weight: 700;
  text-align: center;
}

.muted {
  color: var(--muted);
}

.auth-card,
.menu-card,
.modal-card {
  padding: 16px;
}

.auth-card,
.modal-card {
  margin-top: auto;
  margin-bottom: auto;
}

.field {
  width: 100%;
  border: 1px solid rgba(111, 171, 247, 0.58);
  border-radius: 14px;
  background: rgba(5, 17, 44, 0.66);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}

.field:focus {
  border-color: rgba(159, 222, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(73, 165, 255, 0.25);
}

.row {
  display: flex;
  gap: 8px;
}

.row.equal > * {
  flex: 1;
}

.tiny {
  font-size: 12px;
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 172px;
  overflow: auto;
}

.leader-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(83, 141, 216, 0.52);
  background: rgba(9, 22, 57, 0.74);
  color: var(--text);
  font-size: 14px;
}

.chip {
  border-radius: 999px;
  border: 1px solid rgba(104, 160, 235, 0.58);
  background: rgba(8, 21, 52, 0.72);
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
}

.chip.active {
  color: #e9f6ff;
  border-color: rgba(163, 221, 255, 0.95);
  background: linear-gradient(160deg, rgba(58, 151, 255, 0.88), rgba(75, 110, 255, 0.8));
}

.spacer {
  flex: 1;
}

.footer-note {
  text-align: center;
  color: rgba(172, 204, 235, 0.74);
  font-size: 12px;
  font-weight: 700;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 24, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
}

.modal-card {
  width: min(520px, 100%);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 11px;
  border: 1px solid rgba(119, 180, 255, 0.52);
  background: rgba(10, 24, 58, 0.76);
  color: #d8edff;
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ce887;
}

.status-dot.offline {
  background: #ff7f9e;
}

@media (min-width: 740px) {
  #app-shell {
    width: min(430px, 98vw);
    height: min(900px, 98vh);
    margin: auto;
    border-radius: 30px;
    overflow: hidden;
    border: 1px solid rgba(89, 144, 226, 0.52);
    box-shadow: 0 24px 70px rgba(5, 11, 34, 0.6), inset 0 1px 0 rgba(206, 230, 255, 0.18);
  }
}
