:root {
  --ink: #1d1428;
  --cream: #fff8ec;
  --yellow: #ffd23f;
  --red: #e8344e;
  --blue: #4cb4ff;
  --purple: #7a5bd6;
  font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #120c1f; overflow: hidden; }
.hidden { display: none !important; }
.pix { image-rendering: pixelated; }

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1280px;
  height: 720px;
  transform-origin: center;
  overflow: hidden;
  background: #120c1f;
}
#game { position: absolute; inset: 0; image-rendering: pixelated; }
#ui, #pause {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
#ui:empty { pointer-events: none; }
#pause { background: rgba(20, 12, 35, 0.6); z-index: 5; }

.topbtns { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; z-index: 9; }
.iconbtn {
  width: 46px; height: 46px; border-radius: 12px; border: 3px solid var(--ink);
  background: rgba(255, 248, 236, 0.85); font-size: 22px; cursor: pointer; line-height: 1;
}

h1 { margin: 0; font-size: 48px; line-height: 1.1; }
p { margin: 0; }
.row { display: flex; gap: 20px; justify-content: center; align-items: center; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 0.35em; border-radius: 8px; border: 3px solid var(--ink);
  border-bottom-width: 5px; background: #fff; font: 700 0.95em 'Fredoka', sans-serif; text-align: center;
}
.tiny { font-size: 18px; opacity: 0.85; }
.msg { color: #fff; background: var(--red); padding: 8px 18px; border-radius: 14px; font-size: 22px; border: 3px solid var(--ink); }

.btn {
  font: 700 28px 'Fredoka', sans-serif;
  padding: 12px 28px;
  border-radius: 20px;
  border: 5px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 7px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn.big { font-size: 34px; padding: 16px 36px; }
.btn.small { font-size: 20px; padding: 6px 16px; border-width: 4px; box-shadow: 0 4px 0 var(--ink); }
.btn.blue { background: var(--blue); }
.btn.ghost { background: var(--cream); }
.btn.red { background: var(--red); color: #fff; }
.btn:hover, .btn.focus { transform: translateY(-4px) scale(1.04); box-shadow: 0 11px 0 var(--ink); outline: 5px solid #fff; outline-offset: 3px; }
.btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: 0.7; }

.card {
  background: var(--cream);
  border: 6px solid var(--ink);
  border-radius: 32px;
  padding: 28px 40px;
  box-shadow: 0 10px 0 var(--ink);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  animation: pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* title */
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 34px; }
.logo { display: flex; flex-direction: row; align-items: center; line-height: 0.9; transform: rotate(-3deg); animation: wobble 3s ease-in-out infinite; }
.logo span { font-size: 132px; font-weight: 700; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; letter-spacing: 4px; text-shadow: 0 10px 0 var(--ink); }
.logo .l1 { color: var(--yellow); }
.logo .l2 { color: #4cc9f0; }
@keyframes wobble { 50% { transform: rotate(2deg) scale(1.03); } }
.help { color: #fff; font-size: 22px; text-shadow: 0 2px 0 var(--ink); }

/* join */
.join-card input {
  width: 6ch; font: 700 64px 'Fredoka', sans-serif; text-align: center; letter-spacing: 10px;
  border: 5px solid var(--ink); border-radius: 18px; padding: 4px 12px; text-transform: uppercase;
}

/* lobby */
.lobby { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.room-code {
  display: flex; align-items: center; gap: 16px; background: var(--ink); color: #fff; padding: 6px 30px 8px; border-radius: 22px;
  border: 5px solid #fff;
}
.room-code span { font-size: 26px; opacity: 0.8; }
.room-code b { font-size: 64px; letter-spacing: 12px; color: var(--yellow); }
.seats { display: flex; gap: 40px; }
.seat {
  width: 420px; height: 440px; background: var(--cream); border: 6px solid var(--ink); border-radius: 30px; box-shadow: 0 10px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px; padding: 0 20px 18px; overflow: hidden;
}
.seat h2 { margin: 0 -20px 4px; align-self: stretch; text-align: center; background: var(--pc); font-size: 36px; padding: 6px 0; border-bottom: 5px solid var(--ink); }
.seat .qr { width: 210px; height: 210px; background: #fff; border: 4px solid var(--ink); border-radius: 14px; padding: 4px; }
.seat .qr svg { width: 100%; height: 100%; display: block; }
.big-p { font-size: 26px; font-weight: 600; }
.or { font-size: 21px; }
.seat.filled { background: color-mix(in srgb, var(--pc) 22%, var(--cream)); }
.joined { display: flex; flex-direction: column; align-items: center; font-size: 90px; line-height: 1.1; margin-top: 8px; animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
.joined span { font-size: 46px; font-weight: 700; color: var(--ink); }
.keys { font-size: 22px; display: flex; flex-direction: column; gap: 8px; }
.url { color: #fff; text-shadow: 0 2px 0 var(--ink); }
.corner { position: absolute; left: 16px; bottom: 16px; }

/* character select */
.select { display: flex; flex-direction: column; align-items: center; gap: 26px; color: #fff; }
.select h1 { font-size: 56px; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; }
.chars { display: flex; gap: 60px; }
.char-card {
  position: relative; width: 340px; height: 380px; border-radius: 30px; border: 6px solid var(--ink); background: var(--cream);
  box-shadow: 0 10px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 20px;
  cursor: pointer; transition: transform 0.15s; font-family: inherit;
}
.char-card .char { max-width: 240px; max-height: 250px; margin-bottom: 14px; }
.char-card[data-char='human'] .char { height: 250px; }
.char-card[data-char='elephant'] .char { width: 240px; }
.char-card .cname { font-size: 40px; font-weight: 700; color: var(--ink); }
.char-card.on { transform: translateY(-14px) scale(1.06); background: #ffe9a8; outline: 8px solid #ffb703; }
.char-card.on .char { animation: hop 0.6s ease-in-out infinite; }
.char-card.p2 { background: #d4f1ff; outline: 8px solid #4cc9f0; }
.badge { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 30px; font-weight: 700; padding: 2px 20px; border-radius: 16px; border: 5px solid var(--ink); }
@keyframes hop { 50% { transform: translateY(-14px); } }
.hint { font-size: 30px; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; color: #fff; }
.kA { display: inline-block; width: 1.4em; height: 1.4em; line-height: 1.3em; border-radius: 50%; background: var(--red); color: #fff; border: 4px solid var(--ink); text-align: center; -webkit-text-stroke: 0; }

/* results */
.result-card, .giant-card, .champ-card { min-width: 640px; }
.result-card h1, .champ-card h1 { font-size: 54px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.winners { display: flex; gap: 50px; align-items: flex-end; }
.winner { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.winner .char { height: 150px; }
.winner .char[alt='Elephant'] { height: 110px; }
.bounce { animation: hop 0.5s ease-in-out infinite; }
.gain { font-size: 40px; font-weight: 700; color: #b37a00; display: flex; align-items: center; gap: 8px; animation: rise 0.8s ease-out both 0.4s; }
@keyframes rise { from { transform: translateY(30px) scale(0.5); opacity: 0; } }
.score { display: flex; gap: 24px; }
.score span { display: flex; align-items: center; gap: 8px; font-size: 32px; font-weight: 700; background: var(--pc); padding: 4px 18px; border-radius: 16px; border: 4px solid var(--ink); }
.next { font-size: 26px; display: flex; align-items: center; gap: 8px; }
.press { font-size: 24px; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

/* giant */
.giant-card h1 { font-size: 64px; color: var(--red); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.sub { font-size: 30px; }
.giants { display: flex; gap: 70px; align-items: flex-end; margin-top: 30px; }
.g { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.g .char { height: 120px; }
.g .char[alt='Elephant'] { height: 90px; }
.g.is-giant .char { animation: grow 1s ease-out both; height: 170px; }
.g.is-giant .char[alt="Elephant"] { height: 125px; }
@keyframes grow { from { transform: scale(0.6); } 70% { transform: scale(1.1); } }
.g .crown { position: absolute; top: -40px; }
.gname { font-size: 28px; font-weight: 700; background: var(--pc); padding: 2px 16px; border-radius: 14px; border: 4px solid var(--ink); }
.gcoins { font-size: 26px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.gtag { font-size: 22px; font-weight: 700; color: #fff; background: var(--red); padding: 2px 12px; border-radius: 12px; border: 3px solid var(--ink); }

/* champion */
.trophy { animation: hop 0.9s ease-in-out infinite; }
.winner .crown { margin-bottom: -6px; }

/* pause */
.pause-card h1 { font-size: 52px; }
.pause-card p { font-size: 26px; }
.pause-grid { display: flex; gap: 26px; align-items: center; text-align: left; }
.qr.small { width: 200px; height: 200px; background: #fff; border: 4px solid var(--ink); border-radius: 14px; padding: 4px; }
.qr.small svg { width: 100%; height: 100%; display: block; }
.count { font-size: 96px; font-weight: 700; color: var(--red); line-height: 1; }
