* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #171a38; --panel: #212549; --panel2: #2a2f5e;
  --ink: #eef0ff; --muted: rgba(238,240,255,.6);
  --gold: #fcc419;
  --red: #ed2b33; --green: #0aa64f; --yellow: #fdd835; --blue: #27aeff;
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: radial-gradient(circle at 50% 15%, #2b2450, var(--bg) 70%);
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

.hidden { display: none !important; }
.screen {
  position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; z-index: 10;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#game.screen { z-index: 5; }
.panel { margin: auto; text-align: center; padding: 26px; width: min(400px, 94vw); animation: pin .3s ease; }
@keyframes pin { from { transform: translateY(16px) scale(.97); opacity: 0; } }

.crown { font-size: 34px; letter-spacing: 4px; margin-bottom: 6px; }
h1 { font-size: 34px; font-weight: 900; letter-spacing: 1px; line-height: 1; }
h1 span {
  display: block; font-size: 22px; letter-spacing: 4px; margin-top: 2px;
  background: linear-gradient(135deg, #ffe07a, var(--gold), #ff8a3d);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
h2 { font-size: 26px; font-weight: 900; letter-spacing: 3px; margin-bottom: 14px; }
.tag { color: var(--muted); font-weight: 600; margin: 10px 0 16px; }

input {
  width: 100%; padding: 13px 16px; margin: 10px 0 6px;
  border-radius: 14px; border: 2px solid var(--panel2);
  background: var(--panel); color: var(--ink);
  font-size: 16px; font-weight: 700; text-align: center; outline: none;
}
input:focus { border-color: var(--gold); }

button { font-family: inherit; cursor: pointer; }
button.big {
  display: block; width: 100%; margin: 10px 0; padding: 14px 0;
  font-size: 17px; font-weight: 900; letter-spacing: 1px;
  color: #08331a; background: linear-gradient(135deg, #6dedb0, #22c76a);
  border: none; border-radius: 16px;
  box-shadow: 0 5px 0 #169148, 0 10px 24px rgba(0,0,0,.35);
  transition: transform .08s;
}
button.big small { display: block; font-size: 11px; font-weight: 700; opacity: .7; margin-top: 2px; }
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #169148; }
button.big.alt { color: #0b2d4a; background: linear-gradient(135deg, #74c0fc, #339af0); box-shadow: 0 5px 0 #1c7ed6, 0 10px 24px rgba(0,0,0,.35); }
button.big.gold { color: #4a2c00; background: linear-gradient(135deg, #ffe07a, #fcc419); box-shadow: 0 5px 0 #c77e0a, 0 10px 24px rgba(0,0,0,.35); }
button.big.gold:active { box-shadow: 0 2px 0 #c77e0a; }
button.big:disabled { filter: grayscale(.8); opacity: .5; }
.ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 700; margin-top: 10px; text-decoration: none; padding: 8px 16px; }
.mini { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; background: var(--panel2); color: var(--ink); border: none; padding: 9px 16px; border-radius: 12px; font-size: 13px; font-weight: 800; }
.err { color: #ff8787; font-weight: 700; font-size: 14px; min-height: 20px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 600; }
.orSep { color: var(--muted); font-size: 13px; font-weight: 700; margin: 14px 0 6px; }
.joinRow { display: flex; gap: 8px; }
.joinRow input { flex: 1; margin: 0; text-transform: uppercase; letter-spacing: 4px; }
.joinRow button { padding: 0 22px; border: none; border-radius: 14px; font-weight: 900; background: var(--gold); color: #4a2c00; font-size: 15px; }
.roomCode { font-size: 44px; font-weight: 900; letter-spacing: 9px; color: var(--gold); margin: 4px 0 8px; }
.lobbyPlayers { margin: 12px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.lobbySeat { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 14px; padding: 8px 12px; font-weight: 800; font-size: 15px; }
.lobbySeat .seatAv { width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 19px; background: var(--panel2); }
.lobbySeat .tag { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: 1px; }
.lobbySeat.empty { opacity: .35; font-weight: 600; }
.lobbyBtns { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }

/* ================= game ================= */
#gameWrap {
  width: 100%; max-width: 460px; margin: auto; min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 16px 16px 28px;
}
/* compact layout so the prompt stays on screen at short heights (e.g. 360x640) */
@media (max-height: 700px) {
  #topInfo { margin-bottom: 8px; }
  #myRoleCard { padding: 10px; margin-bottom: 10px; }
  #myRoleCard .emoji { font-size: 36px; }
  #myRoleCard .label { font-size: 19px; }
  #myRoleCard .pts { font-size: 13px; }
  #players { gap: 8px; margin-bottom: 10px; }
  .pcard { padding: 9px; }
  .pcard .av { font-size: 29px; }
  .pcard .nm { font-size: 13px; }
  .pcard .rl { min-height: 14px; margin-top: 2px; font-size: 11px; }
  .pcard .say { min-height: 18px; font-size: 10px; }
  #prompt { font-size: 14px; min-height: 20px; }
}
#topInfo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
#roundChip { background: var(--panel); border-radius: 14px; padding: 6px 16px; font-weight: 900; color: var(--gold); }
#lvlChip { background: var(--panel); border-radius: 14px; padding: 6px 12px; font-weight: 900; color: #74c0fc; }
.topBtns { display: flex; gap: 8px; }
#btnTells { font-size: 18px; }
.quit { width: 44px; height: 44px; border-radius: 12px; border: none; background: rgba(255,255,255,.1); color: var(--ink); font-size: 22px; font-weight: 800; }
.quit:active, .mini:active { transform: scale(.94); }

#myRoleCard {
  border-radius: 20px; padding: 22px;
  text-align: center; margin-bottom: 16px;
  animation: flip .5s ease;
  box-shadow: 0 12px 34px rgba(0,0,0,.4);
}
@keyframes flip { from { transform: rotateY(90deg); } }
#myRoleCard .emoji { font-size: 56px; line-height: 1.15; }
#myRoleCard .label { font-size: 26px; font-weight: 900; letter-spacing: 2px; margin-top: 4px; }
#myRoleCard .pts { font-weight: 800; opacity: .85; margin-top: 2px; }
.role-raja { background: linear-gradient(135deg, #ffe07a, #f5b301); color: #5b3a00; }
.role-mantri { background: linear-gradient(135deg, #b197fc, #7048e8); color: #fff; }
.role-sipahi { background: linear-gradient(135deg, #74c0fc, #1971c2); color: #fff; }
.role-chor { background: linear-gradient(135deg, #495057, #212529); color: #fff; }

#players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.pcard {
  background: var(--panel); border: 2px solid transparent; border-radius: 16px;
  padding: 12px; text-align: center; position: relative;
  transition: all .2s;
}
.pcard.guessable { cursor: pointer; border-color: var(--gold); box-shadow: 0 0 18px rgba(252,196,25,.3); }
.pcard.guessable:active { transform: scale(.96); }
.pcard.me { border-color: rgba(255,255,255,.3); }
.pcard .av { font-size: 34px; line-height: 1.15; }
.pcard .nm { font-weight: 800; font-size: 14px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .sc { color: var(--gold); font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.pcard .rl { font-size: 12px; font-weight: 800; margin-top: 4px; min-height: 16px; }
.pcard .rl:empty { display: none; }
.pcard .catch { position: absolute; top: 6px; right: 8px; font-size: 20px; }
.pcard .mark { position: absolute; top: 6px; left: 8px; font-size: 18px; animation: pin .25s ease; }
.pcard .sweat { position: absolute; top: 4px; right: 6px; font-size: 17px; animation: sweatDrip 1.6s ease-in-out infinite; }
.pcard.tell .av { display: inline-block; animation: nervous 1.6s ease-in-out infinite; }
@keyframes nervous {
  0%, 100% { transform: rotate(0) translateX(0); }
  8% { transform: rotate(-6deg) translateX(-2px); }
  16% { transform: rotate(5deg) translateX(2px); }
  24% { transform: rotate(-4deg) translateX(-1px); }
  32% { transform: rotate(0) translateX(0); }
}
@keyframes sweatDrip {
  0%, 100% { transform: translateY(0); opacity: .9; }
  50% { transform: translateY(3px); opacity: .55; }
}

/* layered tells (vs bots) */
.pcard .shifty { position: absolute; top: 36px; left: 6px; font-size: 14px; opacity: 0; animation: tellIn .3s ease forwards; }
.pcard .shifty span { display: inline-block; animation: eyeDart 1.7s ease-in-out infinite; }
@keyframes tellIn { to { opacity: .95; } }
@keyframes eyeDart {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}
.pcard .say { min-height: 21px; margin-top: 4px; font-size: 10.5px; font-weight: 700; color: var(--muted); line-height: 1.25; }
.pcard .say span {
  display: inline-block; max-width: 100%; opacity: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(255,255,255,.08); border-radius: 9px; padding: 2px 7px;
}
@keyframes sayIn { to { opacity: 1; } }
@keyframes sayOut { to { opacity: 0; } }
/* higher difficulty: tells get fainter, smaller and calmer */
.pcard.sub1 .sweat, .pcard.sub1 .shifty { filter: opacity(.6); }
.pcard.sub2 .sweat, .pcard.sub2 .shifty { filter: opacity(.42); }
.pcard.sub1 .sweat { font-size: 15px; }
.pcard.sub2 .sweat { font-size: 13px; }
.pcard.sub1.tell .av { animation-duration: 2.2s; }
.pcard.sub2.tell .av { animation-duration: 2.8s; }

#prompt { text-align: center; font-weight: 800; font-size: 16px; min-height: 24px; margin-bottom: 8px; }
#prompt.act { color: var(--gold); }

#revealBackdrop {
  position: fixed; inset: 0; z-index: 44;
  background: radial-gradient(circle at 50% 62%, rgba(8,6,24,.34), rgba(8,6,24,.74));
  animation: rbFade .28s ease both;
}
@keyframes rbFade { from { opacity: 0; } }

#revealBox {
  position: fixed; left: 50%; bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
  transform: translateX(-50%);
  width: min(440px, 92vw); max-height: 82vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 2px solid rgba(255,255,255,.08);
  border-radius: 22px; padding: 20px 18px 18px; text-align: center;
  font-weight: 800; z-index: 46;
  box-shadow: 0 -8px 44px rgba(0,0,0,.55), 0 0 0 4px rgba(0,0,0,.14);
  animation: revealSheet .44s cubic-bezier(.16,1.12,.3,1) both;
  overscroll-behavior: contain;
}
#revealBox::before {
  content: ''; display: block; width: 40px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,.22); margin: -6px auto 12px;
}
@keyframes revealSheet {
  from { transform: translate(-50%, 70px); opacity: 0; }
}
#revealBox.correct { border-color: rgba(109,237,176,.5); box-shadow: 0 -8px 44px rgba(0,0,0,.55), 0 0 34px rgba(34,199,106,.34); }
#revealBox.wrong { border-color: rgba(255,135,135,.5); box-shadow: 0 -8px 44px rgba(0,0,0,.55), 0 0 34px rgba(237,43,51,.32); }
#revealBox .big {
  font-size: 22px; margin-bottom: 6px; line-height: 1.15;
  animation: stampIn .5s cubic-bezier(.2,1.5,.35,1) both;
}
@keyframes stampIn {
  0% { transform: scale(2.3); opacity: 0; }
  55% { transform: scale(.9); opacity: 1; }
  100% { transform: scale(1); }
}
#revealBox .big.good { text-shadow: 0 0 22px rgba(109,237,176,.6); }
#revealBox .big.bad { text-shadow: 0 0 22px rgba(255,135,135,.55); }
#revealBox .side { font-size: 14px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.12); animation: rbFade .5s .18s ease both; }
#revealBox .good { color: #6dedb0; }
#revealBox .bad { color: #ff8787; }
#revealBox .next {
  margin-top: 14px; font-size: 13px; font-weight: 900; letter-spacing: 1.5px;
  color: #4a2c00; background: linear-gradient(135deg, #ffe07a, var(--gold));
  padding: 11px 0; border-radius: 13px; box-shadow: 0 4px 0 #c77e0a;
  animation: nextPulse 1.15s ease-in-out infinite;
}
#revealBox.tappable { cursor: pointer; }
#revealBox.tappable:active { transform: translateX(-50%) scale(.985); }
#revealBox.tappable:active .next { box-shadow: 0 2px 0 #c77e0a; transform: translateY(2px); }
@keyframes nextPulse { 50% { filter: brightness(1.12); } }

.shareBtn {
  display: block; width: 100%; margin: 2px 0 4px; padding: 12px 0;
  font-size: 14px; font-weight: 900; letter-spacing: 1px;
  color: #08331a; background: linear-gradient(135deg, #63e6be, #20c997);
  border: none; border-radius: 14px; box-shadow: 0 4px 0 #099268;
}
.shareBtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #099268; }

/* pass-and-play */
#hsPass { z-index: 40; background: radial-gradient(circle at 50% 15%, #2b2450, var(--bg) 70%); }
#hsPass input { margin: 6px 0; }
#hsRoleCard {
  border-radius: 20px; padding: 20px; margin: 12px 0 4px;
  animation: flip .5s ease;
  box-shadow: 0 12px 34px rgba(0,0,0,.4);
}
#hsRoleCard .emoji { font-size: 52px; }
#hsRoleCard .label { font-size: 24px; font-weight: 900; letter-spacing: 2px; margin-top: 4px; }
#hsRoleCard .pts { font-weight: 800; opacity: .85; margin-top: 2px; font-size: 14px; }

/* toast sits below the top bar, never over the prompt (which lives at the bottom) */
#toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 62px); bottom: auto;
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; font-weight: 800; font-size: 14px;
  padding: 8px 18px; border-radius: 18px; opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 55;
  max-width: 88vw; width: max-content; text-align: center; line-height: 1.4;
}
#toast.show { opacity: 1; }

#winCrown { font-size: 52px; }
.coinWin { font-weight: 900; font-size: 15px; color: var(--muted); margin: 2px 0 6px; }
.coinWin.win {
  color: #4a2c00; background: linear-gradient(135deg, #ffe07a, var(--gold));
  display: inline-block; padding: 5px 16px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(252,196,25,.35); animation: coinPop .5s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes coinPop { from { transform: scale(.4); opacity: 0; } }
.winStreak { font-weight: 800; font-size: 13px; color: var(--gold); margin: 0 0 8px; letter-spacing: .3px; }
.lvlUp {
  font-weight: 900; font-size: 14px; color: #6dedb0;
  background: rgba(34,199,106,.12); border: 1px solid rgba(109,237,176,.35);
  border-radius: 14px; padding: 8px 12px; margin: 2px 0 8px;
  animation: coinPop .5s cubic-bezier(.2,1.4,.4,1) both;
}
.lvlUp .newp { font-size: 12px; font-weight: 700; color: var(--ink); opacity: .85; margin-top: 3px; }

/* how-to-read-tells overlay */
#tellsHelp {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(8,6,24,.82);
  animation: rbFade .25s ease both;
}
.thBox {
  background: var(--panel); border: 2px solid rgba(255,255,255,.08);
  border-radius: 20px; padding: 20px 18px;
  width: min(420px, 94vw); max-height: 88vh; overflow-y: auto;
  text-align: left; animation: pin .3s ease;
}
.thBox h2 { text-align: center; font-size: 20px; letter-spacing: 2px; margin-bottom: 10px; }
.thRow { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 13.5px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.thRow span { font-size: 22px; flex: none; width: 28px; text-align: center; }
.thRow b { color: var(--gold); }
.thSub { font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--muted); margin: 12px 0 2px; text-transform: uppercase; }
#rankList { margin: 8px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.rankRow { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 14px; padding: 10px 14px; font-weight: 800; font-size: 15px; }
.rankRow .medal { font-size: 20px; }
.rankRow .sc { margin-left: auto; color: var(--gold); font-size: 14px; }

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
