*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  color: #f0f0f0;
  font-family: 'Georgia', 'Times New Roman', serif;
  overflow: hidden;
  touch-action: manipulation;
}

/* ── Login Screen ───────────────────────────────────────────────────────────── */

#login-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #1a0e2a 0%, #0a0a0a 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

#login-box {
  text-align: center;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1.5rem, 6vw, 4rem);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  backdrop-filter: blur(12px);
}

#login-box h1 {
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: normal;
  letter-spacing: 0.18em;
  color: #e8d5b7;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: #7a7a8a;
  font-style: italic;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  letter-spacing: 0.12em;
}

#login-options {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f0f0f0;
  font-family: 'Georgia', serif;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover, .btn:focus-visible {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.32);
  outline: none;
}

.btn:active { opacity: 0.85; }

.btn-primary {
  font-size: clamp(0.95rem, 2.8vw, 1.1rem);
  color: #e8d5b7;
  border-color: rgba(232, 213, 183, 0.28);
  padding: 0.85rem 1.5rem;
}

.btn-primary:hover, .btn-primary:focus-visible {
  border-color: rgba(232, 213, 183, 0.55);
  background: rgba(232, 213, 183, 0.08);
}

.divider {
  color: #3a3a4a;
  font-size: 0.85rem;
  user-select: none;
}

input[type="text"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f0f0f0;
  font-family: 'Courier New', monospace;
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  width: 100%;
  text-align: center;
  letter-spacing: 0.06em;
  transition: border-color 0.18s, background 0.18s;
}

input[type="text"]:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.09);
}

input[type="text"]::placeholder {
  color: #3a3a4a;
  font-family: 'Georgia', serif;
  font-size: 0.78rem;
  letter-spacing: 0;
}

.login-error {
  color: #e08080;
  font-size: 0.88rem;
  margin-top: 0.85rem;
  min-height: 1.2em;
  font-style: italic;
}

/* ── Game Canvas ────────────────────────────────────────────────────────────── */

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  cursor: default;
}

/* ── Session Badge ──────────────────────────────────────────────────────────── */

#session-badge {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom, 12px));
  right: max(14px, env(safe-area-inset-right, 14px));
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 5px 10px;
  z-index: 200;
  backdrop-filter: blur(6px);
}

#session-id-text {
  color: #555;
  font-family: 'Courier New', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#btn-copy {
  width: auto;
  padding: 2px 8px;
  font-size: 0.65rem;
  border-radius: 4px;
  color: #888;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
}

#btn-copy:hover { color: #bbb; border-color: rgba(255,255,255,0.25); }
