:root {
  --ink: #2b1b3d; --void: #150c22; --gold: #f5c542; --pink: #ff3d6e; --purple: #8a4fd0; --cream: #fff7e6;
  --sign: Bangers, Impact, "Arial Black", sans-serif;
  --body: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--void); color: var(--cream); font-family: var(--body); overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
button, input { font: inherit; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- select screen */
#select {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; touch-action: pan-y;
  padding: 18px max(16px, env(safe-area-inset-right)) 150px max(16px, env(safe-area-inset-left));
  background: radial-gradient(1200px 600px at 50% -10%, rgba(138, 79, 208, .55), transparent 70%), rgba(21, 12, 34, .86);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
#select header { text-align: center; }
#logoEye { width: 110px; height: 60px; display: block; margin: 0 auto -6px; }
h1 { margin: 0; font: 400 clamp(56px, 11vw, 104px)/.95 var(--sign); letter-spacing: 3px; color: #ffe14a; -webkit-text-stroke: 3px var(--ink); text-shadow: 0 6px 0 var(--ink), 0 12px 24px rgba(0, 0, 0, .5); transform: rotate(-2deg); }
h1 span { color: var(--pink); }
.season { margin: 2px 0 0; font: 400 clamp(38px, 7vw, 64px)/1 var(--sign); letter-spacing: 5px; color: #fff; -webkit-text-stroke: 2px var(--ink); text-shadow: 0 5px 0 var(--ink), 0 10px 20px rgba(0, 0, 0, .45); }
.season b { font-weight: 400; font-size: 1.3em; color: #ffe14a; margin-left: 4px; }
.sub { margin: 4px auto 0; max-width: 560px; font-size: clamp(15px, 2.2vw, 19px); font-weight: 500; opacity: .92; }
.sub b { color: #ffe14a; }
.live { display: inline-flex; gap: 8px; align-items: center; margin: 10px 0 0; padding: 3px 14px; border-radius: 99px; background: rgba(255, 61, 110, .18); border: 1.5px solid var(--pink); font-weight: 700; font-size: 14px; }
.live::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--pink); animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: .25; } }

#cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; max-width: 1240px; margin: 20px auto 0; }
.card {
  position: relative; padding: 6px 8px 10px; border-radius: 18px; border: 3px solid var(--ink); cursor: pointer; text-align: center;
  background: linear-gradient(180deg, var(--c1, #6a45b8) 0 58%, #fff7e6 58%); color: var(--ink);
  box-shadow: 0 5px 0 var(--ink); transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: 0 8px 0 var(--ink); }
.card.sel { transform: translateY(-5px) scale(1.04); border-color: var(--gold); box-shadow: 0 9px 0 var(--ink), 0 0 0 4px rgba(245, 197, 66, .55), 0 0 34px rgba(245, 197, 66, .6); z-index: 2; }
.card canvas { width: 100%; aspect-ratio: 1.05; display: block; }
.card b { display: block; font: 400 21px/1 var(--sign); letter-spacing: .8px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card small { display: block; font-size: 11.5px; line-height: 1.2; font-weight: 500; min-height: 28px; margin-top: 3px; opacity: .85; }
.card .badge { position: absolute; top: 7px; left: 7px; padding: 1px 8px; border-radius: 99px; background: var(--pink); color: #fff; font: 700 11px var(--body); border: 2px solid var(--ink); }
.card.taken { filter: grayscale(.75) brightness(.8); cursor: not-allowed; }
.card.wild::after { content: "WILDCARD"; position: absolute; top: 7px; right: 7px; padding: 1px 7px; border-radius: 99px; background: var(--gold); border: 2px solid var(--ink); font: 700 9.5px var(--body); }

.join {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(0deg, #150c22 62%, transparent);
}
#picked { min-width: 200px; max-width: 330px; line-height: 1.15; }
#picked b { display: block; font: 400 24px var(--sign); letter-spacing: 1px; color: #ffe14a; }
#picked span { font-size: 12.5px; opacity: .8; }
#nick { width: 190px; padding: 11px 14px; border-radius: 14px; border: 3px solid var(--ink); background: var(--cream); color: var(--ink); font-weight: 700; outline: none; user-select: text; -webkit-user-select: text; }
#nick:focus { border-color: var(--gold); }
#enter { padding: 10px 26px 8px; border-radius: 16px; border: 3px solid var(--ink); background: var(--pink); color: #fff; font: 400 28px var(--sign); letter-spacing: 1.5px; cursor: pointer; box-shadow: 0 6px 0 var(--ink); transition: transform .08s, box-shadow .08s, filter .2s; }
#enter:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
#enter:not(:disabled):active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
#enter:disabled { filter: grayscale(1) brightness(.7); cursor: default; }
#back { display: none; padding: 10px 18px 8px; border-radius: 16px; border: 3px solid var(--ink); background: var(--cream); color: var(--ink); font: 400 22px var(--sign); letter-spacing: 1.5px; cursor: pointer; box-shadow: 0 6px 0 var(--ink); }
#back:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
#select.switching #back { display: block; }
#select.switching #nick, #select.switching .fine, #select.switching #live { display: none; }
.card.you { cursor: default; }
.card.you .badge { background: var(--gold); color: var(--ink); }
.fine { max-width: 760px; margin: 22px auto 0; text-align: center; font-size: 11.5px; opacity: .6; }
.fine a { color: var(--gold); margin-left: 6px; white-space: nowrap; }

/* -------------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud button { pointer-events: auto; }
.panel, #chip, #board, #ticker { background: rgba(21, 12, 34, .82); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 rgba(21, 12, 34, .7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#chip { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; align-items: center; padding: 6px 14px 6px 6px; border-radius: 40px 18px 18px 40px; }
#chipFace { width: 56px; height: 56px; border-radius: 50%; background: var(--purple); border: 2.5px solid var(--gold); }
#chipName { display: block; font: 400 20px/1 var(--sign); letter-spacing: .8px; color: #ffe14a; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vitals { display: flex; gap: 8px; align-items: center; margin: 3px 0 1px; }
#lives { display: flex; gap: 3px; }
#lives svg { width: 15px; height: 14px; }
#hp { display: flex; gap: 2px; }
#hp i { width: 9px; height: 7px; border-radius: 2px; background: #39e67a; border: 1px solid var(--ink); }
#hp i.off { background: rgba(255, 255, 255, .16); }
.trp { font-weight: 800; font-size: 17px; line-height: 1; }
.trp i { font: 400 13px var(--sign); color: var(--pink); margin-right: 5px; letter-spacing: 1px; font-style: normal; }

#ticker { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translate(-50%, -140%); display: flex; align-items: center; gap: 8px; max-width: min(560px, calc(100vw - 470px)); padding: 5px 16px 5px 8px; border-radius: 99px; border-color: var(--gold); font-weight: 700; font-size: 14.5px; line-height: 1.2; opacity: 0; transition: transform .35s cubic-bezier(.2, 1.4, .4, 1), opacity .25s; }
#ticker.show { transform: translate(-50%, 0); opacity: 1; }
#tickEye { width: 44px; height: 28px; flex: none; }

#side { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); width: 176px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
#board { border-radius: 16px; padding: 7px 10px 8px; font-size: 13px; font-weight: 700; }
#board h3 { margin: 0 0 3px; font: 400 16px var(--sign); letter-spacing: 1px; color: var(--pink); display: flex; justify-content: space-between; }
#board h3 em { font: 700 11px var(--body); color: var(--cream); opacity: .7; font-style: normal; align-self: center; }
#board div { display: flex; gap: 6px; line-height: 1.5; }
#board div span:nth-child(2) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#board div.me { color: #ffe14a; }
#board div.hu span:nth-child(2)::after { content: " ●"; color: #39e67a; font-size: 9px; }
#actions { display: flex; flex-wrap: wrap; gap: 6px; }
#actions button { flex: 1 1 40%; padding: 5px 0 3px; border-radius: 11px; border: 2.5px solid var(--ink); background: var(--cream); color: var(--ink); font: 700 12px var(--body); cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
#actions button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#bInvite { background: var(--gold) !important; }
#minimap { width: 176px; height: 120px; border-radius: 12px; border: 2.5px solid var(--ink); background: rgba(21, 12, 34, .82); }

#roomtag { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font: 400 clamp(26px, 5vw, 44px) var(--sign); letter-spacing: 2px; color: #fff; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 4px 0 var(--ink); opacity: 0; transition: opacity .5s; white-space: nowrap; }
#roomtag.show { opacity: 1; }
#flash { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.4) rotate(-6deg); width: 92vw; text-align: center; font: 400 clamp(44px, 10vw, 104px)/.95 var(--sign); letter-spacing: 3px; color: #ffe14a; -webkit-text-stroke: 3px var(--ink); text-shadow: 0 7px 0 var(--ink); opacity: 0; }
#flash small { display: block; font-size: .34em; color: #fff; -webkit-text-stroke: 1.2px var(--ink); text-shadow: 0 3px 0 var(--ink); letter-spacing: 1.5px; margin-top: 8px; }
#flash.show { animation: flash 2.6s ease-out forwards; }
@keyframes flash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-6deg); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(-4deg); } 20% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%) scale(1) rotate(-4deg); } }

#prompt { position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%); padding: 4px 14px 3px; border-radius: 99px; background: var(--gold); color: var(--ink); border: 2.5px solid var(--ink); font-weight: 800; font-size: 14px; white-space: nowrap; opacity: 0; transition: opacity .15s; }
#prompt.show { opacity: 1; }
#prompt kbd, #hint kbd { display: inline-block; padding: 0 6px; margin: 0 3px; border-radius: 6px; background: var(--ink); color: #fff; font: 700 12px var(--body); }
#quips { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; max-width: calc(100vw - 420px); }
#quips button { position: relative; padding: 7px 12px 5px 26px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--cream); color: var(--ink); font: 700 13px/1.15 var(--body); cursor: pointer; box-shadow: 0 4px 0 var(--ink); text-align: left; max-width: 190px; }
#quips button:first-child { background: #ffe14a; }
#quips button::before { content: attr(data-k); position: absolute; left: 7px; top: 50%; transform: translateY(-50%); width: 14px; height: 16px; border-radius: 4px; background: var(--ink); color: #fff; font-size: 10px; line-height: 17px; text-align: center; }
#quips button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#hint { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); font-size: 12.5px; font-weight: 700; opacity: .8; text-shadow: 0 2px 0 var(--void); }

#touch { display: none; }
#stick { position: absolute; left: max(22px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%; background: rgba(21, 12, 34, .45); border: 3px solid rgba(255, 247, 230, .5); pointer-events: auto; touch-action: none; }
#stick i { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: var(--gold); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
#pad { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); width: 196px; height: 176px; }
#pad button { position: absolute; border-radius: 50%; border: 3px solid var(--ink); color: var(--ink); font: 400 17px var(--sign); letter-spacing: 1px; box-shadow: 0 5px 0 var(--ink); touch-action: none; }
#pad button:active, #pad button.down { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
#tSlap { right: 0; bottom: 0; width: 104px; height: 104px; background: var(--pink); color: #fff !important; font-size: 28px !important; }
#tJump { right: 112px; bottom: 6px; width: 70px; height: 70px; background: #39c6e8; }
#tSit { right: 100px; bottom: 86px; width: 62px; height: 62px; background: var(--gold); }
#tSit.hot { animation: hot .7s infinite alternate; }
@keyframes hot { to { box-shadow: 0 5px 0 var(--ink), 0 0 0 7px rgba(245, 197, 66, .5); } }
#tSay { right: 18px; bottom: 114px; width: 62px; height: 62px; background: var(--cream); }

#toast { position: fixed; left: 50%; bottom: 150px; z-index: 40; transform: translate(-50%, 30px); padding: 8px 18px 6px; border-radius: 14px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); font-weight: 800; font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#curtain { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--void); font: 400 26px var(--sign); letter-spacing: 1.5px; transition: opacity .4s; }
#curtain.gone { opacity: 0; pointer-events: none; }
#curtain p { margin: 0; }
.spin { width: 54px; height: 54px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, .15); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (pointer: coarse) {
  #touch { display: block; }
  #hint, #quips, #minimap { display: none; }
  #prompt { bottom: 214px; }
  #prompt kbd { display: none; }
  #toast { bottom: 262px; }
  #side { width: 132px; }
  #board { font-size: 11.5px; padding: 5px 8px; }
  #actions { flex-wrap: wrap; }
  #actions button { flex: 1 1 40%; }
}
@media (max-width: 760px) {
  #ticker { left: max(10px, env(safe-area-inset-left)); right: 152px; top: calc(max(10px, env(safe-area-inset-top)) + 76px); max-width: none; transform: translateY(-16px); border-radius: 18px; font-size: 12.5px; }
  #ticker.show { transform: none; }
  #tickEye { display: none; }
  #ticker { padding: 5px 12px; }
  #quips { max-width: calc(100vw - 20px); }
  #quips button:nth-child(n+3) { display: none; }
  #chipName { max-width: 96px; font-size: 17px; }
  #cards { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
  .card b { font-size: 18px; }
  .card small { font-size: 10.5px; }
  #picked { min-width: 0; flex: 1 1 100%; text-align: center; max-width: none; }
  #picked span { display: none; }
  #nick { flex: 1; min-width: 0; }
  #enter { font-size: 22px; padding: 9px 16px 7px; }
}
@media (max-height: 520px) and (pointer: coarse) {
  #side #board div:nth-child(n+5) { display: none; }
  #stick { width: 112px; height: 112px; }
}
