:root {
  --panel: rgba(17, 18, 23, 0.55);
  --panel-solid: rgba(17, 18, 23, 0.82);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.7);
  --gold: #ffd23f;
  --pink: #ff3d7f;
  --cyan: #3dd6ff;
  --ui: "Fredoka", "Segoe UI", system-ui, sans-serif;
  --title: "Luckiest Guy", "Fredoka", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd0ff; font-family: var(--ui); color: var(--text); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }
button { font-family: var(--ui); cursor: pointer; }

.stroke { text-shadow: 0 2px 0 #000, 0 -2px 0 #000, 2px 0 0 #000, -2px 0 0 #000, 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000; }

#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }
#hud button, #hud input { pointer-events: auto; }

/* ---------- phase pill */
#phase-pill {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border-radius: 999px; padding: 8px 22px; display: flex; gap: 14px; align-items: baseline;
  font-weight: 700; font-size: 18px; white-space: nowrap; backdrop-filter: blur(4px);
}
#phase-timer { font-family: var(--title); font-size: 26px; color: var(--gold); min-width: 2ch; text-align: right; }
#phase-timer.urgent { color: #ff4d6d; animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.18); } }

/* ---------- chat (top-left, Roblox legacy chat) */
#chat { position: absolute; top: 12px; left: 12px; width: min(420px, 46vw); }
#chat-log {
  background: rgba(0, 0, 0, 0.32); border-radius: 8px; padding: 8px 10px; height: 190px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; font-size: 15px; font-weight: 600; line-height: 1.32;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22%);
}
#chat-log .msg { text-shadow: 0 1px 2px #000, 0 0 2px #000; overflow-wrap: anywhere; }
#chat-log .name { font-weight: 700; }
#chat-input {
  margin-top: 6px; width: 100%; background: rgba(0, 0, 0, 0.42); border: 2px solid transparent; border-radius: 8px;
  color: #fff; padding: 8px 10px; font: 600 14px var(--ui); outline: none;
}
#chat-input:focus { border-color: rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.6); }
#chat-input::placeholder { color: rgba(255, 255, 255, 0.6); }

/* ---------- player list (top-right) */
#playerlist { position: absolute; top: 12px; right: 12px; width: 260px; background: var(--panel); border-radius: 8px; overflow: hidden; font-size: 14px; }
#playerlist.collapsed #pl-rows { display: none; }
.pl-head, .pl-row { display: grid; grid-template-columns: 1fr 64px 44px; gap: 6px; padding: 6px 10px; align-items: center; }
.pl-head { background: rgba(0, 0, 0, 0.35); font-weight: 700; color: var(--muted); font-size: 13px; }
.pl-row { font-weight: 600; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.pl-row span:not(:first-child), .pl-head span:not(:first-child) { text-align: right; }
.pl-row .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-row.me { background: rgba(255, 210, 63, 0.18); }
.pl-row .neg { color: #ff7b8f; }

/* ---------- big announcements */
#announce { position: absolute; top: 30%; left: 0; right: 0; text-align: center; pointer-events: none; }
#announce .a-title {
  font-family: var(--title); font-size: clamp(42px, 8vw, 104px); letter-spacing: 1px; line-height: 1;
  -webkit-text-stroke: 3px #000; paint-order: stroke fill; text-shadow: 0 6px 0 rgba(0, 0, 0, 0.45);
  animation: pop 0.45s cubic-bezier(.2, 1.6, .4, 1) both;
}
#announce .a-sub { margin-top: 10px; font-size: clamp(18px, 2.4vw, 28px); font-weight: 700; animation: fadeup 0.5s 0.1s both; }
#announce .out { animation: fadeout 0.35s forwards; }
@keyframes pop { from { transform: scale(0.2) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes fadeup { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeout { to { opacity: 0; transform: scale(1.1); } }
.rainbow { background: linear-gradient(90deg, #ff3d7f, #ffd23f, #6bff7b, #3dd6ff, #b36bff, #ff3d7f); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent !important; animation: pop 0.45s cubic-bezier(.2, 1.6, .4, 1) both, slide 1s linear infinite !important; }
@keyframes slide { to { background-position: 300% 0; } }

/* ---------- item card (round intro) */
#item-card {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: var(--panel-solid); border-radius: 16px; padding: 14px 26px; text-align: center; min-width: 320px;
  border: 3px solid rgba(255, 255, 255, 0.12); animation: fadeup 0.4s both;
}
#item-card .ic-round { color: var(--muted); font-weight: 700; letter-spacing: 2px; font-size: 14px; }
#item-card .ic-name { font-family: var(--title); font-size: 46px; color: var(--gold); }
#item-card .ic-mut { margin-top: 4px; font-weight: 700; font-size: 18px; }
#item-card .ic-mut small { display: block; color: var(--muted); font-weight: 600; font-size: 15px; }

/* ---------- cut help */
#cut-help {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: var(--panel-solid); border-radius: 999px; padding: 10px 22px; font-weight: 700; font-size: 17px; white-space: nowrap;
}
#cut-help kbd { background: #fff; color: #111; border-radius: 6px; padding: 1px 7px; margin: 0 3px; font-family: var(--ui); }

/* ---------- personal result card */
#result-card {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%);
  background: var(--panel-solid); border-radius: 18px; padding: 16px 26px; text-align: center; min-width: 360px;
  animation: pop 0.4s cubic-bezier(.2, 1.4, .4, 1) both; border: 3px solid var(--tier, #fff);
}
#result-card .rc-grams { display: flex; gap: 18px; justify-content: center; align-items: baseline; font-family: var(--title); font-size: 38px; color: #ffe14d; }
#result-card .rc-grams i { font-style: normal; color: var(--muted); font-size: 22px; font-family: var(--ui); }
#result-card .rc-acc { font-size: 22px; font-weight: 700; margin-top: 2px; }
#result-card .rc-tier { font-family: var(--title); font-size: 40px; color: var(--tier, #fff); margin-top: 4px; }
#result-card .rc-quip { font-weight: 600; color: var(--muted); font-size: 17px; }
#result-card .rc-aura { font-family: var(--title); font-size: 26px; margin-top: 6px; }
#result-card .rc-off { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ---------- round results */
#round-results {
  position: absolute; top: 50%; right: 12px; transform: translateY(-40%); width: 330px;
  background: var(--panel-solid); border-radius: 12px; padding: 12px; animation: fadeup 0.35s both;
}
#round-results h3 { margin: 0 0 8px; font-family: var(--title); font-weight: 400; font-size: 24px; color: var(--gold); text-align: center; }
.rr-row { display: grid; grid-template-columns: 22px 1fr 64px 58px; gap: 6px; padding: 5px 4px; font-weight: 600; font-size: 14px; align-items: center; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.rr-row .rr-acc { text-align: right; font-weight: 700; }
.rr-row .rr-aura { text-align: right; font-family: var(--title); font-size: 15px; }
.rr-row.me { background: rgba(255, 210, 63, 0.15); border-radius: 6px; }
.rr-row small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- feed (kill-feed style) */
#feed { position: absolute; right: 12px; top: 40%; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; width: 330px; }
#feed .toast { background: var(--panel-solid); border-radius: 8px; padding: 6px 12px; font-weight: 700; font-size: 14px; animation: slidein 0.3s both; border-left: 4px solid var(--c, #fff); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- emote bar + corner buttons */
#emote-bar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
#emote-bar button, #corner-buttons button {
  background: var(--panel); border: 2px solid rgba(255, 255, 255, 0.15); color: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 15px;
  transition: transform 0.1s, background 0.15s;
}
#emote-bar button:hover, #corner-buttons button:hover { background: rgba(255, 255, 255, 0.25); transform: translateY(-2px); }
#emote-bar button b { display: inline-block; background: rgba(255, 255, 255, 0.85); color: #111; border-radius: 5px; padding: 0 6px; margin-right: 6px; font-size: 12px; }
#corner-buttons { position: absolute; bottom: 14px; right: 12px; display: flex; gap: 8px; }
#corner-buttons button.off { opacity: 0.45; }
#controls-hint { position: absolute; bottom: 18px; left: 12px; font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 2px #000; max-width: 30vw; }

#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
#flash.go { animation: flash 0.6s ease-out; }
@keyframes flash { from { opacity: 0.55; } to { opacity: 0; } }

/* ---------- join screen */
#join-screen {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 61, 127, 0.55), transparent 50%), radial-gradient(circle at 75% 80%, rgba(61, 214, 255, 0.5), transparent 55%), rgba(10, 10, 18, 0.72);
}
.join-card { width: min(560px, 100%); background: rgba(20, 20, 28, 0.92); border-radius: 22px; padding: 28px; border: 3px solid rgba(255, 255, 255, 0.1); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.logo { font-family: var(--title); font-size: clamp(40px, 9vw, 64px); color: var(--gold); -webkit-text-stroke: 2px #000; paint-order: stroke fill; text-shadow: 0 5px 0 #000; line-height: 1; }
.logo span { display: inline-block; animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(-18deg) translateY(-4px); } }
.sub { color: var(--muted); font-weight: 600; margin: 8px 0 16px; }
.how { display: grid; gap: 8px; margin-bottom: 18px; font-weight: 500; }
.how b { display: inline-block; width: 28px; }
.join-card label { font-weight: 700; font-size: 13px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.join-row { display: flex; gap: 10px; margin-top: 6px; }
#name-input { flex: 1; min-width: 0; font: 700 18px var(--ui); padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #fff; outline: none; }
#name-input:focus { border-color: var(--gold); }
#play-btn { font-family: var(--title); font-size: 26px; padding: 8px 28px; border-radius: 12px; border: none; background: #00b06f; color: #fff; box-shadow: 0 5px 0 #007a4d; }
#play-btn:hover { filter: brightness(1.1); }
#play-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #007a4d; }
#join-status { margin-top: 12px; color: var(--muted); font-size: 14px; font-weight: 600; }

@media (max-width: 760px) {
  #playerlist { width: 200px; font-size: 12px; }
  #round-results, #feed { width: 260px; }
  #controls-hint { display: none; }
  #chat-log { height: 120px; }
  #emote-bar button { padding: 6px 8px; font-size: 13px; }
}
