@font-face {
  font-family: 'Thmanyah Sans';
  src: url('fonts/thmanyahsans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('fonts/thmanyahsans-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Thmanyah Sans';
  src: url('fonts/thmanyahsans-Black.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
}

/* هوية "الكاميرا" (Viewfinder): أبيض بنفسجي فاتح بالنهار، وبنفسجي غامق بالليل،
   زوايا تركيز الكاميرا حول الصور، وصور اللاعبين مثل صور البولارويد */
:root {
  /* وضع النهار: كريمي هادي (أقل سطوع من الأبيض) */
  --bg: #f7eedb;
  --bg-glow: #fbf5e8;
  --surface: #fffaf0;
  --surface-2: #f1e6cf;
  --text: #221b14;
  --muted: #76695a;
  --line: #e7dbc2;
  --primary: #6c3df0;
  --primary-2: #8f5bff;
  --on-primary: #ffffff;
  --accent: #ff4f6d;
  --teal: #12b89a;
  --amber: #ffb21e;
  --danger: #e5394f;
  --ok: #0e9f6e;
  --ok-bg: #def2df;
  /* ملاحظة الخصوصية: بالنهار أخضر نعناعي أقوى من الخلفية الكريمي عشان تبان */
  --privacy-bg: #b4e6c2;
  --privacy-text: #10331f;
  --privacy-dot: #0e9f6e;
  --privacy-icon: #ffffff;
  --no-bg: #ffe6e3;
  --sel-bg: #fdebb8;
  --polaroid: #ffffff;
  --shadow: 0 10px 26px rgba(90, 64, 30, 0.1), 0 2px 6px rgba(90, 64, 30, 0.06);
  --shadow-lg: 0 18px 44px rgba(90, 64, 30, 0.16);
  --radius: 22px;
  /* ألوان مرحة، والأزرار بحدود سميكة وظل صلب */
  --yellow: #ffcd4a;
  --blue: #7cc4ff;
  --pink: #ff8fab;
  --green: #6fd38a;
  --orange: #f6a35b;
  --purple: #b9a2ff;
  --ink: #1f1a14;
  --edge: #1f1a14;
  --btn-border: 2.5px solid var(--edge);
  --btn-shadow: 0 5px 0 var(--edge);
  --btn-shadow-sm: 0 3px 0 var(--edge);
  --font: 'Thmanyah Sans', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}

/* وضع الليل */
:root[data-theme='dark'] {
  --bg: #0f0c1d;
  --bg-glow: #2a1c5c;
  --surface: #1b1733;
  --surface-2: #241f42;
  --text: #f4f1ff;
  --muted: #a9a3cc;
  --line: #322b58;
  --primary: #8c6bff;
  --primary-2: #b08cff;
  --accent: #ff6b85;
  --teal: #2fd3b4;
  --amber: #ffc24d;
  --danger: #ff6b7d;
  --ok: #3ddc9b;
  --ok-bg: #123329;
  --privacy-bg: #123329;
  --privacy-text: #f4f1ff;
  --privacy-dot: #3ddc9b;
  --privacy-icon: #123329;
  --no-bg: #3a1726;
  --sel-bg: #2d2457;
  --polaroid: #f4f1ff;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
  --edge: #000000;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f0c1d;
    --bg-glow: #2a1c5c;
    --surface: #1b1733;
    --surface-2: #241f42;
    --text: #f4f1ff;
    --muted: #a9a3cc;
    --line: #322b58;
    --primary: #8c6bff;
    --primary-2: #b08cff;
    --accent: #ff6b85;
    --teal: #2fd3b4;
    --amber: #ffc24d;
    --danger: #ff6b7d;
    --ok: #3ddc9b;
    --ok-bg: #123329;
    --privacy-bg: #123329;
    --privacy-text: #f4f1ff;
    --privacy-dot: #3ddc9b;
    --privacy-icon: #123329;
    --no-bg: #3a1726;
    --sel-bg: #2d2457;
    --polaroid: #f4f1ff;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
    --edge: #000000;
    color-scheme: dark;
  }
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(120% 60% at 50% -10%, var(--bg-glow) 0%, transparent 60%);
  background-repeat: no-repeat;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.25s, color 0.25s;
}

h1,
h2,
h3 {
  font-weight: 900;
  line-height: 1.25;
  margin: 0;
}
h2 {
  font-size: 1.7rem;
}
h3 {
  font-size: 1.15rem;
}
p {
  margin: 0;
}
small {
  display: block;
  font-size: 0.85rem;
}
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}
.muted {
  color: var(--muted);
  font-weight: 700;
}
.center-text {
  text-align: center;
}
.big-text {
  font-size: 1.3rem;
  font-weight: 900;
}

/* أيقونات Phosphor من ملف واحد (icons/ph.svg) وتاخذ لون النص */
.ic {
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.3em;
  flex: none;
}
.big-emoji {
  line-height: 1;
  color: var(--primary);
}
.big-emoji .ic {
  width: 68px;
  height: 68px;
}

/* ---------- الإطار ---------- */

#app {
  max-width: 480px;
  margin: 0 auto;
}

.screen {
  padding: calc(env(safe-area-inset-top) + 64px) 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
  animation: enter 0.35s ease;
}
.screen.center {
  justify-content: center;
  align-items: center;
  text-align: center;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.row.between {
  justify-content: space-between;
}
.row.gap > * {
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.soft {
  background: var(--surface-2);
  box-shadow: none;
}
.card.warn {
  background: var(--no-bg);
  border-color: transparent;
}
.card.warn small {
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- الأزرار ---------- */

.btn {
  font: inherit;
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--ink);
  background: var(--surface);
  border: var(--btn-border);
  border-radius: 18px;
  padding: 14px 22px;
  min-height: 58px;
  width: 100%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  box-shadow: var(--btn-shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s;
  user-select: none;
}
.btn:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: 0 0 0 var(--edge);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--yellow);
}
.btn.secondary {
  background: var(--blue);
}
.btn.ghost {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--btn-shadow-sm);
  min-height: 48px;
  font-size: 1.05rem;
}
.btn.whatsapp {
  background: var(--green);
}
.btn.big {
  min-height: 64px;
  font-size: 1.4rem;
}
.btn.small {
  min-height: 42px;
  padding: 6px 14px;
  font-size: 1rem;
  width: auto;
  border-radius: 14px;
  box-shadow: var(--btn-shadow-sm);
}
.btn.picker {
  background: var(--pink);
}

.chip {
  font: inherit;
  font-weight: 900;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--edge);
  border-radius: 999px;
  box-shadow: var(--btn-shadow-sm);
  padding: 4px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* أزرار الزاوية: الصوت ووضع الليل */
.corner {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  z-index: 20;
  display: flex;
  gap: 8px;
}
.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 2px solid var(--edge);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--btn-shadow-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.round-btn .ic {
  width: 24px;
  height: 24px;
}
.back {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  z-index: 20;
  font: inherit;
  font-weight: 900;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: 14px;
  box-shadow: var(--btn-shadow-sm);
  padding: 7px 14px;
  cursor: pointer;
}

/* ---------- المدخلات ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 900;
  font-size: 1.05rem;
}
.input {
  font: inherit;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 12px 18px;
  min-height: 58px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--sel-bg);
}
.input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* مفتاح تشغيل وإطفاء */
/* "وش الصور المسموحة؟" في شاشة "غرفتك جاهزة" */
.photo-rule {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: right;
}

/* ---------- الرئيسية ---------- */

.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.code-input {
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 1.7rem;
}
.input:disabled {
  opacity: 0.6;
}
.join-status {
  min-height: 1.6em;
  text-align: center;
  font-weight: 900;
  color: var(--muted);
}
.join-status.error {
  color: var(--danger);
}
.join-status.ok {
  color: var(--ok);
}

.home {
  justify-content: center;
}
.logo {
  text-align: center;
  margin-bottom: 10px;
}
/* اسم اللعبة داخل زوايا تركيز الكاميرا */
.logo-frame {
  position: relative;
  display: inline-block;
  padding: 18px 26px 14px;
}
.logo-frame::before,
.logo-frame::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  border: 4px solid var(--accent);
}
.logo-frame::before {
  top: 0;
  right: 0;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 10px;
}
.logo-frame::after {
  bottom: 0;
  left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 10px;
}
.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 26px rgba(108, 61, 240, 0.35);
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}
.logo-mark .ic {
  width: 38px;
  height: 38px;
}
.logo h1 {
  font-size: 2.7rem;
}
.logo p {
  color: var(--muted);
  font-weight: 700;
  font-size: 1.05rem;
  margin-top: 4px;
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-6px) rotate(4deg);
  }
}
@keyframes wobble {
  0%,
  100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(6deg) scale(1.05);
  }
}
.invite {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
}
.invite b {
  letter-spacing: 0.08em;
  color: var(--primary);
}
/* ملاحظة الخصوصية: كرت أخضر بدون إطار، لونه يختلف عن خلفية النهار والليل */
.privacy {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.5;
  color: var(--privacy-text);
  background: var(--privacy-bg);
  border-radius: 18px;
  padding: 12px 14px;
  margin-top: 8px;
}
.privacy .ic {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  color: var(--privacy-icon);
  background: var(--privacy-dot);
}

/* ---------- المشاركة والغرفة ---------- */

.code-label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
}
/* كل حرف من الكود في خانة لحاله */
.code-big {
  display: inline-flex;
  gap: 8px;
  margin: 6px 0 10px;
  direction: ltr;
}
.code-big span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 64px;
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--ink);
  background: var(--yellow);
  border: var(--btn-border);
  border-radius: 14px;
  box-shadow: var(--btn-shadow);
  text-transform: uppercase;
}
.share .btn {
  max-width: 420px;
}

.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.room-head .code {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
  color: var(--primary);
  text-transform: uppercase;
}
.room-actions {
  display: flex;
  gap: 8px;
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 8px 12px;
  animation: enter 0.3s ease;
}
.player .pname {
  flex: 1;
  font-weight: 900;
  font-size: 1.15rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .pname small {
  display: inline;
  color: var(--muted);
}
.player .crown {
  color: var(--amber);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.tag.ok {
  color: var(--ok);
  background: var(--ok-bg);
}
.tag.wait {
  color: #b77900;
  background: #fff3d6;
}
:root[data-theme='dark'] .tag.wait {
  color: var(--amber);
  background: #3a2d10;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .tag.wait {
    color: var(--amber);
    background: #3a2d10;
  }
}
.tag.off {
  color: var(--muted);
  background: var(--surface-2);
}
.kick {
  font: inherit;
  font-weight: 900;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  width: 30px;
  height: 30px;
  cursor: pointer;
  padding: 0;
}

/* صورة اللاعب: دائرة بلون فاتح وأول حرف من اسمه */
.avatar {
  --av: var(--yellow);
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: var(--av);
  border: 2px solid var(--edge);
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
}
.avatar.sm {
  width: 34px;
  height: 34px;
  font-size: 16px;
}
.avatar.lg {
  width: 60px;
  height: 60px;
  font-size: 28px;
}

/* الإعدادات */
.settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.setting-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: 900;
  font-size: 1.1rem;
}
.setting-head > span .ic {
  color: var(--primary);
}
.setting-head b {
  color: var(--primary);
  background: var(--sel-bg);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.95rem;
}
.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.segmented button {
  flex: 1;
  font: inherit;
  font-weight: 900;
  font-size: 1.02rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 9px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.segmented button.on {
  color: var(--ink);
  background: var(--yellow);
  box-shadow: inset 0 0 0 2px var(--edge);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 38px;
  background: transparent;
  direction: rtl;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--primary);
  border: 4px solid var(--surface);
  box-shadow: 0 4px 10px rgba(108, 61, 240, 0.4);
}
input[type='range']::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}
input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  border: 4px solid var(--surface);
}

.settings-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
}
.settings-summary div {
  display: flex;
  justify-content: space-between;
}
.settings-summary b {
  font-weight: 900;
  color: var(--primary);
}

/* ---------- الصور ---------- */

.server-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 4px 14px;
  align-self: flex-start;
}
.server-chip.ok {
  color: var(--ok);
  background: var(--ok-bg);
}
.server-chip.wait {
  color: var(--primary);
  background: var(--sel-bg);
}

/* صور اللاعب مثل صور البولارويد: إطار أبيض وميلان خفيف */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px;
  padding: 6px 4px 100px;
}
.thumb {
  position: relative;
  aspect-ratio: 0.86;
  background: var(--polaroid);
  padding: 6px 6px 20px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  transform: rotate(-2deg);
  animation: enter 0.25s ease;
}
.thumb:nth-child(even) {
  transform: rotate(2deg);
}
.thumb:nth-child(3n) {
  transform: rotate(-1deg);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 3px;
}
.thumb .remove {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(229, 57, 79, 0.35);
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  display: flex;
  justify-content: center;
  z-index: 5;
}
.bottom-bar .btn {
  max-width: 448px;
}

.upload .progress,
.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width 0.3s;
}

/* ---------- اللعب ---------- */

.game {
  gap: 12px;
}
.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 3px 14px;
  font-weight: 900;
  font-size: 1rem;
}
.pill.timer:empty {
  display: none;
}
.timebar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.timebar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--yellow);
}
.timebar i.hurry {
  background: var(--danger);
}

/* إطار الصورة مع زوايا تركيز الكاميرا */
.photo-wrap {
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-lg);
}
.photo-wrap::before,
.photo-wrap::after {
  content: '';
  position: absolute;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 4px solid #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
  pointer-events: none;
}
.photo-wrap::before {
  top: 14px;
  right: 14px;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 12px;
}
.photo-wrap::after {
  bottom: 14px;
  left: 14px;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 12px;
}
.photo {
  position: relative;
  width: 100%;
  height: min(50dvh, 450px);
  display: grid;
  place-items: center;
}
/* الصورة تتمدد داخل الإطار بدون قص (absolute عشان سفاري في الآيفون ما يطوّلها برا الإطار) */
.photo img.shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  animation: photo-in 0.4s ease;
}
.zoom-hint {
  position: absolute;
  bottom: 14px;
  right: 50%;
  transform: translateX(50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 900;
  color: #fff;
  background: rgba(15, 12, 29, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  padding: 2px 12px;
  pointer-events: none;
}
/* وقت التشويق والكشف نخفي التلميح عشان ما يغطي على العد أو اسم صاحب الصورة */
.photo-wrap:has(.overlay.suspense, .overlay.revealed) .zoom-hint {
  display: none;
}
.no-scroll {
  overflow: hidden;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* الصورة بحجمها الكامل */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 8, 20, 0.94);
  display: grid;
  place-items: center;
  cursor: zoom-out;
  animation: fade 0.2s ease;
}
.viewer img {
  max-width: 100vw;
  max-height: 100dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.viewer-top {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.viewer-timer:empty {
  visibility: hidden;
}
.viewer-hint {
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  padding: 4px 12px;
}
@keyframes photo-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}
.photo-loading {
  color: var(--primary);
  animation: wobble 1.2s ease-in-out infinite;
}
.photo-loading .ic {
  width: 52px;
  height: 52px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.overlay.suspense {
  background: rgba(15, 12, 29, 0.55);
  backdrop-filter: blur(3px);
}
.overlay.revealed {
  place-items: end center;
  padding: 16px;
}
.countdown {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  font-size: 5.5rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.18), 0 18px 40px rgba(0, 0, 0, 0.35);
}
.countdown.pop {
  animation: pop 0.9s ease-out;
}
@keyframes pop {
  0% {
    transform: scale(1.6);
    opacity: 0;
  }
  25% {
    transform: scale(1);
    opacity: 1;
  }
}
.owner-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  background: var(--yellow);
  border: var(--btn-border);
  border-radius: 20px;
  padding: 8px 20px 8px 10px;
  box-shadow: var(--btn-shadow);
  animation: badge 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.owner-badge b {
  font-size: 1.6rem;
  line-height: 1.1;
  display: block;
}
.owner-badge small {
  font-weight: 900;
  opacity: 0.75;
}
@keyframes badge {
  from {
    transform: scale(0.3) translateY(30px);
    opacity: 0;
  }
}

.question {
  text-align: center;
  font-size: 1.9rem;
}
.question .ic {
  color: var(--accent);
}
.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.option {
  font: inherit;
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--text);
  background: var(--surface);
  border: var(--btn-border);
  border-radius: 18px;
  box-shadow: var(--btn-shadow-sm);
  padding: 6px 8px 6px 14px;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: right;
  transition: transform 0.08s, background 0.15s, box-shadow 0.08s;
}
.option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.option:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--edge);
}
.option:disabled {
  cursor: default;
  opacity: 0.5;
}
.option.selected {
  background: var(--sel-bg);
  box-shadow: var(--btn-shadow-sm), 0 0 0 4px var(--yellow);
}
.vote-btn {
  margin-top: 4px;
}
.option.picked {
  opacity: 1;
  color: var(--ink);
  background: var(--yellow);
}

.mine {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 1.2rem;
}
.mine b {
  font-size: 1.35rem;
}

.results .nobody {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 10px;
}
.votes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.votes li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 1.05rem;
  animation: enter 0.3s ease backwards;
}
.votes li:nth-child(2) {
  animation-delay: 0.08s;
}
.votes li:nth-child(3) {
  animation-delay: 0.16s;
}
.votes li:nth-child(4) {
  animation-delay: 0.24s;
}
.votes li.ok {
  background: var(--ok-bg);
}
.votes li.no {
  background: var(--no-bg);
}
.votes .voter {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.votes .voter b {
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* سهم طويل يشير من اللي صوّت (يمين) للي صوّت عليه (يسار)، وفوقه "صوّت على" */
.vote-arrow {
  flex: 1;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--muted);
}
.vote-arrow small {
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}
/* السهم سميك وبلون النص عشان يبان */
.vote-arrow i {
  position: relative;
  display: block;
  width: 100%;
  height: 4px;
  background: var(--text);
  border-radius: 4px;
}
.vote-arrow i::before {
  content: '';
  position: absolute;
  left: -2px;
  top: -6px;
  border: 8px solid transparent;
  border-left: 0;
  border-right: 13px solid var(--text);
}
.votes .gain {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 900;
  white-space: nowrap;
}
.votes li.ok .gain {
  color: var(--ok);
}
.votes li.no .gain {
  color: var(--danger);
}
.wait-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--muted);
}
.wait-next b {
  color: var(--text);
}

.board h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.board h3 .ic {
  color: var(--amber);
}
.board ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
}
.board li.me {
  background: var(--sel-bg);
}
.board .rank {
  width: 22px;
  text-align: center;
  font-weight: 900;
  color: var(--muted);
}
.board .pname {
  flex: 1;
  font-weight: 900;
  font-size: 1.08rem;
}
.board b {
  font-size: 1.15rem;
  color: var(--primary);
}

/* ---------- النهاية ---------- */

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}
.step {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  border: var(--btn-border);
  border-radius: 20px 20px 8px 8px;
  box-shadow: var(--btn-shadow);
  padding: 12px 6px;
  animation: rise 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}
.step-1 {
  order: 2;
  min-height: 220px;
  background: var(--yellow);
  animation-delay: 0.5s;
}
.step-2 {
  order: 1;
  min-height: 178px;
  background: var(--blue);
  animation-delay: 0.25s;
}
.step-3 {
  order: 3;
  min-height: 146px;
  background: var(--orange);
}
.medal .ic {
  width: 40px;
  height: 40px;
  color: var(--ink);
}
.step .avatar {
  background: #fff;
}
.winner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}
.winner b {
  font-size: 1.05rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.winner span {
  font-weight: 900;
}
@keyframes rise {
  from {
    transform: translateY(60px);
    opacity: 0;
  }
}

/* ---------- تنبيهات ---------- */

.netbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  text-align: center;
  font-weight: 900;
  color: #fff;
  background: var(--primary);
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  transform: translateY(-110%);
  transition: transform 0.25s;
}
.netbar.show {
  transform: none;
}

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  left: 50%;
  z-index: 40;
  max-width: calc(100% - 32px);
  color: var(--bg);
  background: var(--text);
  font-weight: 900;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
