* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0a0a1a;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 30%, #0d1b3e 0%, #070714 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
}
.screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 80% 15%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 65% 55%, rgba(255,255,255,0.2), transparent);
  pointer-events: none;
  z-index: 0;
}
.screen > * { position: relative; z-index: 1; }

/* LOGIN */
.logo { text-align: center; margin-top: 12vh; }
.logo h1 {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 10px;
  background: linear-gradient(135deg, #44aaff, #ff44aa, #ffcc44);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  color: #8888aa;
  letter-spacing: 6px;
  font-size: 1rem;
  text-transform: uppercase;
}

.menu-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 28px;
  margin: 28px;
  max-width: 380px;
  width: calc(100% - 40px);
  backdrop-filter: blur(10px);
}

.tagline {
  color: #6e6e88;
  font-size: 0.9rem;
  max-width: 380px;
  text-align: center;
  padding: 0 24px;
  margin-bottom: 40px;
}

.input-group { margin-bottom: 16px; }
.input-group label {
  display: block;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.input-group input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 1rem;
  outline: none;
}
.input-group input:focus { border-color: #ff8844; }

/* BUTTONS */
.btn {
  display: inline-block;
  padding: 11px 22px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #ff6633, #ff4444);
  color: white;
  width: 100%;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(255,68,68,0.3);
}
.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #ccc;
  border: 1px solid rgba(255,255,255,0.12);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); }
.btn-text {
  background: none;
  color: #888;
  font-size: 0.9rem;
}
.btn-text:hover { color: #ccc; }
.btn-link {
  background: none;
  border: none;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: #ff8844; }

.error-msg {
  background: rgba(255,50,50,0.15);
  border: 1px solid rgba(255,50,50,0.3);
  color: #ff6666;
  padding: 10px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* DASHBOARD */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1000px;
  padding: 24px 24px 16px;
}
.dash-logo {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #44aaff, #ff44aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.dash-logo span {
  font-size: 0.9rem;
  margin-left: 6px;
  color: #888;
  -webkit-text-fill-color: #888;
  letter-spacing: 2px;
}
.dash-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #aaa;
}

.dash-section {
  width: 100%;
  max-width: 1000px;
  padding: 8px 24px 16px;
}
.dash-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: #888;
  margin-bottom: 12px;
}

.new-game-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.new-game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.new-game-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,136,68,0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
.new-game-card .game-icon {
  font-size: 2.2rem;
  line-height: 1;
}
.new-game-card .game-info h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}
.new-game-card .game-info p {
  font-size: 0.8rem;
  color: #888;
  line-height: 1.4;
}

.dash-join {
  display: flex;
  gap: 8px;
  max-width: 320px;
}
.dash-join input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #e0e0e0;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 1rem;
  outline: none;
  text-align: center;
}

.games-list { width: 100%; padding-bottom: 60px; }
.game-section { margin-bottom: 18px; }
.game-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
  font-weight: 700;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.game-card:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,136,68,0.3);
}
.game-card.has-unread {
  border-color: rgba(255,136,68,0.5);
  background: rgba(255,136,68,0.05);
}
.game-card-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.game-card-body { flex: 1; }
.game-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.game-card-game { font-weight: 600; font-size: 0.95rem; }
.game-card-code {
  font-family: monospace;
  font-size: 0.9rem;
  color: #ff8844;
  letter-spacing: 2px;
}
.game-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}
.game-card-status { font-weight: 600; }
.game-card-age { color: #555; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.modal-content {
  background: rgba(20,20,40,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: calc(100% - 40px);
}
.modal-content h2 {
  text-align: center;
  margin-bottom: 18px;
}
.mode-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: #eee;
  font-family: inherit;
  margin-bottom: 8px;
  transition: all 0.15s;
}
.mode-option:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,136,68,0.4);
}
.mode-emoji { font-size: 1.8rem; }
.mode-option h3 { font-size: 1rem; margin-bottom: 4px; }
.mode-option p { font-size: 0.85rem; color: #aaa; line-height: 1.4; }

@media (max-width: 600px) {
  .logo h1 { font-size: 2.5rem; letter-spacing: 5px; }
  .dash-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .new-game-menu { grid-template-columns: 1fr; }
}

/* Shown across the top while the server cannot be reached. */
#connection-status {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000; display: none;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px; text-align: center;
  background: #b3541e; color: #fff; font-size: 0.85rem; font-weight: 600; pointer-events: none;
}
#connection-status.show { display: block; }
.shell-loading { padding: 80px 20px; text-align: center; color: #8fa3bf; }

/* "Install as an app" offer on the dashboard. */
.install-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; width: min(92%, 720px); margin: 14px auto 0;
  padding: 10px 14px; border-radius: 10px; background: rgba(255, 136, 68, 0.12); border: 1px solid rgba(255, 136, 68, 0.4);
  color: #e0e0e0; font-size: 0.9rem; position: relative; z-index: 1;
}
.install-bar span { flex: 1 1 200px; }
.install-bar .btn { width: auto; margin: 0; padding: 8px 18px; }
