@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap");

/* ===============================
   Theme (ONE source of truth)
   =============================== */
:root{
  --bg0:#05070d;
  --bg1:#0a0f1f;

  --panelA: rgba(11,17,36,.88);
  --panelB: rgba(7,10,24,.94);

  --text:#e9edff;
  --muted:#9aa6d8;

  --accent:#7a6cff;
  --accent2:#4dd9ff;

  --shadow: 0 20px 55px rgba(0,0,0,.60);
  --shadow2: 0 12px 30px rgba(0,0,0,.40);

  --radius: 18px;
}

/* ===============================
   Base / Layout
   =============================== */
*{ box-sizing: border-box; }

body{
  margin:0;
  min-height:100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);

  font-size: clamp(14px, 1.6vw, 16px);
  padding: clamp(18px, 3vw, 44px) clamp(12px, 3vw, 20px);

  display:flex;
  flex-direction: column;
  align-items:center;

  background:
    radial-gradient(circle at 20% 25%, rgba(122,108,255,.18), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(77,217,255,.14), transparent 60%),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.03), transparent 70%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

/* Subtle cursed motion overlay */
body::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 20%, rgba(122,108,255,.10), transparent 55%),
    radial-gradient(circle at 70% 75%, rgba(77,217,255,.08), transparent 60%),
    linear-gradient(180deg, rgba(5,7,13,.35), rgba(5,7,13,.55));
  opacity: .9;
  z-index: 0;
  animation: cursedFog 22s ease-in-out infinite alternate;
}

@keyframes cursedFog{
  0%{ filter: hue-rotate(0deg); opacity: .85; }
  100%{ filter: hue-rotate(10deg); opacity: 1; }
}

body > *{ position: relative; z-index: 1; }

h1{
  margin: 0 0 22px;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: .5px;
  text-align: center;
  text-shadow:
    0 14px 45px rgba(0,0,0,.70),
    0 0 18px rgba(122,108,255,.18),
    0 0 14px rgba(77,217,255,.14);
}

h2{
  margin: 10px 0 8px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .2px;
}

/* Reusable “panel” look */
.panel{
  background: linear-gradient(180deg, var(--panelA), var(--panelB));
  border: 1px solid rgba(122,108,255,.18);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

/* ===============================
   Main Menu (Minigame Hub)
   =============================== */
#menu{
  width: min(980px, 100%);
  margin-top: 12px;
}

.menu-grid{
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.menu-tile{
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border-radius: var(--radius);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow2);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.menu-tile:hover{
  transform: translateY(-2px);
  box-shadow:
    0 16px 38px rgba(0,0,0,.55),
    0 0 0 1px rgba(122,108,255,.18);
  filter: brightness(1.03);
}

.menu-tile.disabled{
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

.tile-title{
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 6px;
}

.tile-sub{
  color: var(--muted);
  font-weight: 650;
  line-height: 1.3;
}

/* Topbar */
.topbar{
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.topbar-title{
  font-weight: 900;
  letter-spacing: .2px;
  opacity: 0.95;
  text-align: center;
}

.ghost-btn{
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
  justify-self: start;
}
.ghost-btn:hover{
  transform: translateY(-1px);
  filter: brightness(1.04);
}

/* ===============================
   Hub + playable list
   =============================== */
#hub{
  width: min(980px, 100%);
  display:flex;
  flex-direction: column;
  align-items:center;
  gap: 18px;

  padding: 22px;
  background: linear-gradient(180deg, var(--panelA), var(--panelB));
  border: 1px solid rgba(122,108,255,.18);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

#daily-btn{
  appearance:none;
  border: 0;
  padding: 14px 22px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 16px;
  color: #05070d;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 14px 32px rgba(122,108,255,.25), 0 10px 24px rgba(77,217,255,.18);
  cursor:pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
#daily-btn:hover{
  transform: translateY(-1px);
  filter: brightness(1.05);
}
#daily-btn:active{ transform: translateY(0px) scale(.99); }

.playable-container{
  width:100%;
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 18px;
  justify-items: center;
  align-items: center;
  margin-top: 4px;
}

.playable-card{
  width:100%;
  height: 96px;
  border: 0;
  padding: 0;
  border-radius: 16px;
  overflow:hidden;
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow2);
  cursor:pointer;
  position:relative;
  transition: transform .18s ease, box-shadow .18s ease;
}
.playable-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(0,0,0,.50);
}

.playable-thumb{
  width:100%;
  height:100%;
  object-fit: cover;
  filter: blur(12px) brightness(.70) saturate(.85);
  transform: scale(1.06);
}

.playable-badge{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 34px;
  font-weight: 900;
  color: rgba(255,255,255,.88);
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.10), rgba(0,0,0,.30));
  text-shadow: 0 10px 25px rgba(0,0,0,.60);
  pointer-events:none;
}

/* Completed reveal */
.playable-card.completed .playable-thumb{
  filter: none;
  transform: none;
}
.playable-card.completed .playable-badge{
  background: rgba(0, 0, 0, 0.35);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.3px;
}
.playable-card.completed .playable-badge::before{
  content: "✓ Completed";
}

/* ===============================
   Game card
   =============================== */
#game-card{
  width: min(720px, 100%);
  padding: 26px;
  text-align:center;
  position: relative;

  background: linear-gradient(180deg, var(--panelA), var(--panelB));
  border: 1px solid rgba(122,108,255,.18);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

#image-container{
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(360px, 52vh);
  margin: 10px auto 18px;
  overflow:hidden;
  border-radius: 18px;
  background: rgba(0,0,0,.25);
  box-shadow: 0 14px 35px rgba(0,0,0,.45);
  display:flex;
  align-items:center;
  justify-content:center;
  border: 1px solid rgba(255,255,255,.08);
}

#frame{
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
  clip-path: inset(30% 30% 30% 30%);
  transition: clip-path .35s ease, opacity .12s ease;
}

#frame.is-loading{ opacity: 0; }

/* Controls row */
.controls{
  display:flex;
  gap: 12px;
  justify-content:center;
  align-items:center;
  flex-wrap: wrap;
  margin-top: 4px;
}

#guess{
  width: min(520px, 100%);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(122,108,255,.35);
  background: rgba(5,7,13,.55);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
#guess::placeholder{ color: rgba(233,237,255,.55); }
#guess:focus{
  border-color: rgba(77,217,255,.65);
  box-shadow: 0 0 0 4px rgba(77,217,255,.18);
}

#submit, #skip{
  appearance:none;
  border:0;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 900;
  color: #05070d;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  cursor:pointer;
  transition: transform .15s ease, filter .15s ease, box-shadow .15s ease;
  box-shadow: 0 14px 32px rgba(122,108,255,.25), 0 10px 24px rgba(77,217,255,.18);
  min-width: 92px;
}
#submit:hover, #skip:hover{
  transform: translateY(-1px);
  filter: brightness(1.05);
}
#submit:active, #skip:active{ transform: translateY(0px) scale(.99); }

#status{
  margin: 14px 0 10px;
  min-height: 22px;
  color: var(--muted);
  font-weight: 700;
}

#back-btn{
  appearance:none;
  border: 0;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 800;
  color: var(--text);
  background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.12);
  cursor:pointer;
  transition: transform .15s ease, filter .15s ease;
}
#back-btn:hover{ transform: translateY(-1px); filter: brightness(1.05); }
#back-btn:active{ transform: translateY(0px) scale(.99); }

/* Animations */
@keyframes shake{
  0%{ transform: translateX(0); }
  25%{ transform: translateX(-6px); }
  50%{ transform: translateX(6px); }
  75%{ transform: translateX(-4px); }
  100%{ transform: translateX(0); }
}
.shake{ animation: shake .45s; }

.correct-glow{
  box-shadow:
    0 0 30px rgba(108,255,201,.30),
    0 0 70px rgba(77,217,255,.20);
}

/* ===============================
   Win/Lose FX overlays
   =============================== */
#fx-win, #fx-lose{
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 9999;
}

#fx-win.active{
  opacity: 1;
  animation: winFlash 650ms ease-out forwards;
  background:
    radial-gradient(circle at 50% 55%, rgba(77,217,255,.22), transparent 55%),
    radial-gradient(circle at 50% 55%, rgba(122,108,255,.18), transparent 65%);
}

#fx-win::before{
  content:"";
  position:absolute;
  inset:-10%;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 55%, transparent 0 35%, rgba(77,217,255,.25) 36%, transparent 48%);
  filter: blur(1px);
}

#fx-win.active::before{
  opacity: 1;
  animation: winRing 700ms ease-out forwards;
}

@keyframes winFlash{
  0%{ opacity: 0; transform: scale(0.98); }
  12%{ opacity: 1; }
  100%{ opacity: 0; transform: scale(1); }
}

@keyframes winRing{
  0%{ transform: scale(0.6); opacity: 0.0; }
  25%{ opacity: 1; }
  100%{ transform: scale(1.25); opacity: 0; }
}

#fx-lose.active{
  opacity: 1;
  animation: loseFlash 700ms ease-out forwards;
  background:
    radial-gradient(circle at 50% 55%, rgba(0,0,0,.55), rgba(0,0,0,.85)),
    linear-gradient(120deg, transparent 0 45%, rgba(255,61,46,.18) 48%, transparent 54%),
    linear-gradient(120deg, transparent 0 52%, rgba(255,61,46,.22) 55%, transparent 61%);
}

@keyframes loseFlash{
  0%{ opacity: 0; }
  15%{ opacity: 1; }
  100%{ opacity: 0; }
}

.win-pop{ animation: winPop 420ms ease-out; }
@keyframes winPop{
  0%{ transform: scale(1); }
  35%{ transform: scale(1.02); }
  100%{ transform: scale(1); }
}

.lose-dim{
  filter: grayscale(.25) brightness(.9);
  transition: filter .25s ease;
}

/* ===============================
   Mobile tweaks
   =============================== */
@media (max-width: 520px){
  #hub{ padding: 16px; }
  #game-card{ padding: 16px; }

  .controls{ gap: 10px; }

  #submit, #skip{
    flex: 1;
  }

  #guess{
    flex: 1 1 100%;
  }

  .playable-container{
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .playable-card{
    height: 88px;
  }
}
/* Anti-cheese: disable selection & dragging */
#frame,
.playable-thumb {
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: auto;
}
