:root {
  --bg-0: #050d18;
  --bg-1: #071a30;
  --bg-2: #0b2b4d;
  --primary: #085ca4;
  --primary-bright: #2b8ee0;
  --primary-glow: rgba(43, 142, 224, 0.45);
  --accent: #e0081b;
  --text: #eef5fd;
  --muted: #93a9c2;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --danger: #ff6b6b;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Ambient background */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(43, 142, 224, 0.28), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(224, 8, 27, 0.14), transparent 55%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 55%, #04111f 100%);
}

.app-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
}

.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

/* ---------------- Login ---------------- */

#view-login {
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 36px 34px 28px;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  background: #ffffff;
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.brand-mark img {
  display: block;
  height: 26px;
  width: auto;
}

.brand-text {
  line-height: 1.1;
}

.brand-text strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

a.brand {
  text-decoration: none;
  color: inherit;
}

a.brand:hover .brand-text strong {
  color: var(--primary-bright);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 22px;
  transition: color 0.2s ease, gap 0.2s ease;
}

.back-link:hover {
  color: var(--primary-bright);
  gap: 10px;
}

.login-card h1 {
  margin: 26px 0 6px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 0.95rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-transform: uppercase;
}

input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(4, 12, 24, 0.55);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input::placeholder {
  color: rgba(147, 169, 194, 0.6);
}

input:focus {
  outline: none;
  border-color: var(--primary-bright);
  box-shadow: 0 0 0 4px rgba(43, 142, 224, 0.2);
  background: rgba(4, 12, 24, 0.8);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}

.btn-primary {
  margin-top: 6px;
  padding: 14px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-bright), var(--primary));
  box-shadow: 0 12px 26px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px var(--primary-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

.spinner-inline {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -3px;
  margin-right: 8px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.88rem;
}

.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.login-footer a {
  color: var(--muted);
  text-decoration: none;
}

.login-footer a:hover {
  color: var(--primary-bright);
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 14px;
  font-size: 0.72rem;
}

.legal-links a {
  color: rgba(147, 169, 194, 0.75);
  text-decoration: none;
}

.legal-links a:hover {
  color: var(--primary-bright);
  text-decoration: underline;
}

/* ---------------- Top bar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(5, 13, 24, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar .brand-mark img {
  height: 22px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.user-chip strong {
  font-size: 0.9rem;
}

.user-chip span {
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-ghost {
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ---------------- Dashboard ---------------- */

.dashboard {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 28px 72px;
}

.dashboard h1 {
  font-size: 1.9rem;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
  margin-top: 30px;
}

.game-card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: rgba(43, 142, 224, 0.55);
  box-shadow: 0 26px 60px rgba(8, 92, 164, 0.35);
}

.game-cover {
  height: 150px;
  background:
    radial-gradient(600px 200px at 10% 0%, rgba(43, 142, 224, 0.5), transparent 70%),
    linear-gradient(135deg, #0a2a4a, #061426);
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Line-art simulation icons (see app.js). One colour for every card, set here
   so the whole library can be retinted in a single place. */
.game-cover svg.glyph-icon {
  width: 62px;
  height: 62px;
  color: #a5daff;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
}

/* Fallback for a simulation without an icon: an emoji cannot be tinted, so it
   is only used when no icon is defined. */
.game-cover .glyph {
  font-size: 2.6rem;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
}

.game-body {
  padding: 20px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.game-body h3 {
  margin: 0;
  font-size: 1.15rem;
}

.game-body .version {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-bright);
  font-weight: 700;
}

.game-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  flex: 1;
}

.btn-play {
  margin-top: 6px;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-bright), var(--primary));
  box-shadow: 0 10px 22px var(--primary-glow);
}

.btn-play:hover {
  transform: translateY(-1px);
}

.empty-state {
  margin-top: 30px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
}

/* ---------------- Player ---------------- */

#view-player .topbar {
  position: static;
}

.player-title {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.player-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

#unity-canvas {
  width: min(1280px, 100%);
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: calc(100vh - 140px);
  background: #000;
  border-radius: 14px;
  box-shadow: var(--shadow);
  outline: none;
}

.unity-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  background: rgba(5, 13, 24, 0.72);
  backdrop-filter: blur(3px);
  border-radius: 14px;
  margin: 24px;
}

.unity-loading[hidden] {
  display: none !important;
}

.spinner {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--primary-bright);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.progress-track {
  width: min(420px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-bright), var(--accent));
  transition: width 0.25s ease;
}

.progress-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

#unity-warning {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 90%);
  z-index: 4;
}

#unity-warning > div {
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  background: rgba(43, 142, 224, 0.18);
  border: 1px solid rgba(43, 142, 224, 0.5);
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }

  .dashboard {
    padding: 28px 18px 60px;
  }

  .user-chip span {
    display: none;
  }

  .login-card {
    padding: 28px 22px 22px;
  }
}
