/* ==========================================================================
   Tunghlwm — shared theme
   Dark, minimal, no dependencies. Edit freely.
   ========================================================================== */

:root {
  --bg: #0e0e13;
  --bg-glow: #241a29;
  --bg-glow-2: #1b1b2c;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);
  --text: #f2eef5;
  --muted: #a49cae;
  --faint: #6f6878;
  --accent: #a78bfa;
  --accent-2: #6d5ae8;
  --danger: #f87171;
  --ok: #4ade80;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

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

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 700px at 15% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 600px at 90% 0%, var(--bg-glow-2), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

a { color: var(--accent); }

::selection { background: rgba(167, 139, 250, 0.35); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

.container { width: min(1100px, 100% - 2.5rem); margin-inline: auto; }

/* --------------------------------------------------------------------------
   Header / footer
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(14, 14, 19, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.8);
}

.site-nav { display: flex; gap: 4px; }

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a.active { color: var(--text); background: var(--surface-2); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 3rem;
  color: var(--faint);
  font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero { padding: 4.5rem 0 2.5rem; }

.hero h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  max-width: 48ch;
  color: var(--muted);
  font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   Game grid
   -------------------------------------------------------------------------- */

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
  padding-bottom: 1rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.card-cover {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
}

.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-initial {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: rgba(255, 255, 255, 0.88);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  padding: 0.95rem 1rem 1rem;
}

.card-body h3 { margin: 0; font-size: 1.02rem; letter-spacing: -0.01em; }

.card-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  margin-top: auto;
  padding-top: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.chip {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 999px;
}

.play-pill { font-size: 0.85rem; font-weight: 600; color: var(--accent); white-space: nowrap; }
.game-card:hover .play-pill { color: #c9bdfd; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #8b7cf6, var(--accent-2));
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover { background: linear-gradient(180deg, #9a8cff, #7a68f5); border-color: transparent; }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); }

.btn-sm { font-size: 0.8rem; padding: 0.4rem 0.65rem; }
.btn-icon { padding: 0.4rem 0.55rem; font-size: 0.9rem; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { resize: vertical; min-height: 2.6rem; }

::placeholder { color: var(--faint); }

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18);
}

input:disabled { opacity: 0.6; cursor: not-allowed; }

input[type="checkbox"],
input[type="radio"] { accent-color: var(--accent); }

input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  margin-right: 0.7rem;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover { background: rgba(255, 255, 255, 0.14); }

.field { margin-bottom: 1rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.hint { font-size: 0.78rem; color: var(--muted); margin: 0.3rem 0 0; }
.opt { color: var(--faint); font-weight: 400; }
.error-text { color: var(--danger); font-size: 0.85rem; margin: 0 0 0.8rem; }

.notice {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.hint code,
.notice code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.9em;
  word-break: break-all;
}

label.checkbox,
label.radio {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  margin: 0;
  cursor: pointer;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem 1rem;
  margin: 0 0 1rem;
}

legend { font-size: 0.82rem; color: var(--muted); padding: 0 0.35rem; }

.radio-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.8rem; }

.source-wrap { margin-top: 0.4rem; }

.cover-preview-wrap { display: flex; align-items: center; gap: 1rem; margin-top: 0.7rem; }

.cover-preview-wrap img {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Dialog
   -------------------------------------------------------------------------- */

dialog {
  border: 1px solid var(--border-strong);
  background: #16161d;
  color: var(--text);
  border-radius: var(--radius);
  padding: 0;
  width: min(620px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(5, 5, 9, 0.65);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }

.dialog-body { padding: 1.25rem; max-height: min(68vh, 620px); overflow-y: auto; }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */

.auth-card {
  max-width: 380px;
  margin: 5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.auth-card h1 { margin: 0 0 0.3rem; font-size: 1.35rem; letter-spacing: -0.02em; }
.auth-card .hint { margin-bottom: 1.4rem; }

.admin-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 3rem 0 1.5rem;
}

.admin-toolbar h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }
.admin-toolbar-actions { display: flex; gap: 0.6rem; }

.admin-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
}

.admin-thumb {
  width: 72px;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}

.admin-main { min-width: 0; }
.admin-main h4 { margin: 0 0 0.15rem; font-size: 0.95rem; }

.admin-meta {
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-actions { display: flex; gap: 0.4rem; }

.pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.pill-on { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.08); }
.pill-off { color: #f0a35e; border-color: rgba(240, 163, 94, 0.35); background: rgba(240, 163, 94, 0.08); }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: rgba(240, 163, 94, 0.08);
  border: 1px solid rgba(240, 163, 94, 0.35);
  color: #f0c9a0;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.banner strong { color: #f6d9bb; }

.panel {
  margin-top: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel h2 { margin: 0 0 0.35rem; font-size: 1.05rem; letter-spacing: -0.01em; }
.panel .hint { margin-bottom: 1rem; }
.panel-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.qr-wrap {
  background: #fff;
  border-radius: 12px;
  padding: 0.75rem;
  width: max-content;
  margin: 0.5rem auto 1rem;
}

.qr-wrap img { display: block; width: 180px; height: 180px; }

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

body.player-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 14, 19, 0.8);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.player-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-frame-wrap { flex: 1; position: relative; background: #000; }

.player-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  background: var(--bg);
}

/* --------------------------------------------------------------------------
   Status, toast, skeleton
   -------------------------------------------------------------------------- */

.status {
  color: var(--muted);
  text-align: center;
  padding: 3rem 0;
  font-size: 0.95rem;
}

.status code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.85em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  background: #1d1d26;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  max-width: min(90vw, 440px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(74, 222, 128, 0.45); }
.toast.error { border-color: rgba(248, 113, 113, 0.5); }

.skeleton-card {
  height: 235px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0.03) 40%,
    rgba(255, 255, 255, 0.07) 50%,
    rgba(255, 255, 255, 0.03) 60%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 620px) {
  .hero { padding: 3rem 0 2rem; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-toolbar { padding-top: 2.2rem; }
  .admin-row { grid-template-columns: 56px 1fr; }
  .admin-thumb { width: 56px; }
  .admin-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .player-title { font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
