/* Enoch's Arcade. Colours and fonts come from the theme (see js/themes.js). */

:root {
  --bg: #10002b;
  --bg-solid: #10002b;
  --panel: rgba(255,255,255,0.07);
  --panel-border: rgba(255,255,255,0.16);
  --text: #fff;
  --muted: #cdb8ff;
  --accent: #ff3fa4;
  --accent-2: #00f5d4;
  --accent-3: #fee440;
  --on-accent: #1a0033;
  --glow: 0 0 10px #ff3fa4aa;
  --radius: 22px;
  --font-head: 'Bungee', system-ui, sans-serif;
  --font-body: 'Fredoka', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg-solid);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
/* Fixed background layer (background-attachment: fixed is broken on iPhone) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: -2;
  transition: filter .3s;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--accent-3); outline-offset: 3px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding:
    calc(10px + env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(28px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity .3s;
}
body.ready .app { opacity: 1; }
body.playing { overflow: hidden; }
body.playing .app, body.playing #fx { visibility: hidden; }

.panel {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ---------- season banner ---------- */
.season-banner {
  text-align: center;
  font-family: var(--font-head);
  font-size: clamp(1rem, 4.5vw, 1.4rem);
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 999px;
  padding: 8px 16px;
  margin: 4px auto 6px;
  width: fit-content;
  max-width: 100%;
  box-shadow: var(--glow);
  animation: pulse 2s ease-in-out infinite;
}

/* ---------- announcement ---------- */
.announce {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 10px;
  padding: 10px 8px 10px 14px;
  background: var(--accent-3);
  color: #111;
  border-radius: 18px;
  box-shadow: 0 4px 0 #0004;
  animation: pop .35s ease-out;
}
.announce[hidden] { display: none; }
.announce-icon { font-size: 1.6rem; animation: shout 2.4s ease-in-out infinite; transform-origin: 30% 70%; }
.announce-text { flex: 1; margin: 0; font-weight: 700; font-size: 1.02rem; line-height: 1.3; overflow-wrap: anywhere; white-space: pre-line; }
.announce-close { flex: 0 0 auto; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #0000001a; color: #111; font-size: 1rem; }
@keyframes shout { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-14deg) scale(1.15); } 85% { transform: rotate(10deg) scale(1.15); } }

/* ---------- hero ---------- */
.hero { position: relative; text-align: center; padding: 6px 0 4px; }
.theme-btn {
  position: absolute;
  top: 4px;
  right: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
  background: var(--panel);
  font-size: 1.35rem;
  z-index: 2;
  transition: transform .2s;
}
.theme-btn:active { transform: rotate(-20deg) scale(.92); }

/* ---------- theme picker ---------- */
.sheet-wide { max-width: min(560px, calc(100vw - 32px)); }
.theme-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.theme-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: 3px solid transparent;
  border-radius: 18px;
  box-shadow: 0 4px 0 #0005;
  font-size: 1rem;
  line-height: 1.15;
}
.theme-opt .theme-mascot { font-size: 2.2rem; }
.theme-opt.on { border-color: var(--accent-3); box-shadow: 0 0 0 3px var(--accent), 0 4px 0 #0005; }
.theme-opt:active { transform: scale(.95); }
.theme-opt small { font-family: var(--font-body); font-size: .75rem; opacity: .8; }
.mascot-wrap { position: relative; display: inline-block; }
.mascot {
  font-size: clamp(3.4rem, 16vw, 5rem);
  line-height: 1;
  background: none;
  border: 0;
  padding: 4px;
  animation: bob 3s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px #0006);
}
.mascot.jiggle { animation: jiggle .5s; }
body.party .mascot { animation: spin .6s linear infinite; }
.bubble {
  position: absolute;
  left: 100%;
  top: 0;
  white-space: nowrap;
  background: #fff;
  color: #222;
  font-weight: 600;
  font-size: .95rem;
  padding: 7px 12px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 4px 12px #0005;
  animation: pop .25s ease-out;
  z-index: 2;
}
@media (max-width: 520px) {
  .bubble { left: 50%; top: auto; bottom: 100%; transform: translateX(-50%); border-radius: 16px; }
}

.logo {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: clamp(2.3rem, 11vw, 4.6rem);
  line-height: 1.05;
  margin: 4px 0 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.logo .word { display: inline-block; white-space: nowrap; color: var(--accent); text-shadow: var(--glow); }
.logo .word:nth-child(2n) { color: var(--accent-2); }
.logo .letter { display: inline-block; animation: var(--logo-anim, wave) 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 0.09s); }
[data-logo="wave"]    { --logo-anim: wave; }
[data-logo="float"]   { --logo-anim: float; }
[data-logo="bounce"]  { --logo-anim: bounce; }
[data-logo="wobble"]  { --logo-anim: wobble; }
[data-logo="flicker"] { --logo-anim: flicker; }
[data-logo="blink"]   { --logo-anim: blink; }
[data-logo="stomp"]   { --logo-anim: stomp; }
[data-logo="pow"]     { --logo-anim: pow; }
body.party .logo .letter { animation: bounce .5s ease-in-out infinite; animation-delay: calc(var(--i) * 0.04s); }
body.party::before { animation: rainbow 1s linear infinite; }

.tagline { margin: 0 0 14px; color: var(--muted); font-weight: 600; }

/* ---------- joke ---------- */
.joke { padding: 14px 16px 16px; margin: 8px 0 16px; text-align: center; }
.joke-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.joke-label { font-family: var(--font-head); color: var(--accent-3); font-size: .95rem; }
.joke-next { background: none; border: 0; font-size: 1.3rem; padding: 4px; }
.joke-next:active { transform: rotate(180deg); }
.joke-q { font-size: 1.2rem; font-weight: 600; margin: 8px 0 12px; }
.joke-a {
  width: 100%;
  border: 2px dashed var(--accent-2);
  background: transparent;
  border-radius: 14px;
  padding: 12px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent-2);
}
.joke-a.revealed { border-style: solid; background: var(--accent-2); color: var(--on-accent); animation: pop .3s ease-out; }

/* ---------- buttons ---------- */
.actions { display: flex; justify-content: center; margin: 4px 0 18px; }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-head);
  font-size: 1.05rem;
  box-shadow: 0 5px 0 #0005, var(--glow);
  transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #0005; }
.btn-big { font-size: clamp(1.15rem, 5vw, 1.5rem); padding: 14px 30px; }
.btn-alt { background: var(--accent-2); }
.btn[disabled] { opacity: 1; }
.btn-small {
  border: 2px solid var(--panel-border);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
}

/* ---------- spotlight ---------- */
.spotlight {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin: 0 0 18px;
  border-radius: var(--radius);
  background: radial-gradient(circle at 20% 20%, #ffffff40, transparent 60%), var(--c);
  color: #fff;
  box-shadow: 0 8px 0 #0004, var(--glow);
  position: relative;
  overflow: hidden;
}
.spotlight::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, #ffffff55 45%, transparent 60%);
  transform: translateX(-100%);
  animation: shine 4s ease-in-out infinite;
  pointer-events: none;
}
.spot-art { font-size: clamp(3.5rem, 18vw, 6rem); line-height: 1; flex: 0 0 auto; filter: drop-shadow(0 6px 8px #0005); animation: bob 2.5s ease-in-out infinite; }
.spot-art img { width: 110px; height: 110px; object-fit: cover; border-radius: 18px; }
.spot-body { min-width: 0; text-shadow: 0 2px 4px #0006; }
.spot-label { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.spot-title { font-family: var(--font-head); font-size: clamp(1.4rem, 6vw, 2rem); line-height: 1.1; margin: 2px 0 4px; }
.spot-desc { margin: 0 0 10px; font-size: .95rem; }
.spotlight .btn { background: #fff; color: #222; text-shadow: none; }

/* ---------- category chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 2px solid var(--panel-border);
  background: var(--panel);
  border-radius: 999px;
  padding: 7px 15px;
  font-weight: 700;
}
.chip.on { background: var(--accent-2); color: var(--on-accent); border-color: var(--accent-2); }

/* ---------- game grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; } }
.card {
  position: relative;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--panel-border);
  overflow: hidden;
  animation: pop-in .45s cubic-bezier(.2, 1.4, .4, 1) both;
  animation-delay: var(--d);
  transition: transform .15s, box-shadow .15s;
}
.card-play { display: block; width: 100%; border: 0; padding: 0; background: none; text-align: left; }
.card:active { transform: scale(.95); }
@media (hover: hover) {
  .card:hover { transform: translateY(-5px) rotate(var(--tilt)); box-shadow: 0 0 0 3px var(--accent), var(--glow); }
  .card:hover .card-emoji { transform: scale(1.15) rotate(-6deg); }
}
.card-art {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 25%, #ffffff55, transparent 60%), var(--c);
  overflow: hidden;
}
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card-emoji { font-size: clamp(3.2rem, 15vw, 4.6rem); filter: drop-shadow(0 6px 6px #0005); transition: transform .2s; }
.card-body { padding: 10px 12px 12px; }
.card-title { font-family: var(--font-head); font-size: 1.02rem; line-height: 1.15; overflow-wrap: anywhere; }
.card-by { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.badge-new {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent-3);
  color: #111;
  font-weight: 800;
  font-size: .75rem;
  border-radius: 999px;
  padding: 3px 9px;
  transform: rotate(-8deg);
  animation: pulse 1.2s ease-in-out infinite;
  pointer-events: none;
}
.card-share {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: #0006;
  font-size: 1rem;
  display: grid;
  place-items: center;
}
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 1.1rem; padding: 30px 0; }

/* ---------- footer ---------- */
.footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 28px; color: var(--muted); }
.made { font-size: .9rem; }

/* ---------- player ---------- */
.player { position: fixed; inset: 0; z-index: 100; background: #000; width: 100vw; height: 100vh; height: 100dvh; overscroll-behavior: none; }
.player[hidden] { display: none; }
.player-stage, .game-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.player-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-solid);
  color: var(--text);
  z-index: 2;
}
.player-loading[hidden] { display: none; }
.player-loading::before { content: ''; position: absolute; inset: 0; background: var(--bg); z-index: -1; }
.loading-emoji { font-size: 5rem; animation: spin-bounce 1s ease-in-out infinite; }
.loading-title { font-family: var(--font-head); font-size: 1.6rem; text-align: center; padding: 0 20px; }
.loading-dots span { animation: blink 1s infinite; }
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }
.player-start { display: none; margin-top: 10px; }
.needs-tap .player-start { display: inline-block; }
.needs-tap .loading-dots { display: none; }
.needs-tap .loading-emoji { animation: bob 2s ease-in-out infinite; }

.exit {
  position: absolute;
  left: calc(10px + env(safe-area-inset-left));
  top: calc(10px + env(safe-area-inset-top));
  z-index: 3;
  min-width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 23px;
  border: 2px solid #ffffffaa;
  background: #000a;
  color: #fff;
  font-size: 1.3rem;
  opacity: .6;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  transition: opacity .15s, background .15s;
}
.exit.armed { opacity: 1; padding: 0 16px; background: var(--accent); color: var(--on-accent); font-family: var(--font-head); font-size: 1.05rem; animation: pop .2s ease-out; }

/* ---------- share sheet ---------- */
.sheet { border: 0; padding: 0; background: transparent; color: var(--text); max-width: min(380px, calc(100vw - 32px)); width: 100%; }
.sheet::backdrop { background: #000a; backdrop-filter: blur(3px); }
.sheet-inner {
  position: relative;
  background: var(--bg-solid);
  border: 3px solid var(--accent);
  border-radius: 26px;
  padding: 22px 18px 18px;
  text-align: center;
  box-shadow: var(--glow);
}
.sheet[open] .sheet-inner { animation: pop .25s ease-out; }
.sheet-title { font-family: var(--font-head); font-size: 1.4rem; padding: 0 30px; }
.sheet-sub { color: var(--muted); margin: 4px 0 12px; }
.qr { background: #fff; color: #333; border-radius: 16px; padding: 10px; width: min(240px, 70vw); aspect-ratio: 1; margin: 0 auto 14px; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; }
.sheet-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sheet-buttons .btn { font-size: .95rem; padding: 10px 16px; }
.sheet-close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 1.3rem; }

/* ---------- iPhone install hint ---------- */
.ios-hint {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  gap: 12px;
  align-items: center;
  background: #fff;
  color: #222;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 30px #0008;
  animation: slide-up .35s ease-out;
  font-size: .95rem;
}
.ios-hint[hidden] { display: none; }
.ios-hint-text strong:first-child { display: block; margin-bottom: 2px; }
.ios-share { color: #007aff; vertical-align: -3px; }
.ios-hint .btn-small { background: #222; color: #fff; border: 0; flex: 0 0 auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, calc(100% + 60px));
  visibility: hidden;
  background: var(--accent-3);
  color: #111;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 200;
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- theme extras ---------- */
[data-theme="retro"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background: repeating-linear-gradient(transparent 0 2px, #0000002e 2px 4px);
}
[data-theme="retro"] .logo { font-size: clamp(1.6rem, 8vw, 3.4rem); line-height: 1.4; }
[data-theme="retro"] .card-title, [data-theme="retro"] .btn, [data-theme="retro"] .season-banner, [data-theme="retro"] .joke-label { font-size: .8rem; line-height: 1.5; }
[data-theme="retro"] { --radius: 4px; }
[data-theme="hero"] .card, [data-theme="hero"] .panel { border-width: 3px; box-shadow: 5px 5px 0 #000; }
[data-theme="candy"] .card-share, [data-theme="silly"] .card-share { background: #ffffffcc; }
[data-theme="silly"] .card, [data-theme="silly"] .panel { border-width: 3px; box-shadow: 4px 4px 0 #2b2d42; }

/* ---------- animations ---------- */
@keyframes wave    { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-10px); } }
@keyframes float   { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes bounce  { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-14px) scale(1.08, .95); } 60% { transform: translateY(0) scale(.95, 1.05); } }
@keyframes wobble  { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.08); } }
@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: .2; } 95% { opacity: 1; } 97% { opacity: .4; } }
@keyframes blink   { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .25; } }
@keyframes stomp   { 0%, 80%, 100% { transform: translateY(0); } 85% { transform: translateY(-12px) rotate(-4deg); } 90% { transform: translateY(2px) scale(1.1, .9); } }
@keyframes pow     { 0%, 85%, 100% { transform: scale(1) rotate(0); } 90% { transform: scale(1.3) rotate(-8deg); } }
@keyframes bob     { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes jiggle  { 0%, 100% { transform: rotate(0) scale(1); } 20% { transform: rotate(-15deg) scale(1.2); } 40% { transform: rotate(12deg) scale(1.15); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes spin-bounce { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-16px) rotate(180deg); } }
@keyframes pulse   { 0%, 100% { transform: scale(1) rotate(var(--r, 0deg)); } 50% { transform: scale(1.06) rotate(var(--r, 0deg)); } }
.badge-new { --r: -8deg; }
@keyframes pop     { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pop-in  { from { transform: scale(.5) translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shine   { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes rainbow { to { filter: hue-rotate(360deg); } }
@keyframes slide-up { from { transform: translateY(120%); } to { transform: none; } }
.bubble { animation-name: pop; }
@media (max-width: 520px) { .bubble { animation: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition: none !important; }
}
