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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0a0e2a;
}

/* ── Sky canvas ─────────────────────────────────────────── */

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* ── Panel ──────────────────────────────────────────────── */

#panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;

  padding: 1.75rem 1.5rem 1.25rem;
  border-radius: 20px 20px 0 0;

  color: #fff;
  background: rgba(0, 0, 0, 0.28);
}

@supports (backdrop-filter: blur(1px)) {
  #panel {
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    background: rgba(0, 0, 0, 0.18);
  }
}

/* Landscape / tablet card layout */
@media (min-width: 768px) and (orientation: landscape) {
  #panel {
    left: 1.75rem;
    right: auto;
    bottom: 1.75rem;
    width: 360px;
    max-height: 82vh;
    border-radius: 20px;
  }
}

/* ── Typography ─────────────────────────────────────────── */

.heading {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: normal;
  line-height: 1.2;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  margin-bottom: 0.35rem;
}

.subheading {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  font-weight: 300;
  opacity: 0.9;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
  margin-bottom: 0.2rem;
}

/* ── Countdown ──────────────────────────────────────────── */

#countdown-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.2);
}

#countdown-block[hidden] {
  display: none;
}

.countdown-label {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: clamp(0.78rem, 2.5vw, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
  margin-bottom: 0.3rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.countdown-timer {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
  letter-spacing: 0.02em;
}

/* ── Footer timestamp ───────────────────────────────────── */

/* ── Modals ─────────────────────────────────────────────── */

dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(420px, 92vw);
  width: 100%;
  /* Restore centering removed by the * { margin:0 } reset.
     position:fixed + inset:0 + margin:auto centers on all viewports. */
  position: fixed;
  inset: 0;
  margin: auto;
  max-height: 90vh;
  overflow-y: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  padding: 2rem 1.75rem 1.75rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0, 0, 0, 0.38);
  color: #fff;
}

@supports (backdrop-filter: blur(1px)) {
  .modal-box {
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
    background: rgba(0, 0, 0, 0.25);
  }
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  transition: color 0.15s;
}

.modal-close:hover {
  color: #fff;
}

.modal-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: normal;
  margin-bottom: 1.4rem;
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
}

.modal-label {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.65;
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}

.modal-label:first-of-type {
  margin-top: 0;
}

.modal-optional {
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
  font-size: 0.7rem;
}

.modal-input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.modal-input::placeholder {
  color: rgba(255,255,255,0.3);
}

.modal-input:focus {
  border-color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.13);
}

.modal-error {
  margin-top: 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.82rem;
  color: #ffb3b3;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.modal-error[hidden] {
  display: none;
}

.modal-btn {
  display: block;
  width: 100%;
  margin-top: 1.4rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.modal-btn:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.5);
}

.modal-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.modal-switch {
  margin-top: 1.1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.82rem;
  opacity: 0.6;
  text-align: center;
}

.modal-link {
  background: none;
  border: none;
  color: #fff;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  opacity: 1;
  padding: 0;
}

/* ── Gallery modal ──────────────────────────────────────── */

#modal-gallery {
  max-width: min(680px, 96vw);
}

.gallery-box {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.gallery-box .modal-title {
  flex-shrink: 0;
}

#gallery-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
  padding-right: 0.25rem;
}

@media (max-width: 480px) {
  #gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}

.gallery-item:hover {
  transform: scale(1.04);
  border-color: rgba(255,255,255,0.35);
}

.gallery-item-error {
  opacity: 0.35;
  cursor: default;
}

.gallery-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-status {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.55);
  text-align: center;
  padding: 2rem 0;
}

.gallery-status-error { color: #ffb3b3; }

#gallery-lightbox {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  cursor: zoom-out;
}

#gallery-lightbox[hidden] { display: none; }

#gallery-lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* ── Snap modal ─────────────────────────────────────────── */

#modal-snap {
  max-width: min(480px, 96vw);
  width: 100%;
  border: none;
  padding: 0;
  background: transparent;
}

.snap-box {
  position: relative;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.7);
  overflow: hidden;
}

@supports (backdrop-filter: blur(1px)) {
  .snap-box {
    backdrop-filter: blur(28px) saturate(1.4);
    -webkit-backdrop-filter: blur(28px) saturate(1.4);
  }
}

.snap-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  z-index: 10;
  background: rgba(0,0,0,0.4);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snap-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  overflow: hidden;
}

#snap-video,
#snap-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#snap-preview[hidden],
#snap-canvas[hidden] {
  display: none;
}

.snap-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem 1.5rem;
}

.snap-status {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  min-height: 1.1em;
  text-align: center;
}

.snap-status.snap-ok    { color: #a8f0b8; }
.snap-status.snap-error { color: #ffb3b3; }

.snap-shutter {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  position: relative;
}

.snap-shutter::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #fff;
  transition: background 0.15s;
}

.snap-shutter:hover {
  background: rgba(255,255,255,0.25);
}

.snap-shutter:active {
  transform: scale(0.93);
}

.snap-shutter:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

/* ── Game launcher modal ────────────────────────────────── */

#modal-game-launcher {
  max-width: min(380px, 92vw);
}

.launcher-box {
  padding-bottom: 1.25rem;
}

#launcher-list {
  list-style: none;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.launcher-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  transition: background 0.15s, border-color 0.15s;
}

.launcher-item:hover {
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.28);
}

.launcher-item-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
}

.launcher-item-name {
  font-size: 1rem;
  font-weight: 500;
}

.launcher-item-desc {
  font-size: 0.78rem;
  opacity: 0.6;
  margin-top: 0.15rem;
}

/* ── Game play modal (full-screen) ──────────────────────── */

#modal-game-play {
  max-width: 100vw;
  width: 100vw;
  max-height: 100vh;
  height: 100dvh;
  margin: 0;
  inset: 0;
  background: #0a0e2a;
  overflow: hidden;
}

#game-play-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-play-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
}

.game-play-close:hover { color: #fff; }

#game-over-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.72);
  z-index: 150;
}

#game-over-overlay[hidden] { display: none; }

#game-over-msg {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  color: #fff;
  text-shadow: 0 2px 16px rgba(0,0,0,0.7);
  text-align: center;
  padding: 1.5rem 2rem;
}

/* ── Game countdown overlay ─────────────────────────────── */

#game-countdown {
  position: absolute;
  inset: 0;
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#game-countdown-num {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(6rem, 28vw, 14rem);
  color: #fff;
  text-shadow: 0 4px 40px rgba(0,0,0,0.6);
  line-height: 1;
  will-change: opacity;
}

/* ── Button Game ────────────────────────────────────────── */

.btngame-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.btngame-score {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 1;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
  min-width: 3ch;
  text-align: center;
}

.btngame-controls {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.btngame-btn {
  width: clamp(56px, 14vw, 72px);
  height: clamp(56px, 14vw, 72px);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btngame-btn:hover  { background: rgba(255,255,255,0.22); }
.btngame-btn:active { transform: scale(0.92); }

.btngame-finish {
  padding: 0.65rem 2rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
  width: clamp(56px, 14vw, 72px);
  height: clamp(56px, 14vw, 72px);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.7rem, 2.5vw, 0.85rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btngame-finish:hover { background: rgba(255,255,255,0.22); }

/* ── Games button ───────────────────────────────────────── */

#games-menu {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
}

#games-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.28);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

@supports (backdrop-filter: blur(1px)) {
  #games-btn {
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    background: rgba(0,0,0,0.18);
  }
}

#games-btn:hover {
  background: rgba(255,255,255,0.15);
}

#games-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: block;
  transition: opacity 0.4s ease;
}

/* ── User menu ──────────────────────────────────────────── */

#user-menu {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
}

#user-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.28);
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

@supports (backdrop-filter: blur(1px)) {
  #user-btn {
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    background: rgba(0,0,0,0.18);
  }
}

#user-btn:hover {
  background: rgba(255,255,255,0.15);
}

#user-dropdown {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 140px;
  list-style: none;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.45);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

@supports (backdrop-filter: blur(1px)) {
  #user-dropdown {
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    background: rgba(0,0,0,0.28);
  }
}

#user-dropdown[hidden] {
  display: none;
}

#user-dropdown li {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

#user-dropdown li:last-child {
  border-bottom: none;
}

#user-dropdown button {
  width: 100%;
  padding: 0.65rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

#user-dropdown button:hover {
  background: rgba(255,255,255,0.1);
}

#user-dropdown .menu-divider {
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

#user-dropdown .menu-label {
  padding: 0.4rem 1rem 0.2rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.45;
  color: #fff;
}

/* ── Footer timestamp ───────────────────────────────────── */

footer {
  margin-top: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.72rem;
  opacity: 0.45;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
