* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1026; }
body { font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif; color: #eef4ff; user-select: none; -webkit-user-select: none; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.panel {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
  background: rgba(8, 12, 34, 0.74); backdrop-filter: blur(6px);
}

#lobby h1 { font-size: clamp(40px, 7vw, 92px); letter-spacing: 4px; font-weight: 900; text-shadow: 0 4px 0 #16324f, 0 8px 24px rgba(0,0,0,0.5); }
#lobby h1 span, #errorbox h2 span { color: #ffd25e; }
#lobby .tag { margin-bottom: 22px; font-size: clamp(14px, 1.8vw, 21px); color: #9fb8d8; }

#lobbygrid { display: flex; gap: 56px; align-items: center; flex-wrap: wrap; justify-content: center; }
#joinbox { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#qrwrap { position: relative; width: clamp(220px, 26vw, 360px); aspect-ratio: 1; background: #fff; border-radius: 20px; padding: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.45), 0 0 0 6px rgba(255, 210, 94, 0.35); }
#qr { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#qr:not([src]) { visibility: hidden; }
#qrloading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #3d4f7e; font-weight: 800; }
#joinurl { font-size: clamp(15px, 1.8vw, 22px); font-weight: 800; color: #7fe3ff; }
.codeline { color: #9fb8d8; font-size: 15px; }
#roomcode { display: inline-block; font-size: 30px; font-weight: 900; letter-spacing: 6px; color: #ffd25e; vertical-align: middle; margin-left: 6px; }
.hint { color: #8aa2c4; font-size: 14px; }
.joinlabel { font-size: 15px; letter-spacing: 2px; text-transform: uppercase; color: #9fb8d8; margin-bottom: 4px; font-weight: 700; }

#lobbyright { display: flex; flex-direction: column; gap: 10px; min-width: 380px; }
#lobbyplayers { display: flex; flex-wrap: wrap; gap: 10px; min-height: 44px; max-width: 560px; }
.pchip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px 8px 14px;
  border-radius: 999px; font-weight: 800; font-size: 17px;
  background: #16213e; border: 2px solid #2c3d63; animation: pop-in 0.25s ease;
}
.pchip.dc { opacity: .5; }
.pchip .dot { width: 14px; height: 14px; border-radius: 50%; }
.pchip .kick { margin-left: 4px; background: none; border: none; color: #8aa2c4; font-size: 15px; cursor: pointer; padding: 0 4px; }
.pchip .kick:hover { color: #ff8d8d; }
@keyframes pop-in { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.setrow { display: flex; align-items: center; gap: 8px; }
.setname { width: 110px; color: #9fb8d8; font-size: 15px; font-weight: 700; }
.setrow button {
  background: #16213e; color: #8aa2c4; border: 2px solid #2c3d63; border-radius: 10px;
  padding: 8px 14px; font-size: 15px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.setrow button.sel { background: #2457a8; color: #fff; border-color: #69a8ff; box-shadow: 0 0 14px rgba(105, 168, 255, 0.5); }

#startbtn, #newroombtn {
  margin-top: 10px; padding: 16px 60px; font-size: 26px; font-weight: 900; letter-spacing: 3px; font-family: inherit;
  border: none; border-radius: 16px; background: linear-gradient(180deg, #ffd25e, #ff9838);
  color: #3d2200; cursor: pointer; box-shadow: 0 6px 0 #b05e12, 0 12px 30px rgba(255, 170, 60, 0.35);
  transition: transform 0.1s;
}
#startbtn:not(:disabled):hover { transform: translateY(-2px); }
#startbtn:not(:disabled):active { transform: translateY(3px); box-shadow: 0 2px 0 #b05e12; }
#startbtn:disabled { filter: grayscale(0.8); opacity: 0.5; cursor: not-allowed; }
#rules { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 1100px; }
#rules span { background: rgba(16, 26, 54, .7); border: 1.5px solid #22335a; border-radius: 999px; padding: 8px 16px; font-size: 14px; color: #c9d8f0; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#o2wrap { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: min(560px, 44vw); text-align: center; display: flex; flex-direction: column; align-items: center; }
#o2bar { width: 100%; height: 26px; background: rgba(10, 18, 40, 0.75); border: 2px solid rgba(140, 190, 255, 0.35); border-radius: 999px; overflow: hidden; position: relative; }
#o2fill { height: 100%; background: linear-gradient(90deg, #37d0ff, #7fe3ff); border-radius: 999px; transition: width 0.3s linear; }
#o2bar.panic #o2fill { background: linear-gradient(90deg, #ff5050, #ff8d50); animation: o2panic 0.6s infinite alternate; }
@keyframes o2panic { from { filter: brightness(1); } to { filter: brightness(1.6); } }
#o2text { margin-top: 4px; font-weight: 900; letter-spacing: 2px; font-size: 17px; text-shadow: 0 2px 6px rgba(0,0,0,0.6); }

#peak {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px;
  background: rgba(10, 18, 40, 0.8); border: 2px solid rgba(255, 210, 94, 0.7); border-radius: 999px;
  font-weight: 900; font-size: 17px; letter-spacing: 1px; color: #ffe9b0; box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
#peakarrow { width: 34px; height: 34px; transition: transform 0.15s linear; }
#peakarrow path { fill: #ffd25e; stroke: #3d2200; stroke-width: 1.5; }
#peak.here { border-color: #6dffa8; color: #b9ffd6; }

#roster { position: absolute; top: 16px; left: 18px; display: flex; flex-direction: column; gap: 6px; }
.rchip {
  display: flex; align-items: center; gap: 8px; background: rgba(10, 18, 40, 0.7);
  border-radius: 999px; padding: 5px 14px 5px 6px; font-weight: 800; font-size: 15px;
  border: 1.5px solid rgba(140, 190, 255, 0.25);
}
.rchip .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.7); }
.rchip.elim { opacity: 0.35; text-decoration: line-through; }
.rchip.dc { opacity: 0.55; }
.rchip.elim::after { content: '✂'; margin-left: 4px; }

#altwrap { position: absolute; top: 16px; right: 18px; text-align: right; }
#altbar { width: 16px; height: min(36vh, 320px); background: rgba(10, 18, 40, 0.7); border: 2px solid rgba(140, 190, 255, 0.35); border-radius: 999px; position: relative; margin-left: auto; }
#altfill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(180deg, #ffd25e, #ff9838); border-radius: 999px; transition: height 0.3s; }
#altflag { position: absolute; left: -26px; font-size: 20px; transition: bottom 0.3s; transform: translateY(50%); }
#alttext { margin-top: 6px; font-weight: 900; font-size: 16px; letter-spacing: 1px; text-shadow: 0 2px 6px rgba(0,0,0,0.6); }

#minijoin { position: absolute; left: 14px; bottom: 14px; display: flex; align-items: center; gap: 10px; background: rgba(10, 18, 40, 0.75); border-radius: 14px; padding: 8px 14px 8px 8px; border: 1.5px solid rgba(140, 190, 255, 0.25); }
#miniqr { width: 74px; height: 74px; background: #fff; border-radius: 8px; padding: 3px; image-rendering: pixelated; }
.mjlabel { font-size: 12px; color: #9fb8d8; font-weight: 700; }
#minicode { font-size: 15px; font-weight: 900; color: #7fe3ff; }

#pausebadge { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); background: rgba(255, 152, 56, .92); color: #3d2200; font-weight: 900; padding: 10px 24px; border-radius: 999px; letter-spacing: 1px; }

#toasts { position: absolute; top: 132px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast {
  background: rgba(10, 18, 40, 0.85); border-radius: 12px; padding: 9px 22px; font-weight: 800;
  font-size: 17px; animation: toast-in 0.25s ease; white-space: nowrap;
  border: 1.5px solid rgba(140, 190, 255, 0.3);
}
.toast.good { border-color: #6dffa8; color: #b9ffd6; }
.toast.warn { border-color: #ffd25e; color: #ffe9b0; }
.toast.bad { border-color: #ff6d6d; color: #ffc9c9; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all 0.4s; }
@keyframes toast-in { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }

#countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 20vw; font-weight: 900; color: #ffd25e; text-shadow: 0 10px 40px rgba(0,0,0,0.6);
  animation: cd-pulse 1s infinite;
}
@keyframes cd-pulse { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }

#voteoverlay {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(800px, 92vw); background: rgba(10, 16, 38, 0.95); border: 2px solid rgba(255, 210, 94, 0.6);
  border-radius: 22px; padding: 24px 30px; z-index: 60; box-shadow: 0 20px 80px rgba(0,0,0,0.6);
}
#voteoverlay h2 { text-align: center; font-size: 28px; letter-spacing: 3px; color: #ffd25e; }
.vsub { text-align: center; color: #9fb8d8; font-weight: 700; margin: 4px 0 12px; }
#votetimer { height: 8px; background: #1a2646; border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
#votetimerfill { height: 100%; background: #ff9838; border-radius: 999px; transition: width .25s linear; }
#votecards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.vcard {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 120px;
  background: #16213e; border: 2px solid #2c3d63; border-radius: 14px; padding: 12px 18px;
}
.vcard.voted { border-color: #6dffa8; }
.vcard .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; }
.vcard .vname { font-weight: 900; font-size: 17px; }
.vcard .vcount { font-size: 22px; font-weight: 900; color: #ff8d8d; min-height: 26px; }
.vcard .vstate { font-size: 12px; color: #8aa2c4; font-weight: 700; }
#voteskip { text-align: center; margin-top: 14px; color: #8aa2c4; font-weight: 700; }

#voteflash {
  position: fixed; top: 52%; left: 50%; transform: translate(-50%, -50%); z-index: 70; background: rgba(8,12,34,.55); padding: 18px 34px; border-radius: 24px;
  text-align: center; pointer-events: none; animation: vf-in .35s ease;
}
#vfmain { font-size: clamp(30px, 5.5vw, 68px); font-weight: 900; letter-spacing: 3px; text-shadow: 0 6px 30px rgba(0,0,0,0.8); white-space: nowrap; }
#vfsub { margin-top: 10px; font-size: clamp(18px, 2.6vw, 32px); font-weight: 900; text-shadow: 0 4px 20px rgba(0,0,0,0.8); }
#voteflash.cut #vfmain { color: #ff5d5d; }
#voteflash.safe #vfmain { color: #8dffb4; }
#voteflash .yeti { color: #ff9ad0; }
#voteflash .innocent { color: #bcd7ff; }
@keyframes vf-in { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

#end h1 { font-size: clamp(50px, 9vw, 120px); letter-spacing: 6px; text-shadow: 0 6px 0 #16324f, 0 14px 40px rgba(0,0,0,0.5); text-align: center; }
#end.won h1 { color: #ffd25e; }
#end.lost h1 { color: #9fc3ff; }
#endstats { font-size: clamp(18px, 2.4vw, 26px); margin: 18px 0 6px; color: #d7e6ff; font-weight: 700; text-align: center; line-height: 1.5; }
#endyeti {
  margin-top: 14px; font-size: clamp(20px, 3vw, 32px); font-weight: 900;
  background: rgba(10, 16, 38, 0.9); border: 2px solid #ffd25e; border-radius: 18px; padding: 16px 34px;
}
#endyeti .dot { display: inline-block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; margin: 0 6px -3px; }
#endbtns { margin-top: 30px; display: flex; gap: 18px; }
#endbtns button {
  padding: 15px 40px; font-size: 21px; font-weight: 900; letter-spacing: 2px; border-radius: 14px; cursor: pointer; font-family: inherit;
  border: 2px solid rgba(140, 190, 255, 0.4); background: #16213e; color: #eef4ff;
}
#rematchbtn { background: linear-gradient(180deg, #ffd25e, #ff9838) !important; color: #3d2200 !important; border: none !important; box-shadow: 0 5px 0 #b05e12; }
#errorbox h2 { font-size: 32px; text-align: center; max-width: 700px; }
