/* Ifhamny brand (from the 2016 box and card artwork):
   low-poly facets in cyan / crimson / magenta / orange, white rounded cards,
   main word in red, forbidden words in dark grey, Droid/Noto Kufi for Arabic. */
:root {
  --red: #d61e43; --red-dark: #8e1632; --orange: #f5821f; --yellow: #fec215;
  --cyan: #12b7d3; --teal: #05a8cb; --teal-dark: #148daa; --magenta: #9d248e; --purple: #762980;
  --ink: #2d2d2d; --muted: #6b7280; --card: #ffffff; --line: #e6e8ec;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; color: var(--ink);
  font-family: "Noto Kufi Arabic", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: #0d7f97 url("bg.jpg") center / cover no-repeat;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: rgba(255,255,255,.92); 
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 44px; display: block; }
.brand .en { font-weight: 700; font-size: 18px; color: var(--teal-dark); letter-spacing: .5px; }
h2 { margin: 0 0 12px; font-size: 18px; color: var(--teal-dark); }
.hidden { display: none !important; }
.panel { max-width: 860px; margin: 24px auto; padding: 0 16px; }
.center { text-align: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .two { grid-template-columns: 1fr; } }
.card-box, .panel.center > p, #waiting {
  background: var(--card); border-radius: 22px; padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
}
.tagline { display: block; margin: 0 auto 18px; max-width: 320px; height: auto; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 14px; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 16px; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--cyan); }
button {
  padding: 10px 18px; border-radius: 999px; border: 2px solid var(--line); background: #fff;
  color: var(--ink); font-size: 15px; font-family: inherit; font-weight: 600; cursor: pointer;
}
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
button.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
.modes { display: grid; gap: 8px; }
.mode {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; color: var(--ink); margin: 0;
}
.mode:has(input:checked) { border-color: var(--cyan); background: #ecfbfe; }
.mode input { grid-row: 1 / span 2; width: auto; margin: 0; accent-color: var(--red); }
.mode b { font-size: 15px; } .mode small { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; text-align: center; font-weight: 600; text-shadow: 0 1px 2px #fff; }
.note { color: #fff; font-size: 13px; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
#roomBadge { color: var(--muted); font-size: 14px; white-space: nowrap; }
#roomBadge b { color: var(--red); letter-spacing: 3px; font-size: 18px; }




.tag { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.92); color: var(--ink); padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
[dir="rtl"] .tag { left: auto; right: 10px; }
.board { display: flex; justify-content: space-between; align-items: center; max-width: 1000px; margin: 12px auto 0; padding: 0 16px; }
.scores { display: flex; gap: 10px; }
.scores .p { background: #fff; border: 2px solid #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.scores .p.active { border-color: var(--yellow); }
.scores .p b { color: var(--red); margin-left: 8px; }
[dir="rtl"] .scores .p b { margin-left: 0; margin-right: 8px; }
.timer { font-size: 30px; font-weight: 700; color: #fff; background: var(--teal); border-radius: 999px; min-width: 72px; text-align: center; padding: 2px 14px; box-shadow: 0 4px 12px rgba(0,0,0,.18); font-variant-numeric: tabular-nums; }
.timer.low { background: var(--red); }
.role { text-align: center; margin: 14px 0 10px; color: #fff; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.45); }

/* the card itself, as printed: white, rounded, red word on top, grey forbidden words */
.card { max-width: 420px; margin: 0 auto; background: var(--card); border-radius: 22px; padding: 22px 20px 18px; text-align: center; box-shadow: 0 12px 36px rgba(0,0,0,.28); }
.word { font-size: 38px; font-weight: 700; color: var(--red); margin-bottom: 14px; line-height: 1.3; }
.forbidden { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 20px; color: var(--ink); }
.forbidden li:nth-child(5) { grid-column: 1 / -1; }
.forbidden:empty { display: none; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.guess { max-width: 420px; margin: 0 auto; text-align: center; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.45); }
.heard { font-size: 20px; color: var(--ink); text-shadow: none; min-height: 1.6em; background: #fff; border-radius: 18px; padding: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.pending { max-width: 420px; margin: 12px auto; background: #fff; border: 3px solid var(--yellow); border-radius: 18px; padding: 14px; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.pending p { margin: 0 0 10px; }
#canvasWrap { max-width: 660px; margin: 12px auto; text-align: center; }
canvas { width: 100%; background: #fff; border-radius: 18px; border: 4px solid #fff; touch-action: none; cursor: crosshair; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #fff; color: var(--ink); border: 3px solid var(--cyan); padding: 12px 20px; border-radius: 999px; font-size: 16px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 90vw; text-align: center; z-index: 10; }
.toast.good { border-color: var(--yellow); } .toast.bad { border-color: var(--red); }

/* phones */
@media (max-width: 600px) {
  header { padding: 8px 12px; }
  .brand img { height: 36px; } .brand .en { display: none; }
  #roomBadge { font-size: 12px; } #roomBadge b { font-size: 16px; letter-spacing: 2px; }
  .videos { padding: 10px 10px 0; gap: 8px; }
  .tile { border-width: 3px; }
  .board { padding: 0 10px; } .timer { font-size: 24px; min-width: 60px; }
  .word { font-size: 30px; } .forbidden { font-size: 18px; }
  .card { margin: 0 10px; padding: 16px 14px 14px; }
  .panel { margin: 16px auto; padding: 0 12px; }
  .tagline { max-width: 240px; }
  .toast { bottom: 16px; font-size: 14px; padding: 10px 14px; }
}

/* ---- Snapchat-style stage: the other player full screen, you in a small tile, the game on top ---- */
header { position: sticky; top: 0; z-index: 5; }
#game { position: relative; }
.stage { position: fixed; inset: 0; z-index: 0; background: transparent; }
.stage #remoteVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: transparent; }
.stage-empty { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,.92); color: var(--ink); padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); white-space: nowrap; }
.remote-tag { position: absolute; left: 12px; top: 76px; bottom: auto; }
.remote-tag:empty { display: none; }
[dir="rtl"] .remote-tag { left: auto; right: 12px; }
.pip { position: absolute; right: 12px; top: 76px; width: 28vw; max-width: 180px; min-width: 96px; aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; border: 3px solid #fff; background: #0b2730; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
[dir="rtl"] .pip { right: auto; left: 12px; }
.pip video { width: 100%; height: 100%; object-fit: cover; }
.pip .tag { left: 6px; bottom: 6px; font-size: 11px; padding: 2px 8px; }
.hud { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); max-height: 72vh; overflow-y: auto; }
.hud .board { margin: 0 0 10px; padding: 0; }
.waiting { background: #fff; border-radius: 22px; padding: 16px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.waiting p { margin: 0 0 8px; }
.waiting b { color: var(--red); letter-spacing: 3px; }
.hud .role { margin: 6px 0 8px; }
.hud .card { max-width: 480px; }
.hud .guess, .hud .pending { max-width: 480px; }
#canvasWrap { max-width: 520px; }

/* camera / mic / flip / leave */
.controls { position: absolute; right: 12px; top: calc(76px + min(28vw, 180px) * 4 / 3 + 10px); display: flex; flex-direction: column; gap: 8px; }
[dir="rtl"] .controls { right: auto; left: 12px; }
.ctl { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 2px solid #fff; background: rgba(255,255,255,.92); font-size: 20px; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.ctl.off { background: var(--red); border-color: var(--red); color: #fff; opacity: .95; }
.ctl.off::after { content: ""; position: absolute; }
.ctl.leave { background: var(--ink); border-color: var(--ink); color: #fff; font-size: 18px; }
#localVideo.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

/* ---- effects: confetti canvas, result cards, shake, score bumps ---- */
.fx-confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.fx-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; }
.fx-card { background: #fff; border-radius: 28px; padding: 26px 34px; text-align: center; min-width: min(86vw, 360px); box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: fx-pop .55s cubic-bezier(.2, 1.6, .4, 1) both; }
.fx-overlay.out .fx-card { animation: fx-leave .45s ease-in both; }
.fx-icon { font-size: 56px; line-height: 1; animation: fx-wiggle 1.2s ease-in-out .3s 2; }
.fx-title { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: .5px; }
.fx-word { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--teal-dark); }
.fx-sub { color: var(--muted); font-size: 14px; margin-top: 8px; }
.fx-success .fx-card { border: 4px solid var(--yellow); }
.fx-success .fx-title { background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--cyan), var(--magenta)); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 300% 100%; animation: fx-shimmer 1.8s linear infinite; }
.fx-fail .fx-card { border: 4px solid var(--red); }
.fx-fail .fx-title { color: var(--red); }
.fx-fail .fx-word { color: var(--red); text-decoration: line-through; }
.fx-timeout .fx-card { border: 4px solid var(--teal); } .fx-timeout .fx-title { color: var(--teal-dark); }
.fx-skip .fx-card { border: 4px solid var(--line); } .fx-skip .fx-title { color: var(--muted); font-size: 22px; }
.fx-flash { position: fixed; inset: 0; z-index: 39; pointer-events: none; background: radial-gradient(ellipse at center, rgba(214,30,67,0) 40%, rgba(214,30,67,.75) 100%); animation: fx-flash .7s ease-out both; }
body.fx-shake { animation: fx-shake .6s cubic-bezier(.36,.07,.19,.97) both; }
.fx-bump-up { animation: fx-bump-up .7s cubic-bezier(.2,1.6,.4,1) both; }
.fx-bump-down { animation: fx-bump-down .7s cubic-bezier(.2,1.6,.4,1) both; }
.timer.low { animation: fx-pulse .5s ease-in-out infinite alternate; }
@keyframes fx-pop { from { transform: scale(.4) rotate(-6deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes fx-leave { to { transform: scale(.85) translateY(30px); opacity: 0; } }
@keyframes fx-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg) scale(1.1); } 75% { transform: rotate(14deg) scale(1.1); } }
@keyframes fx-shimmer { to { background-position: 300% 0; } }
@keyframes fx-flash { from { opacity: 1; } to { opacity: 0; } }
@keyframes fx-shake { 10%, 90% { transform: translate3d(-2px, 0, 0); } 20%, 80% { transform: translate3d(5px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-9px, 0, 0); } 40%, 60% { transform: translate3d(9px, 0, 0); } }
@keyframes fx-bump-up { 30% { transform: scale(1.35); background: var(--yellow); } 100% { transform: scale(1); } }
@keyframes fx-bump-down { 30% { transform: scale(1.25) rotate(-4deg); background: #ffd9df; } 100% { transform: scale(1); } }
@keyframes fx-pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .fx-card, body.fx-shake, .fx-bump-up, .fx-bump-down, .timer.low { animation: none; } }
/* effect fixes: the confetti layer must stay transparent (the pictionary canvas rule paints canvases white),
   and the shake must not move the body, or fixed overlays collapse to the body's content height */
html, body { height: 100%; }
.fx-confetti { background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
body.fx-shake { animation: none; }
body.fx-shake .stage, body.fx-shake .hud, body.fx-shake header { animation: fx-shake .6s cubic-bezier(.36,.07,.19,.97) both; }
