/* style.css — DooRoo, phone-only unified build.
   Bright & playful party-game look (Kahoot/Jackbox-inspired): warm light
   background, bold flat accent colors, chunky "3D-press" buttons, rounded
   friendly type. Layout is flex/grid + logical properties only (no
   left/right) so dir="rtl" on <body> mirrors everything automatically. */

:root {
  --bg-app: #FFF8F0;
  --bg-card: #FFFFFF;
  --bg-card-2: #FBF5FF;
  --bg-badge: #F3ECFF;
  --border-soft: #EDE3F9;
  --border-strong: #DCCCF2;

  --purple: #7C4DFF;
  --purple-dark: #5B32D6;
  --pink: #FF6FB5;
  --pink-dark: #E0428F;
  --coral: #FF5A6E;
  --coral-dark: #D63D50;
  --blue: #3D8BFD;
  --blue-dark: #2563D9;
  --gold: #FFC93C;
  --gold-dark: #E0A600;
  --green: #34C759;
  --green-dark: #229A44;
  --orange: #FF9F45;
  --orange-dark: #DB7C22;

  --text-primary: #2B2540;
  --text-dim: #6E6484;
  --text-faint: #A79FBD;

  /* Latin text uses the playful Baloo 2 / Nunito pair; Kurdish Sorani and
     Arabic fall through to Noto Sans Arabic. Noto is built for complete
     Unicode-block coverage rather than just "Arabic language," so it has
     the Kurdish-specific letters (ە ێ ۆ ڵ ڕ etc.) that narrower Arabic
     webfonts often lack — a missing glyph silently swaps just that one
     character to a different fallback font mid-word, which is what made
     Kurdish text look broken/inconsistent before this. Deliberately only
     one Arabic-script font in the stack, not two, so there's no seam for
     glyphs to split across. */
  --font-display: 'Baloo 2', 'Noto Sans Arabic', system-ui, sans-serif;
  --font-body: 'Nunito', 'Noto Sans Arabic', system-ui, -apple-system, sans-serif;
  --font-mono: 'Nunito', 'Noto Sans Arabic', system-ui, sans-serif;

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-round: 999px;

  --shadow-purple: 0 6px 16px rgba(124, 77, 255, 0.28);
  --shadow-pink: 0 6px 16px rgba(255, 111, 181, 0.3);
  --shadow-coral: 0 6px 14px rgba(255, 90, 110, 0.32);
  --shadow-gold: 0 6px 14px rgba(255, 201, 60, 0.35);
  --shadow-blue: 0 6px 14px rgba(61, 139, 253, 0.3);
  --shadow-card: 0 2px 0 var(--border-strong), 0 10px 24px rgba(43, 37, 64, 0.07);
  --scrim: rgba(43, 37, 64, 0.55);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-inline-start: env(safe-area-inset-left, 0px);
  --safe-inline-end: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input { font-family: inherit; }
::selection { background: var(--pink); color: #fff; }
body.rtl { direction: rtl; }
body.ltr { direction: ltr; }
.hidden { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--purple); }

@keyframes glowPulse { 0%, 100% { filter: drop-shadow(0 0 0 transparent); } 50% { filter: drop-shadow(0 4px 10px currentColor); } }
@keyframes screenShake {
  0% { transform: translate(0, 0); } 20% { transform: translate(-8px, 5px) rotate(-0.5deg); }
  40% { transform: translate(7px, -5px) rotate(0.5deg); } 60% { transform: translate(-5px, 3px) rotate(-0.3deg); }
  80% { transform: translate(5px, -2px) rotate(0.3deg); } 100% { transform: translate(0, 0); }
}
.screen-shake { animation: screenShake 420ms ease-in-out; }
@keyframes pulseRedBg { 0%, 100% { background-color: transparent; } 50% { background-color: rgba(255, 90, 110, 0.22); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spinSlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes scoreFloat {
  0% { opacity: 0; transform: translateY(0) scale(0.8); } 15% { opacity: 1; transform: translateY(-4px) scale(1); }
  85% { opacity: 1; transform: translateY(-26px) scale(1); } 100% { opacity: 0; transform: translateY(-36px) scale(0.9); }
}
@keyframes laserDraw { from { stroke-dashoffset: 200; opacity: 0; } 15% { opacity: 1; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes screenFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes gentleBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(340px) rotate(540deg); opacity: 0; }
}

.btn {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
  border-radius: var(--radius-md);
  padding: 0.85em 1.4em;
  font-weight: 700;
  font-size: 1.02rem;
  position: relative;
  transition: transform 100ms ease, box-shadow 100ms ease, filter 100ms ease;
}
.btn:active { transform: translateY(4px); filter: brightness(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--purple); color: #fff; box-shadow: 0 5px 0 var(--purple-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--purple-dark); }
.btn-secondary { background: var(--bg-card); border: 2px solid var(--border-strong); color: var(--text-dim); box-shadow: 0 4px 0 var(--border-strong); }
.btn-secondary:active { box-shadow: 0 0 0 var(--border-strong); }
.btn-block { width: 100%; }

/* ============================================================ app frame
   True fullscreen edge-to-edge on a phone; a centered "phone card" when
   the same app is opened on a wider screen (laptop testing, casting). */
body {
  display: flex; align-items: center; justify-content: center;
  width: 100vw; overflow: hidden;
}
#app-frame {
  position: relative;
  width: 100%; height: 100dvh;
  max-width: 480px;
  background: var(--bg-app);
  overflow: hidden;
}
.desktop-brand { display: none; }
@media (min-width: 640px) {
  body {
    padding: 2rem; height: 100vh;
    flex-direction: column; gap: 1.6rem;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    position: relative; overflow: hidden;
  }
  /* soft ambient depth behind the device card — decorative only */
  body::before, body::after {
    content: ''; position: absolute; border-radius: 50%;
    filter: blur(70px); opacity: 0.4; pointer-events: none; z-index: 0;
  }
  body::before { width: 380px; height: 380px; background: var(--gold); top: -130px; inset-inline-start: -130px; }
  body::after { width: 420px; height: 420px; background: var(--teal, #2EC4B6); bottom: -150px; inset-inline-end: -150px; }

  .desktop-brand {
    display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    position: relative; z-index: 1;
  }
  .desktop-brand .db-logo {
    width: 46px; height: 46px; border-radius: 50%;
    background: conic-gradient(#fff 0deg 180deg, rgba(255,255,255,.65) 180deg 360deg);
    border: 3px solid rgba(255,255,255,.55);
    box-shadow: 0 10px 26px rgba(43, 37, 64, 0.3);
  }
  .desktop-brand .db-title {
    font-family: var(--font-display); font-weight: 800; font-size: 1.5rem;
    color: #fff; text-shadow: 0 2px 14px rgba(43, 37, 64, 0.3);
  }
  .desktop-brand .db-tag { color: rgba(255,255,255,.9); font-weight: 700; font-size: 0.92rem; }

  #app-frame {
    height: min(860px, 90dvh);
    border-radius: 34px;
    box-shadow: 0 30px 70px rgba(43, 37, 64, 0.45);
    position: relative; z-index: 1;
  }
  /* phone-bezel chrome — purely decorative, only shown once the app is a
     centered "device card" rather than a true edge-to-edge mobile view */
  #app-frame::before {
    content: '';
    position: absolute; top: 0; inset-inline: 0;
    margin-inline: auto;
    width: 118px; height: 20px;
    background: var(--bg-app);
    border: 1px solid var(--border-soft); border-top: none;
    border-radius: 0 0 14px 14px;
    z-index: 40; pointer-events: none;
  }
  #app-frame::after {
    content: '';
    position: absolute; bottom: 7px; inset-inline: 0;
    margin-inline: auto;
    width: 92px; height: 4px;
    background: var(--border-strong);
    border-radius: var(--radius-round);
    z-index: 40; pointer-events: none;
  }
}

#root {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-inline-start: var(--safe-inline-start);
  padding-inline-end: var(--safe-inline-end);
  transition: background-color 200ms ease;
}
#root.timer-critical { animation: pulseRedBg 1s ease-in-out infinite; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.screen.hidden { display: none; }
.screen:not(.hidden) { animation: screenFadeIn 260ms ease; }
.center-screen { align-items: center; justify-content: center; text-align: center; gap: 1rem; padding: 2rem 1.4rem; overflow-y: auto; }

.lang-row { display: flex; gap: 0.5rem; justify-content: center; }
.lang-btn {
  padding: 0.4em 0.85em; border-radius: var(--radius-round);
  border: 2px solid var(--border-strong); color: var(--text-dim);
  font-size: 0.82rem; font-family: var(--font-display); font-weight: 700;
  background: var(--bg-card);
  transition: transform 120ms ease, color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.lang-btn:active { transform: scale(0.92); }
.lang-btn.active { color: #fff; background: var(--purple); border-color: var(--purple); }

.status-bar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1rem; gap: 0.5rem;
}
.status-chip {
  font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; padding: 0.32em 0.75em;
  border-radius: var(--radius-round); background: var(--bg-card);
  border: 2px solid var(--border-soft); color: var(--text-primary); white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}
.status-chip.score { color: var(--green-dark); border-color: rgba(52, 199, 89, 0.35); }
.status-chip.timer { color: var(--purple); min-width: 3ch; text-align: center; }
.status-chip.timer.critical { color: var(--coral); border-color: var(--coral); background: #fff0f1; }

/* ============================================================ landing */
.logo-mark {
  width: 66px; height: 66px; border-radius: 50%;
  background: conic-gradient(var(--purple) 0deg 180deg, var(--pink) 180deg 360deg);
  box-shadow: var(--shadow-purple);
  border: 3px solid #fff;
  margin-bottom: 0.2rem;
  animation: gentleBounce 2.4s ease-in-out infinite;
}
#screen-landing .app-title { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; color: var(--purple); }
#screen-landing .app-subtitle { color: var(--text-faint); margin-top: -0.4rem; font-weight: 700; }
.landing-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 0.9rem; }
.landing-form input {
  width: 100%; padding: 0.85em 1em; border-radius: var(--radius-md);
  border: 2px solid var(--border-strong); background: var(--bg-card);
  color: var(--text-primary); font-size: 1.05rem; font-weight: 700; text-align: center;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.landing-form input::placeholder { color: var(--text-faint); font-weight: 600; }
.landing-form input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(124,77,255,.15); }
.landing-divider { display: flex; align-items: center; gap: 0.7rem; color: var(--text-faint); font-size: 0.85rem; font-weight: 700; }
.landing-divider::before, .landing-divider::after { content: ''; flex: 1; height: 2px; background: var(--border-soft); }
.join-row { display: flex; gap: 0.6rem; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 0.15em; }
.join-row .btn { flex: 0 0 auto; }
#landing-status { min-height: 1.3em; color: var(--text-dim); font-size: 0.9rem; font-weight: 700; }
#landing-status.error { color: var(--coral-dark); }
.howto-link { color: var(--pink-dark); font-size: 0.95rem; font-weight: 800; padding: 0.4rem; transition: opacity 120ms ease; }
.howto-link:active { opacity: 0.6; }
.leave-room-link { color: var(--coral-dark); font-size: 0.95rem; font-weight: 800; padding: 0.4rem; transition: opacity 120ms ease; }
.leave-room-link:active { opacity: 0.6; }
.reconnect-status { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.reconnect-status.hidden { display: none; }
.reconnect-status .spinner { border-top-color: var(--purple); }
#reconnect-text { color: var(--text-dim); font-weight: 700; font-size: 0.95rem; }

/* ============================================================ lobby */
#screen-lobby { padding: 0 1.1rem 1.1rem; gap: 0.8rem; overflow-y: auto; }
.lobby-code-panel {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  background: var(--bg-card);
  border: 2px solid var(--border-soft); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.1rem; margin-top: 0.4rem;
}
.room-code-label { color: var(--text-dim); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em; }
.room-code {
  font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; letter-spacing: 0.18em;
  color: var(--purple);
  padding: 0.1em 0.5em; border-radius: var(--radius-sm);
  border: 3px dashed var(--border-strong);
}
.qr-wrap { position: relative; padding: 8px; border-radius: var(--radius-md); background: var(--bg-badge); }
#qrcode-box { padding: 10px; background: #fff; border-radius: var(--radius-md); }
#qrcode-box canvas, #qrcode-box img { display: block; width: 132px; height: 132px; }
.scan-hint { color: var(--text-faint); font-size: 0.8rem; font-weight: 700; }

.players-panel {
  flex: 1; min-height: 0; background: var(--bg-card); border: 2px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 1rem 1.1rem; display: flex; flex-direction: column;
  box-shadow: var(--shadow-card);
}
.players-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.7rem; flex: 0 0 auto; }
.players-panel-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; }
#player-count-label { color: var(--green-dark); font-family: var(--font-display); font-weight: 800; font-size: 0.9rem; }
.player-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.player-row {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.55em 0.7em;
  background: var(--bg-card-2); border: 2px solid var(--border-soft); border-radius: var(--radius-md);
  animation: fadeInUp 280ms ease both;
  transition: transform 150ms ease;
}
.player-row .avatar-dot { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; color: var(--text-primary); flex: 0 0 auto; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }
.player-row .p-name { flex: 1; font-size: 0.98rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .p-badge {
  font-family: var(--font-display); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.03em;
  padding: 0.2em 0.55em; border-radius: var(--radius-round); background: var(--bg-badge); color: var(--text-dim);
}
.player-row .p-badge.host { color: var(--gold-dark); background: #fff6de; border: 2px solid var(--gold); }
.player-row .p-badge.you { color: var(--purple); background: #f1ecff; border: 2px solid var(--purple); }
.player-row.disconnected { opacity: 0.45; }

.lobby-footer { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding-top: 0.2rem; }
#start-hint { color: var(--text-dim); font-size: 0.85rem; font-weight: 700; text-align: center; }

/* ============================================================ how-to-play modal */
.modal-backdrop {
  position: absolute; inset: 0; z-index: 60; background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal-sheet {
  width: 100%; max-height: 86%; overflow-y: auto;
  background: var(--bg-app); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.7rem 1.3rem calc(1.3rem + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 1rem;
  position: relative;
  animation: modalSlideUp 260ms cubic-bezier(.2,.8,.3,1);
  box-shadow: 0 -14px 40px rgba(43,37,64,.2);
}
.modal-sheet::before {
  content: ''; position: absolute; top: 10px; inset-inline: 0; margin-inline: auto;
  width: 40px; height: 5px; border-radius: var(--radius-round); background: var(--border-strong);
}
@keyframes modalSlideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-sheet h2 { font-family: var(--font-display); font-weight: 800; color: var(--purple); font-size: 1.35rem; }
.modal-section h3 { font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; color: var(--pink-dark); margin-bottom: 0.5rem; letter-spacing: 0.02em; }
.modal-card-row { display: flex; flex-direction: column; gap: 0.5rem; }
.modal-mini-card {
  display: flex; align-items: flex-start; gap: 0.7rem;
  background: var(--bg-card); border: 2px solid var(--border-soft); border-radius: var(--radius-md);
  padding: 0.65em 0.85em;
}
.modal-mini-card .mc-body { min-width: 0; }
.modal-mini-card b { color: var(--text-primary); font-family: var(--font-display); font-weight: 800; font-size: 0.92rem; }
.modal-mini-card p { color: var(--text-dim); font-size: 0.86rem; font-weight: 600; margin-top: 0.2rem; line-height: 1.35; }
.modal-close-btn { align-self: center; margin-top: 0.2rem; }
.leave-confirm-sheet { border-radius: var(--radius-lg); }
.leave-confirm-sheet h2 { text-align: center; }
.leave-confirm-sheet p { color: var(--text-dim); font-weight: 600; font-size: 0.95rem; line-height: 1.4; text-align: center; }
.leave-confirm-actions { display: flex; gap: 0.7rem; }
.leave-confirm-actions .btn { flex: 1; }

/* shared icon-badge treatment: market/how-to-play mini-cards */
.mc-icon, .mi-icon {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.mc-icon svg, .mi-icon svg { width: 1.15rem; height: 1.15rem; }
.icon-attack, .icon-boobyTrap { background: var(--coral); }
.icon-shield, .icon-guardian { background: var(--blue); }
.icon-greed, .icon-bandit { background: var(--gold); color: var(--text-primary); }
.icon-spyGlasses, .icon-shieldTax { background: var(--purple); }
.icon-doubleAttack, .icon-trickster { background: var(--pink); }
.icon-pitchBlack, .icon-none { background: var(--text-faint); }

/* ============================================================ role reveal overlay */
.role-overlay {
  position: absolute; inset: 0; z-index: 55; background: var(--scrim);
  display: flex; align-items: center; justify-content: center;
}
.role-overlay.hidden { display: none; }
.role-card {
  padding: 1.6rem 1.8rem; border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 3px solid var(--pink); box-shadow: var(--shadow-pink); max-width: 320px; text-align: center;
  animation: popIn 320ms cubic-bezier(.3,1.4,.5,1);
}
.role-card .role-label { color: var(--text-faint); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.1em; margin-bottom: 0.4rem; }
.role-card .role-name { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; color: var(--pink-dark); margin-bottom: 0.5rem; }
.role-card .role-desc { color: var(--text-primary); font-weight: 700; font-size: 1rem; line-height: 1.4; }

/* ============================================================ action screen */
.event-strip { flex: 0 0 auto; text-align: center; padding: 0.4rem; font-family: var(--font-display); font-weight: 800; font-size: 0.82rem; color: var(--purple); background: #f1ecff; }
.event-strip.hidden { display: none; }
.desperation-banner { flex: 0 0 auto; text-align: center; padding: 0.45rem; font-family: var(--font-display); font-weight: 800; font-size: 0.86rem; color: var(--coral-dark); background: #ffeaec; animation: pulseRedBg 1.6s ease-in-out infinite; }
.desperation-banner.hidden { display: none; }

.action-zones { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.action-zone {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.35rem; position: relative; color: #fff;
  transition: transform 90ms ease, filter 120ms ease;
}
.action-zone + .action-zone { box-shadow: inset 0 3px 0 rgba(0,0,0,.07); }
.action-zone:active { transform: scale(0.97); filter: brightness(0.95); }
.action-zone.pressed { transform: scale(0.97); }
.action-zone .zone-icon { line-height: 1; }
.action-zone .zone-icon svg { width: 2.4rem; height: 2.4rem; display: block; }
.action-zone .zone-label { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; letter-spacing: 0.02em; }
.zone-attack { background: var(--coral); }
.zone-shield { background: var(--blue); }
.zone-greed { background: var(--gold); color: var(--text-primary); }
.action-zone.locked-out { opacity: 0.25; pointer-events: none; }
.longpress-caption { flex: 0 0 auto; text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--text-faint); padding: 0.3rem; }

.lock-overlay {
  position: absolute; inset: 0; background: var(--scrim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; z-index: 20;
}
.lock-overlay.hidden { display: none; }
.lock-overlay .lock-icon { color: #fff; background: var(--green); width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-card); }
.lock-overlay .lock-icon svg { width: 1.8rem; height: 1.8rem; }
.lock-overlay .lock-text { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; color: #fff; }
.lock-overlay div:not(.lock-icon):not(.lock-text):not(.spinner) { color: #fff; font-weight: 700; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spinSlow 900ms linear infinite; }

.target-sheet { position: absolute; inset: 0; background: var(--bg-app); display: flex; flex-direction: column; z-index: 15; padding: 1rem; gap: 0.75rem; }
.target-sheet.hidden { display: none; }
.target-sheet h3 { font-family: var(--font-display); font-weight: 800; text-align: center; color: var(--coral-dark); font-size: 1.1rem; }
.target-grid { flex: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.65rem; overflow-y: auto; align-content: start; }
.target-btn { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.8rem 0.5rem; border-radius: var(--radius-md); background: var(--bg-card); border: 3px solid var(--border-soft); color: var(--text-primary); transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease; }
.target-btn:active { transform: scale(0.96); }
.target-btn .avatar-dot { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; color: var(--text-primary); font-size: 1.1rem; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }
.target-btn.chosen { border-color: var(--coral); box-shadow: var(--shadow-coral); }
.target-sheet-footer { flex: 0 0 auto; display: flex; gap: 0.6rem; }
.target-sheet-footer .btn { flex: 1; }
.btn-confirm { background: var(--coral); color: #fff; box-shadow: 0 5px 0 var(--coral-dark); }
.btn-confirm:active { box-shadow: 0 1px 0 var(--coral-dark); }
.btn-confirm:disabled { opacity: 0.35; pointer-events: none; }

.tooltip-backdrop { position: absolute; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 65; padding: 1.4rem; }
.tooltip-backdrop.hidden { display: none; }
.tooltip-card { background: var(--bg-card); border: 3px solid var(--border-soft); border-radius: var(--radius-lg); padding: 1.3rem; max-width: 320px; text-align: center; animation: popIn 220ms cubic-bezier(.3,1.4,.5,1); box-shadow: var(--shadow-card); }
.tt-icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--purple); color: #fff; margin-bottom: 0.6rem; }
.tt-icon svg { width: 1.7rem; height: 1.7rem; }
.tt-icon.hidden { display: none; }
.tooltip-card .tt-name { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.tooltip-card .tt-desc { color: var(--text-dim); font-weight: 600; font-size: 0.98rem; line-height: 1.45; }
.tooltip-card .tt-close { margin-top: 1rem; color: var(--text-faint); font-weight: 700; font-size: 0.82rem; }

/* ============================================================ market */
#screen-market { padding: 0.9rem; gap: 0.7rem; }
.market-head { flex: 0 0 auto; text-align: center; }
.market-head h2 { font-family: var(--font-display); font-weight: 800; color: var(--gold-dark); font-size: 1.3rem; }
.market-timer { font-family: var(--font-body); font-weight: 700; color: var(--text-dim); font-size: 0.85rem; }
.market-list { flex: 1; display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto; min-height: 0; }
.market-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.75rem 0.9rem; background: var(--bg-card); border: 2px solid var(--border-soft); border-radius: var(--radius-md); transition: border-color 150ms ease; }
.market-item.owned { border-color: var(--green); background: #f0fbf2; }
.market-item .mi-body { flex: 1; min-width: 0; }
.market-item .mi-name { font-family: var(--font-display); font-weight: 800; font-size: 0.98rem; }
.market-item .mi-desc { font-size: 0.82rem; font-weight: 600; color: var(--text-dim); }
.market-item .mi-buy { flex: 0 0 auto; padding: 0.55em 0.9em; border-radius: var(--radius-round); background: var(--gold); color: var(--text-primary); font-family: var(--font-display); font-weight: 800; font-size: 0.82rem; box-shadow: 0 3px 0 var(--gold-dark); transition: transform 120ms ease, opacity 120ms ease; }
.market-item .mi-buy:active { transform: translateY(3px); box-shadow: 0 0 0 var(--gold-dark); }
.market-item .mi-buy:disabled { opacity: 0.4; }
.market-item.owned .mi-buy { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-dark); }
.market-footer { flex: 0 0 auto; }
.market-footer .btn { width: 100%; }

/* ============================================================ reveal / arena */
#screen-reveal { padding: 0; }
.reveal-topbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 0.6rem; }
.reveal-topbar .phase-big { font-family: var(--font-display); font-weight: 800; font-size: 1rem; color: var(--text-dim); letter-spacing: 0.04em; }
.reveal-event { flex: 0 0 auto; text-align: center; padding: 0.3rem; font-family: var(--font-display); font-weight: 800; font-size: 0.78rem; color: var(--purple); }
.reveal-event.hidden { display: none; }

.arena-wrap { flex: 1; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
#arena { position: relative; width: min(84vw, 60vh, 420px); height: min(84vw, 60vh, 420px); }
#laser-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.laser-line { fill: none; stroke: var(--coral); stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 2px 4px rgba(255,90,110,.4)); stroke-dasharray: 10 7; animation: laserDraw 650ms ease-out forwards; }
.laser-line.mutual { stroke: var(--orange); filter: drop-shadow(0 2px 4px rgba(255,159,69,.4)); }

.avatar-node { position: absolute; width: 78px; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 0.25rem; transition: transform 200ms ease; animation: fadeInUp 260ms ease both; }
.avatar-node .avatar-ring {
  width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 0.95rem; font-weight: 800; color: var(--text-primary);
  border: 3px solid #fff; position: relative; transition: box-shadow 220ms ease, border-color 220ms ease;
  box-shadow: 0 3px 0 rgba(43,37,64,.12);
}
.avatar-node .name-tag { font-size: 0.68rem; font-weight: 700; color: var(--text-primary); max-width: 76px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-node .score-tag { font-family: var(--font-body); font-weight: 800; font-size: 0.68rem; color: var(--green-dark); }
.avatar-node.is-me .avatar-ring { border-color: var(--purple); }
.avatar-node.is-me .name-tag { color: var(--purple); font-weight: 800; }
.avatar-node.desperate .avatar-ring { border-color: var(--coral); animation: glowPulse 900ms infinite; color: var(--coral-dark); }
.avatar-node.shielded .avatar-ring { border-color: var(--blue); box-shadow: var(--shadow-blue); }
.avatar-node.disconnected .avatar-ring { opacity: 0.4; }
.score-float { position: absolute; top: -4px; left: 50%; transform: translateX(-50%); font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; animation: scoreFloat 1.1s ease forwards; pointer-events: none; white-space: nowrap; }
.score-float.gain { color: var(--green-dark); }
.score-float.loss { color: var(--coral-dark); }

.reveal-log { flex: 0 0 auto; max-height: 26%; overflow-y: auto; margin: 0 0.9rem 0.8rem; background: var(--bg-card); border: 2px solid var(--border-soft); border-radius: var(--radius-md); padding: 0.65rem 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; }
.log-line { font-size: 0.84rem; font-weight: 600; color: var(--text-dim); animation: fadeInUp 250ms ease both; }
.log-line b { color: var(--text-primary); }

/* ============================================================ results */
#screen-results { align-items: center; justify-content: center; gap: 0.9rem; padding: 1.4rem; text-align: center; overflow-y: auto; position: relative; }
#screen-results h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; color: var(--text-dim); letter-spacing: 0.02em; }
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.confetti-piece { position: absolute; top: -20px; border-radius: 3px; animation: confettiFall linear forwards; }
.winner-spotlight { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding-top: 0.4rem; position: relative; z-index: 2; }
.winner-spotlight .avatar-ring {
  position: relative; width: 100px; height: 100px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; color: var(--text-primary);
  border: 4px solid #fff;
  box-shadow: var(--shadow-gold), 0 3px 0 rgba(43,37,64,.12);
  animation: gentleBounce 2s ease-in-out infinite;
}
.winner-spotlight .winner-name { font-family: var(--font-display); font-weight: 800; font-size: 1.55rem; color: var(--gold-dark); }
.winner-spotlight .winner-score { font-family: var(--font-body); font-weight: 800; font-size: 1.05rem; color: var(--text-dim); }
.trickster-banner { position: relative; z-index: 2; padding: 0.6em 1.1em; border-radius: var(--radius-round); background: #ffeaf6; border: 2px solid var(--pink); color: var(--pink-dark); font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; }
.trickster-banner.hidden { display: none; }
.scoreboard { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 0.4rem; width: 100%; max-width: 360px; }
.scoreboard-row {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.5em 0.85em;
  background: var(--bg-card); border: 2px solid var(--border-soft); border-radius: var(--radius-md);
  animation: fadeInUp 320ms ease both;
}
.scoreboard-row:nth-child(1) { animation-delay: 60ms; }
.scoreboard-row:nth-child(2) { animation-delay: 140ms; }
.scoreboard-row:nth-child(3) { animation-delay: 220ms; }
.scoreboard-row.me { border-color: var(--purple); box-shadow: var(--shadow-purple); }
.scoreboard-row .rank { font-family: var(--font-display); font-weight: 800; color: var(--text-faint); width: 2ch; flex: 0 0 auto; }
.scoreboard-row:first-child .rank { color: var(--gold-dark); }
.scoreboard-row .avatar-dot { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; box-shadow: inset 0 -2px 0 rgba(0,0,0,.08); }
.scoreboard-row .name { flex: 1; font-weight: 700; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoreboard-row .score { font-family: var(--font-display); font-weight: 800; color: var(--green-dark); }

/* ============================================================ small / landscape phones */
@media (orientation: landscape) and (max-height: 500px) {
  .action-zones { flex-direction: row; }
  .action-zone .zone-icon svg { width: 1.9rem; height: 1.9rem; }
  .action-zone .zone-label { font-size: 1.1rem; }
  .target-grid { grid-template-columns: repeat(3, 1fr); }
  #arena { width: min(50vh, 60vw, 360px); height: min(50vh, 60vw, 360px); }
}
@media (max-height: 620px) {
  .action-zone .zone-icon svg { width: 2rem; height: 2rem; }
  .action-zone .zone-label { font-size: 1.15rem; }
  .role-card { padding: 1rem 1.2rem; }
}
