/* Random Wheel: a haunted house. The wheel and the butler are placed by js/main.js. */

@font-face {
  font-family: "Creepster";
  src: url("data/fonts/Creepster-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --gold: #a8f0b4;
  --gold-deep: #3f8f5c;
  --red: #a11d33;
  --plum: #120b1c;
  --panel: rgba(18, 11, 28, .9);
  --show: "Creepster", "Arial Black", "Segoe UI Black", Arial, sans-serif;
  --body: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--plum);
  color: #fff;
  font: 16px/1.35 var(--body);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- the names panel ---------- */

#panel {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 14px;
  background:
    radial-gradient(circle at 50% -10%, rgba(110, 230, 150, .22), transparent 60%),
    linear-gradient(180deg, #2a1838, #120b1c);
  border-right: 4px solid var(--gold-deep);
  box-shadow: inset -2px 0 0 #1c3a2a, 6px 0 24px rgba(0, 0, 0, .6);
  overflow-y: auto;
  z-index: 2;
}
body.panel-hidden #panel { display: none; }

.marquee {
  margin: 0 0 4px;
  padding: 10px 8px 12px;
  text-align: center;
  font: 42px/1 var(--show);
  letter-spacing: .03em;
  text-transform: uppercase;
  border-radius: 14px;
  background: linear-gradient(180deg, #2c1a3e, #150c20);
  border: 3px solid var(--gold-deep);
  /* a row of ghost lights round the sign */
  box-shadow: 0 0 0 4px #150c20, 0 0 0 6px var(--gold-deep), 0 0 22px rgba(120, 240, 160, .35), 0 8px 18px rgba(0, 0, 0, .5);
  position: relative;
}
.marquee span {
  display: block;
  background: linear-gradient(180deg, #f0ffe8 10%, #9ff0a8 55%, #3fae62 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #0b2415);
}
.marquee::before, .marquee::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px;
  height: 6px;
  background: radial-gradient(circle, #d6ffdc 0 2.4px, transparent 3px) 0 0 / 16px 6px repeat-x;
  animation: bulbs 0.9s steps(2) infinite;
}
.marquee::before { top: 3px; }
.marquee::after { bottom: 3px; animation-delay: .45s; }
@keyframes bulbs { 50% { opacity: .35; } }

.label { font-weight: bold; color: var(--gold); }
#names {
  width: 100%;
  min-height: 160px;
  flex: 1 1 auto;
  resize: none;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--gold-deep);
  background: rgba(234, 228, 208, .96);
  color: #1c1226;
  font: 18px/1.35 var(--body);
}
#names:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.note { margin: 0; font-size: 14px; color: #d8d0e4; min-height: 1.3em; }
.note.warn { color: var(--gold); font-weight: bold; }

.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chip {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, #3a2650, #1d1228);
  font-weight: bold;
  user-select: none;
}
.chip:hover { filter: brightness(1.15); }
.chip:disabled { opacity: .45; filter: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--gold); margin: 0; }

.spin {
  margin-top: 4px;
  padding: 14px 18px 16px;
  font: 42px/1 var(--show);
  letter-spacing: .04em;
  color: #fff;
  text-shadow: 0 3px 0 #0e3320;
  border-radius: 18px;
  border: 3px solid #c8ffd2;
  background: linear-gradient(180deg, #5fd184 0%, #2e9a58 45%, #146338 100%);
  box-shadow: 0 7px 0 #0e3320, 0 12px 24px rgba(0, 0, 0, .45), inset 0 2px 0 rgba(255, 255, 255, .4);
  transition: transform .08s, box-shadow .08s;
}
.spin:hover:not(:disabled) { filter: brightness(1.08); }
.spin:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 #0e3320, 0 6px 14px rgba(0, 0, 0, .45); }
.spin:disabled { filter: grayscale(.7) brightness(.8); }
.spin.small { font-size: 26px; padding: 10px 18px 12px; flex: 1 1 0; min-width: 8em; }
.spin.alt {
  text-shadow: 0 3px 0 #2a0636;
  background: linear-gradient(180deg, #9a4fd0 0%, #6a1a9a 45%, #3e0a5e 100%);
  box-shadow: 0 7px 0 #2a0636, 0 12px 24px rgba(0, 0, 0, .45), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.spin.alt:active:not(:disabled) { box-shadow: 0 2px 0 #2a0636, 0 6px 14px rgba(0, 0, 0, .45); }
.keys { margin: 0; font-size: 12px; color: #b4a8c4; text-align: center; }

/* ---------- the stage ---------- */

#stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: #0c0814 url("data/bg/haunted.webp") center bottom / cover no-repeat;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
#wheel { position: absolute; left: 0; top: 0; }
#butler {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  pointer-events: none;
  background-repeat: no-repeat;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .5));
}
/* until js/main.js sizes and places him */
#butler:not(.placed) { visibility: hidden; }
/* lightning: the whole stage flashes */
#flash {
  position: absolute;
  inset: 0;
  background: #e8f0ff;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
/* the Haunting: the room goes dark round the ghosts */
#dark {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 40% 45%, rgba(4, 3, 12, .72), rgba(2, 1, 6, .96));
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
.ghost {
  position: absolute;
  left: 0; top: 0;
  display: none;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 16px rgba(170, 255, 200, .75));
  will-change: transform, opacity;
}

.corner { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; z-index: 3; }
.corner button {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(18, 11, 28, .8);
  font-size: 20px;
}
#mute .off, body.muted #mute .on { display: none; }
body.muted #mute .off { display: inline; }

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

/* ---------- the winner ---------- */

#win {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle, rgba(10, 8, 24, .3), rgba(4, 2, 10, .7));
  z-index: 4;
  animation: fade-in .3s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }

/* ---------- choosing the look, as the page opens ---------- */
#skins {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 4, 16, .88);
  z-index: 6;
  overflow-y: auto;
}
#skins[hidden] { display: none; }
.skins-box { text-align: center; max-width: 900px; width: 100%; }
#skins h2 {
  margin: 0 0 18px;
  font: clamp(30px, 6vw, 56px)/1 var(--show);
  color: var(--gold);
  text-shadow: 0 0 18px rgba(120, 240, 160, .45);
}
.skins-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
#skins button {
  display: block;
  padding: 10px;
  border: 3px solid var(--gold-deep);
  border-radius: 14px;
  background: var(--panel);
  color: #fff;
  font: 26px/1.2 var(--show);
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
#skins button:hover, #skins button:focus-visible { transform: scale(1.03); border-color: var(--gold); outline: none; }
#skins button.last { border-color: var(--gold); }
#skins img { display: block; width: 100%; aspect-ratio: 6 / 5; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
.banner {
  position: relative;
  width: min(92vw, 900px);
  padding: 22px 30px 18px;
  text-align: center;
  border-radius: 26px;
  background: linear-gradient(180deg, #2c1a3e, #150c20 75%);
  border: 4px solid var(--gold-deep);
  box-shadow: 0 0 0 6px #150c20, 0 0 0 9px var(--gold-deep), 0 0 70px rgba(120, 240, 160, .5), 0 20px 50px rgba(0, 0, 0, .6);
  animation: pop-in .55s cubic-bezier(.2, 1.6, .4, 1);
}
.banner::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 20px;
  pointer-events: none;
  background:
    radial-gradient(circle, #d6ffdc 0 3px, transparent 3.6px) 0 0 / 22px 22px repeat-x,
    radial-gradient(circle, #d6ffdc 0 3px, transparent 3.6px) 0 100% / 22px 22px repeat-x;
  animation: bulbs .7s steps(2) infinite;
}
@keyframes pop-in { from { transform: scale(.3) rotate(-6deg); opacity: 0; } }
/* one line, shrunk to fit by js/main.js; the tall line box and padding keep the dips of
   g, j, p and y inside the box the gradient is clipped to */
#winner {
  margin: 4px 0 14px;
  padding: 0 .06em .08em;
  font: clamp(44px, 11vw, 120px)/1.3 var(--show);
  white-space: nowrap;
  background: linear-gradient(180deg, #f4ffee 15%, #a6f2ae 55%, #3fae62 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 #0b2415) drop-shadow(0 0 22px rgba(130, 245, 165, .55));
}
.banner .row { max-width: 640px; margin: 0 auto; }

/* ---------- phones held upright: the stage on top, the names below ---------- */

@media (max-width: 760px) and (orientation: portrait) {
  body { overflow: auto; }
  #app { flex-direction: column; height: auto; min-height: 100dvh; }
  #stage { flex: 0 0 auto; height: 64vh; height: 64svh; order: 1; }
  #panel { order: 2; flex: 0 0 auto; border-right: 0; border-top: 4px solid var(--gold-deep); overflow: visible; }
  .marquee { font-size: 28px; }
  #names { min-height: 150px; flex: 0 0 auto; }
  body.panel-hidden #panel { display: flex; }
  #toggle-panel { display: none; }
}
