:root {
  --c-deep: #3b2a78; --c-purple: #8f6ae6; --c-cream: #fff1d6; --c-yellow: #ffc93c;
  --c-orange: #ff8a1f; --c-blue: #48b4ff; --c-mint: #b9f5d0;
  --f-logo: 'Bubblegum Sans', 'Fredoka', cursive;
  --f-title: 'Tinos', 'Times New Roman', Times, serif;
  --f-body: 'Tinos', 'Times New Roman', Times, serif;
  --bg: #120b2a;
  --panel: #221846;
  --edge: #4e3d86;
  --text: #efe8ff;
  --muted: #a597c7;
  --orange: #ff8a1f;
  --purple: #a77bff;
  --lav: #d9ccff;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html, body { height: 100%; overflow: hidden; }
body {
  background:
    radial-gradient(circle at 85% 8%, rgba(255,240,200,.12) 0, transparent 22%),
    radial-gradient(ellipse at top, #2a1c48 0%, var(--bg) 70%);
  color: var(--text);
  font-family: var(--f-body); font-weight: 400;
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 12px 16px;
}
[hidden] { display: none !important; }
button { font-family: inherit; }

/* ---------- lobby (styled after the GhostTown sheets) ---------- */
.panel {
  position: relative; z-index: 1;
  width: min(900px, 100%);
  max-height: calc(100dvh - 24px);
  display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(16px, 3vw, 40px); align-items: center;
  background: linear-gradient(180deg, rgba(48,34,92,.86), rgba(30,21,62,.9));
  border: 2px solid #5f4ca3;
  border-radius: 24px;
  padding: clamp(16px, 3.4vh, 34px) clamp(18px, 3vw, 38px);
  box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 70px rgba(150,110,255,.2), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(6px);
  text-align: center;
}
#lobby { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px 16px; }
#lobby[hidden] { display: none !important; }
#bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
#lobby::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(8,4,24,.55) 100%); }
.col { display: flex; flex-direction: column; align-items: stretch; min-width: 0; }
.col.left { align-items: center; }
.sub-wrap { display: none; }
h1 {
  position: relative;
  font-family: var(--f-logo); font-weight: 400;
  font-size: clamp(54px, 9.5vh, 80px); line-height: 1; letter-spacing: 1px;
  margin: 0 0 .32em; padding: 0 .08em;
  background: linear-gradient(180deg, #fffaf0 0%, var(--c-cream) 45%, #ffd88a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #5b3fb0) drop-shadow(0 0 2px #2d1d66) drop-shadow(0 0 18px rgba(167,123,255,.75));
}
h1::after {     /* golden swoosh under the logo, like the sheet */
  content: ''; position: absolute; left: 14%; right: 14%; bottom: -.3em; height: .2em;
  background: no-repeat center/100% 100% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20'%3E%3Cpath d='M4 14 C60 2 130 2 196 9' stroke='%23ffc93c' stroke-width='4' fill='none' stroke-linecap='round'/%3E%3Ccircle cx='196' cy='9' r='3' fill='%23ffe9a8'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 6px rgba(255,201,60,.8));
}
h1 .o { width: .52em; height: .58em; vertical-align: -.04em; margin: 0 .01em; filter: drop-shadow(0 0 6px rgba(200,215,255,.95)); }
h1 span { margin-left: .14em; }
.sub {
  font-family: var(--f-body); font-weight: 400; font-size: 18px;
  color: #e6dcff; margin: 0 0 clamp(12px, 2.4vh, 20px);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-title); font-weight: 700; font-size: 17px; color: #fff4e4;
  padding: 5px 16px 6px; border-radius: 999px;
  background: rgba(30,20,62,.9); border: 1.5px solid #6e5ab6;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 14px rgba(150,110,255,.15);
  margin-bottom: 12px;
}
.chip::before { content: '✦'; color: #f5c56b; text-shadow: 0 0 8px rgba(245,197,107,.7); font-size: 13px; }
.pick { display: flex; gap: 14px; justify-content: center; }
.char canvas { width: clamp(92px, 14vh, 120px); height: auto; aspect-ratio: 240 / 208; }
.char {
  background: radial-gradient(circle at 50% 35%, #2c2058, #171030);
  border: 2px solid #4e3d86; border-radius: 16px;
  padding: 6px 14px 10px; color: var(--text); cursor: pointer; width: 148px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.char span { font-family: var(--f-title); font-weight: 700; font-size: 22px; color: var(--c-cream); }
.char small { font-family: var(--f-body); font-weight: 400; color: #c3b6e8; font-size: 16px; }
.char:hover { transform: translateY(-2px); }
.char.boy.selected { border-color: #ffa94a; box-shadow: 0 0 0 3px rgba(255,150,50,.18), 0 0 26px rgba(255,150,50,.25); }
.char.ghost.selected { border-color: #7fc8ff; box-shadow: 0 0 0 3px rgba(110,190,255,.2), 0 0 26px rgba(110,190,255,.28); }

.cta {
  width: 100%; padding: 12px 18px 13px; border-radius: 999px; cursor: pointer;
  font-family: var(--f-title); font-weight: 700; font-size: 22px; letter-spacing: .2px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 2px solid rgba(255,255,255,.4);
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.cta:hover { filter: brightness(1.07); transform: translateY(-1px); }
.cta:active { transform: translateY(2px); }
.cta:disabled { opacity: .5; cursor: wait; }
.cta.orange, .cta.yellow {
  background: linear-gradient(180deg, #ffe589 0%, var(--c-yellow) 45%, #f5a10f 100%);
  color: #4a2a00; text-shadow: 0 1px 0 rgba(255,255,255,.5);
  font-family: var(--f-logo); font-weight: 400; font-size: 24px; letter-spacing: .5px;
  box-shadow: 0 5px 0 #a8620a, 0 0 28px rgba(255,190,50,.45), inset 0 2px 0 rgba(255,255,255,.6);
}
.cta.orange::after, .cta.yellow::after { content: '▶'; font-size: .8em; }
.cta.blue, .cta.purple {
  background: linear-gradient(180deg, #7a5ad6, #5b3fb0 60%, #4a32a0);
  color: var(--c-cream);
  border-color: #a98cff;
  box-shadow: 0 4px 0 #2d1d66, 0 0 22px rgba(150,110,255,.4), inset 0 1px 0 rgba(255,255,255,.3);
}
.cta.ghostbtn {
  width: auto; padding: 11px 26px; font-size: 22px; color: var(--c-cream);
  background: linear-gradient(180deg, #7a5ad6, #5b3fb0 60%, #4a32a0); border: 2px solid #a98cff;
  box-shadow: 0 4px 0 #2d1d66, 0 0 18px rgba(150,110,255,.3);
}
.divider { display: flex; align-items: center; gap: 12px; color: #c3b6e8; font-family: var(--f-body); font-weight: 400; font-size: 17px; margin: 12px 0; }
.divider.wide { margin: 20px 0 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #6e5ab6, transparent); }
.join { display: flex; gap: 10px; }
.join input {
  flex: 1; min-width: 0; padding: 10px; border-radius: 14px; border: 1.5px solid #5f4ca3;
  background: rgba(16,10,36,.9); color: var(--text); text-align: center;
  font: 400 22px var(--f-body); letter-spacing: 14px; text-transform: uppercase;
}
.join input::placeholder { color: #6c5e9a; }
.join input:focus { outline: none; border-color: #8a6ae6; box-shadow: 0 0 16px rgba(150,110,255,.3); }
.err { color: #ffb08a; min-height: 20px; font-size: 14px; margin: 12px 0 0; font-family: var(--f-body); }

/* ---------- game ---------- */
/* game screen: the level fills the window's height, HUD lives in side panels */
#game {
  position: fixed; inset: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: clamp(10px, 1.4vw, 22px);
  padding: 6px clamp(8px, 1.2vw, 18px);
}
#game[hidden] { display: none !important; }
#game .stage { width: min(calc((100dvh - 12px) * 816 / 600), calc(100vw - 150px)); }
.side { display: flex; min-width: 0; }
.side.right { justify-content: flex-start; align-self: start; padding-top: 10px; }
.toolbar { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mini-time[hidden] { display: none; }
.mini-time {
  font: 700 22px var(--f-title); color: rgba(255,241,214,.9);
  text-shadow: 0 0 10px rgba(167,123,255,.6); min-width: 56px; text-align: center;
}
.tool {
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  font: 700 16px var(--f-title); color: #e9defc;
  background: rgba(30,20,62,.55); border: 1.5px solid rgba(110,90,182,.6);
  opacity: .75; transition: opacity .15s, border-color .15s, box-shadow .15s;
}
.tool:hover { opacity: 1; border-color: #a98cff; box-shadow: 0 0 14px rgba(150,110,255,.35); }
.tool.off { opacity: .4; text-decoration: line-through; }
.help-card { width: min(360px, 88%); gap: 12px; text-align: left; }
.help-card .treats { display: flex; gap: 10px; justify-content: center; }
.help-card .pick-count { padding: 5px 12px; border-radius: 12px; background: rgba(16,10,36,.6); font: 700 18px var(--f-title); gap: 8px; }
.help-card .pick-count img { width: 26px; height: 22px; object-fit: contain; }
.help-card .online { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: 13px; }
.help-card .online:not(:has(:not([hidden]))) { display: none; }
.help-card .keys { margin: 0; font: 500 14px var(--f-body); color: #cbbdf0; line-height: 2; text-align: left; }
.help-card .keys .k-title { display: inline-block; min-width: 78px; font-weight: 700; color: #fff4e4; }
.rules { margin: 0; padding-left: 18px; text-align: left; font: 500 13.5px var(--f-body); color: #cbbdf0; line-height: 1.5; }
.rules b.t-lava { color: #ffa94a; } .rules b.t-void { color: #b9a0ff; }
#game .share { position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%); z-index: 2; margin: 0; max-width: 92%; }
/* narrow / tall windows: panels go above and below the level */
@media (max-aspect-ratio: 3/2), (max-width: 900px) {
  #game { grid-template-columns: 1fr; grid-template-rows: auto auto; align-content: center; justify-items: center; gap: 8px; }
  #game .side.left { display: none; }
  #game .side.right { order: -1; padding: 0; justify-content: center; width: 100%; }
  #game .stage { width: min(calc(100vw - 16px), calc((100dvh - 70px) * 816 / 600)); }
  .toolbar { flex-direction: row; }
}
.hud {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  margin-bottom: 10px; font-size: 14px;
}
.hud-left { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hud-right { display: flex; gap: 14px; justify-content: flex-end; align-items: center; }
.hud-mid { font: 700 26px var(--f-title); color: #fbf6ff; letter-spacing: 1px; text-shadow: 0 0 10px rgba(167,123,255,.8); }
.room b { letter-spacing: 2px; color: var(--lav); }
.tag { padding: 4px 12px; border-radius: 99px; font: 600 14px var(--f-title); border: 1px solid currentColor; }
.tag.boy { background: rgba(255,138,31,.15); color: var(--orange); }
.tag.ghost { background: rgba(167,123,255,.18); color: var(--lav); }
.partner.on { color: #9ff09a; }
.partner.off { color: var(--muted); }
.pick-count { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.pick-count i { width: 18px; height: 14px; display: inline-block; }
.pick-count.candy { color: #ff7ac0; }
.pick-count.candy i { background: radial-gradient(circle, #ff5fb0 45%, transparent 47%) center/12px 12px no-repeat,
  linear-gradient(90deg, #ff5fb0 0 3px, transparent 3px calc(100% - 3px), #ff5fb0 calc(100% - 3px)); clip-path: polygon(0 10%, 25% 50%, 0 90%, 100% 90%, 75% 50%, 100% 10%); }
.pick-count.pumpkin { color: var(--orange); }
.pick-count.pumpkin i { background: var(--orange); border-radius: 45%; width: 16px; box-shadow: inset 0 -2px 0 #b04a00; }
.ping { color: var(--muted); font-size: 12px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--edge); background: #1c1430;
  color: var(--lav); cursor: pointer; font-size: 15px;
}
.icon-btn.off { opacity: .45; text-decoration: line-through; }
.stage {
  border: 3px solid var(--edge); border-radius: 10px; overflow: hidden; background: #000;
  box-shadow: 0 24px 70px rgba(0,0,0,.65), 0 0 50px rgba(167,123,255,.12);
}
#cv { display: block; width: 100%; height: auto; }
.share {
  margin-top: 12px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 10px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.share code { background: #140e24; padding: 4px 8px; border-radius: 6px; color: var(--orange); word-break: break-all; }
.share button { background: var(--purple); border: 0; border-radius: 6px; padding: 5px 12px; font-weight: 700; cursor: pointer; color: #160a33; }
.keys { color: var(--muted); font-size: 13px; text-align: center; margin-top: 12px; }
.keys b { color: var(--text); }
kbd {
  background: #251a3e; border: 1px solid var(--edge); border-bottom-width: 2px; border-radius: 4px;
  padding: 1px 6px; font: 600 12px var(--f-title); color: var(--text); margin: 0 1px;
}
@media (max-width: 760px) {
  .panel { grid-template-columns: 1fr; gap: 10px; overflow: auto; }
  .col.right { width: min(420px, 100%); justify-self: center; }
}
@media (max-width: 640px) {
  .hud { grid-template-columns: 1fr 1fr; }
  .hud-mid { order: -1; grid-column: 1 / -1; text-align: center; }
}

/* ---------- level chip + pause menu ---------- */
.level-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font: 600 15px var(--f-title); color: #f3ecff;
  padding: 4px 14px 5px; border-radius: 999px;
  background: rgba(30,20,62,.9); border: 1.5px solid #6e5ab6;
  box-shadow: 0 0 14px rgba(150,110,255,.15);
}
.level-chip::before { content: '✦'; color: #f5c56b; font-size: 12px; text-shadow: 0 0 8px rgba(245,197,107,.7); }
.stage { position: relative; }
.pause-menu {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(12,6,32,.62); backdrop-filter: blur(3px);
}
.pause-card {
  width: min(300px, 80%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center;
  background: linear-gradient(180deg, rgba(48,34,92,.97), rgba(30,21,62,.97));
  border: 2px solid #5f4ca3; border-radius: 20px; padding: 22px 24px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 50px rgba(150,110,255,.2);
}
.pause-card .chip { align-self: center; margin-bottom: 0; font-size: 17px; }
.pause-note { margin: 0; color: #cbbdf0; font: 500 14px var(--f-body); min-height: 0; }
.pause-note:empty { display: none; }
.cta.ghostbtn.wide { width: 100%; }

#fs-btn { display: inline-flex; align-items: center; justify-content: center; }
#fs-btn .fs-out { display: none; }
#fs-btn.on .fs-in { display: none; }
#fs-btn.on .fs-out { display: block; }

/* ---------- title screen ---------- */
#title { position: fixed; inset: 0; z-index: 5; background: #160f36; overflow: hidden; }
#title[hidden] { display: none !important; }
.title-scene { position: absolute; inset: -3%; will-change: transform; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.title-art, #title-fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-art { object-fit: cover; object-position: center 35%; animation: artIn 1.2s ease-out both; }
@keyframes artIn { from { opacity: 0; filter: brightness(.4) blur(3px); } to { opacity: 1; filter: none; } }
#title::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 62%, rgba(10,6,30,.35) 0%, transparent 38%), radial-gradient(ellipse at center, transparent 55%, rgba(8,4,24,.6) 100%); }
.title-actions {
  position: absolute; z-index: 2; left: 51%; top: 57%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: stretch; gap: 14px; width: clamp(220px, 19.5vw, 290px);
}
.title-actions .cta { animation: rise .7s cubic-bezier(.2,.9,.3,1.2) both; }
.title-actions .cta:nth-child(1) { animation-delay: .5s; font-size: clamp(26px, 2.6vw, 34px); padding: 15px 20px 16px; }
.title-actions .cta:nth-child(2) { animation-delay: .65s; font-size: clamp(18px, 1.7vw, 22px); }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
#play-game { position: relative; overflow: hidden; }
#play-game::before {     /* light sweep across the button */
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  animation: sweep 3.2s ease-in-out 1.4s infinite;
}
@keyframes sweep { 0% { left: -60%; } 35%, 100% { left: 130%; } }
#play-game:hover { transform: translateY(-2px) scale(1.03); }

/* how to play */
.modal { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  background: rgba(10,6,28,.62); backdrop-filter: blur(4px); padding: 16px; animation: fade .25s ease-out both; }
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.howto-card {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 22px 26px 24px;
  background: linear-gradient(180deg, rgba(48,34,92,.97), rgba(30,21,62,.97));
  border: 2px solid #5f4ca3; border-radius: 22px; box-shadow: 0 24px 70px rgba(0,0,0,.6), 0 0 50px rgba(150,110,255,.25);
  animation: rise .35s cubic-bezier(.2,.9,.3,1.2) both; text-align: center;
}
.howto-card .chip { margin: 0; font-size: 19px; }
.howto-heroes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 14px;
  background: rgba(16,10,36,.55); border: 1.5px solid #4e3d86; border-radius: 16px; }
.hero img { height: 70px; object-fit: contain; }
.hero b { font: 700 20px var(--f-title); color: var(--c-cream); }
.hero small { font: 400 15px var(--f-body); color: #c3b6e8; line-height: 1.35; }
.howto-rules { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.howto-rules li { display: flex; align-items: center; gap: 10px; font: 400 16px var(--f-body); color: #e6dcff; }
.howto-rules .ic { width: 58px; flex: none; display: flex; justify-content: center; align-items: center; gap: 4px; }
.howto-rules img { height: 26px; width: auto; }
.dot.brew { width: 30px; height: 12px; border-radius: 6px; flex: none; background: linear-gradient(#b6ff5c, #3f9d1a); box-shadow: 0 0 10px rgba(150,255,90,.6); }
.howto-note { margin: 0; font: 400 14px var(--f-body); color: #b9aae3; }
.howto-card .cta { width: 60%; }
.howto-card kbd { font-size: 13px; }

/* menu after removing the logo: bigger hero cards, balanced columns */
.panel { align-items: stretch; }
.col { justify-content: center; }
.col.left .chip { margin-bottom: 16px; font-size: 18px; padding: 6px 20px 7px; }
.pick { gap: 16px; }
.char { width: clamp(150px, 15vw, 186px); padding: 10px 14px 14px; }
.char canvas { width: clamp(120px, 19vh, 156px); }
.back-btn {
  position: absolute; z-index: 2; top: 18px; left: 18px; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; font: 700 16px var(--f-title); color: var(--c-cream);
  background: rgba(30,20,62,.75); border: 1.5px solid #6e5ab6;
}
.back-btn:hover { border-color: #a98cff; box-shadow: 0 0 14px rgba(150,110,255,.35); }

#howto-close::after { content: none; }
