:root {
  --bg: #1b1340;
  --bg2: #2a1f5c;
  --panel: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #b9b2d9;
  --accent: #7b61ff;
  --accent2: #ffb400;
  --good: #3ddc84;
  --warn: #ffb400;
  --bad: #ff5a5f;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: "Trebuchet MS", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 20% -10%, #3b2a8a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #5a1f6e 0%, transparent 60%),
              var(--bg);
  background-attachment: fixed;
}

h1, h2 { margin: 0 0 12px; }
h2 { font-size: 1.1rem; letter-spacing: 0.02em; }
a { color: inherit; }
code { background: var(--panel); padding: 2px 6px; border-radius: 6px; }

/* ---------- common bits ---------- */

.logo { font-weight: 900; font-size: 1.5rem; text-decoration: none; letter-spacing: -0.02em; }
.logo span { color: var(--accent2); }
.logo.big { font-size: clamp(2.4rem, 9vw, 5rem); margin-bottom: 8px; line-height: 1.1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 10px 16px;
  font: inherit; font-weight: 700; color: var(--text); text-decoration: none;
  background: rgba(255, 255, 255, 0.14); cursor: pointer;
  transition: transform .08s, background .15s, opacity .15s;
  touch-action: manipulation;
}
.btn:hover { background: rgba(255, 255, 255, 0.22); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); box-shadow: 0 6px 0 #5438d6; }
.btn.primary:hover { background: #8d77ff; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.big { padding: 16px 24px; font-size: 1.15rem; border-radius: 16px; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }

.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card.center { text-align: center; align-items: center; }

.status { padding: 8px 14px; border-radius: 999px; font-size: 0.9rem; font-weight: 700; }
.status::before { content: "●"; margin-right: 6px; }
.status.ok { background: rgba(61, 220, 132, .15); color: var(--good); }
.status.warn, .status.searching { background: rgba(255, 180, 0, .15); color: var(--warn); }
.status.bad { background: rgba(255, 90, 95, .15); color: var(--bad); }
.status.searching::before { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

input, select {
  font: inherit; font-size: 1.1rem; color: var(--text);
  background: rgba(0, 0, 0, 0.25); border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
select option { color: #000; }
label { font-weight: 700; color: var(--muted); font-size: 0.9rem; }

.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }

.scores, .lobby-players, .feed, .final-list { list-style: none; margin: 0; padding: 0; }
.scores li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  margin-bottom: 6px; background: rgba(255, 255, 255, 0.05);
}
.scores li.drawing { background: rgba(123, 97, 255, 0.3); }
.scores li.guessed { background: rgba(61, 220, 132, 0.2); }
.scores li.away { opacity: 0.45; }
.pname { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pscore { font-variant-numeric: tabular-nums; font-weight: 900; }
.tag { font-size: 0.9rem; }

.timer {
  min-width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.6rem; font-weight: 900; background: var(--accent2); color: #1b1340; flex: none;
}
.timer.small { min-width: 44px; height: 44px; font-size: 1.1rem; }
.timer.low { background: var(--bad); color: #fff; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.board-wrap { width: 100%; display: flex; justify-content: center; }
.board {
  background: #fff; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
  aspect-ratio: 1 / 1; display: block; touch-action: none;
}

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.gallery figure { margin: 0; background: #fff; color: #222; border-radius: 12px; overflow: hidden; }
.gallery img { width: 100%; display: block; }
.gallery figcaption { padding: 8px 10px; font-size: 0.9rem; }
.empty { color: var(--muted); }

.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 5px solid var(--line); border-top-color: var(--accent2); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); cursor: pointer; padding: 0; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }

/* ---------- top bar ---------- */

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; }
.topbar .status { margin-right: auto; }
.topbar-actions { display: flex; gap: 8px; }
.topbar.compact { padding: 10px 14px; justify-content: space-between; }
.me { display: flex; gap: 6px; align-items: center; font-weight: 700; }

/* ---------- landing ---------- */

.hero { max-width: 720px; margin: 0 auto; padding: 10vh 16px 40px; text-align: center; }
.tagline { font-size: 1.25rem; color: var(--muted); margin: 0 0 28px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 36px; }
.how { text-align: left; max-width: 520px; margin: 0 auto 24px; line-height: 1.7; color: var(--muted); }
.how b { color: var(--text); }
.fine { color: var(--muted); font-size: 0.85rem; }

/* ---------- host world ---------- */

body.world-host { height: 100vh; overflow: hidden; background: #5fb8ff; }
.world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
.world:active { cursor: grabbing; }

.join-corner {
  position: fixed; top: 14px; left: 14px; z-index: 2; display: flex; gap: 12px; align-items: center;
  background: rgba(27, 19, 64, 0.78); border-radius: 18px; padding: 10px 16px 10px 10px; backdrop-filter: blur(6px);
}
.corner-text { font-weight: 700; }
.corner-code { color: var(--muted); font-size: 0.95rem; }
.corner-code b { color: var(--accent2); letter-spacing: 0.15em; font-size: 1.2rem; }

.world-actions { position: fixed; top: 14px; right: 14px; z-index: 2; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn.light, .pill.light { background: rgba(27, 19, 64, 0.72); color: #fff; border: 0; }
.pill.light { padding: 8px 14px; font-weight: 700; }
.world-actions .status { background: rgba(27, 19, 64, 0.72); }

.welcome {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -54%); z-index: 1;
  background: rgba(27, 19, 64, 0.88); border-radius: 28px; padding: 24px 36px; text-align: center;
  display: flex; flex-direction: column; align-items: center; max-width: 94vw; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.welcome h1 { font-size: clamp(1.4rem, 3vw, 2.4rem); }
.qr { background: #fff; border-radius: 20px; padding: 10px; width: min(34vh, 300px); aspect-ratio: 1; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr.small { width: 96px; padding: 4px; border-radius: 10px; }
.or { color: var(--muted); font-size: 1.05rem; margin: 14px 0 4px; }
.or b { color: var(--text); }
.big-code { font-size: clamp(2.6rem, 6vw, 4.4rem); font-weight: 900; letter-spacing: 0.25em; color: var(--accent2); padding-left: 0.25em; }
.lan-note { background: rgba(61, 220, 132, .12); color: var(--good); padding: 10px 16px; border-radius: 12px; font-weight: 700; margin: 8px 0 0; }

.toasts { position: fixed; left: 14px; bottom: 14px; z-index: 3; display: flex; flex-direction: column; gap: 8px; }
.world-toast {
  background: rgba(27, 19, 64, 0.85); padding: 10px 16px; border-radius: 14px; font-weight: 700;
  animation: slidein .35s; transition: opacity .5s, transform .5s;
}
.world-toast b { color: var(--accent2); }
.world-toast.out { opacity: 0; transform: translateX(-30px); }
@keyframes slidein { from { opacity: 0; transform: translateX(-30px); } }

.gallery-dialog {
  width: min(1100px, 94vw); max-height: 88vh; border: 1px solid var(--line); border-radius: 20px;
  background: var(--bg2); color: var(--text); padding: 20px;
}
.gallery-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.dialog-head h2 small { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.dialog-head div { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn.dark { color: #222; border-color: #ddd; }

@media (max-width: 700px) {
  .join-corner .corner-text { display: none; }
  .welcome { padding: 18px; }
}

/* ---------- phone ---------- */

body.play { min-height: 100%; }
.phone { max-width: 520px; margin: 0 auto; padding: 8px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.phone .status { align-self: center; text-align: center; border-radius: 14px; }
.row { display: flex; gap: 8px; }
.row input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 900; text-align: center; }

.prompt { flex: 1; font-size: 1.15rem; text-align: center; }
.prompt .word { color: var(--accent2); font-size: 1.4rem; }

.tools { display: flex; flex-direction: column; gap: 10px; }
.tools .swatch { width: 32px; height: 32px; }
.tool-row { display: flex; gap: 8px; align-items: center; }
.sizes { display: flex; gap: 6px; flex: 1; }
.sizes button {
  width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255, 255, 255, .08);
  display: grid; place-items: center; cursor: pointer;
}
.sizes button.on { border-color: var(--accent2); }
.sizes i { display: block; background: #fff; border-radius: 50%; }



.overlay {
  position: fixed; inset: 0; background: rgba(27, 19, 64, .92); z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 700;
}
.toast {
  position: fixed; left: 50%; top: 16px; transform: translate(-50%, -120px); z-index: 20;
  padding: 12px 20px; border-radius: 14px; font-weight: 900; background: var(--bg2); border: 1px solid var(--line);
  transition: transform .25s;
}
.toast.show { transform: translate(-50%, 0); }
.toast.good { background: var(--good); color: #0b2d18; }
.toast.warn { background: var(--warn); color: #2d1d00; }

.prompt { font-size: 1.1rem; text-align: center; }
.prompt small { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.85rem; }
.center-text { text-align: center; }
.grow { flex: 1; }

.steps { display: flex; gap: 6px; justify-content: center; }
.steps span { font-size: 0.8rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--panel); color: var(--muted); }
.steps span.on { background: var(--accent); color: #fff; }
.steps span.done { color: var(--good); }

.draw-phone { gap: 10px; }
.board-frame { position: relative; width: 100%; }
.draw-phone .board { width: 100%; box-shadow: 0 0 0 4px var(--accent2), 0 10px 40px rgba(0, 0, 0, .4); }
.leg-guide {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); pointer-events: none;
  border-top: 4px dashed rgba(123, 97, 255, .7); width: 30%; text-align: center; color: #7b61ff; font-weight: 700; font-size: 0.8rem; padding-top: 2px;
}
.step-actions { display: flex; gap: 8px; }

.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.move-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}
.move-btn.on, .move-btn:active { border-color: var(--accent2); background: rgba(255, 180, 0, .15); }
.move-emoji { font-size: 2.2rem; }

.preview { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); display: block; }

.my-animals { display: flex; flex-direction: column; gap: 10px; }
.my-animal-head { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.acts .btn { padding: 12px 6px; }
.acts .btn.pressed { background: var(--accent); }
.card.center h2, .card.center p { margin: 0; }

.scene-picker { display: flex; gap: 4px; background: rgba(27, 19, 64, 0.72); border-radius: 12px; padding: 3px; }
.scene-picker .btn { background: transparent; padding: 7px 10px; font-size: 1.15rem; }
.scene-picker .btn.on { background: var(--accent); }
.scene-name { margin: -4px 0 10px; color: var(--accent2); font-weight: 700; font-size: 1.2rem; }

.templates { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.template-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}
.template-btn img { width: 100%; aspect-ratio: 1; border-radius: 10px; display: block; }
.template-btn:active { border-color: var(--accent2); }
.board-tpl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; border-radius: var(--radius); }
.draw-phone .board { box-shadow: 0 0 0 4px var(--accent2), 0 10px 40px rgba(0, 0, 0, .4); }
#bucket.on { background: var(--accent2); color: #1b1340; }
.preview { aspect-ratio: 1 / 1; background: radial-gradient(circle at 50% 40%, #cfeaff, #7fb8e6); }
.local-note { background: rgba(255, 180, 0, .15); color: var(--warn); padding: 10px 16px; border-radius: 12px; font-weight: 700; margin: 8px 0 0; max-width: 560px; }
.welcome { max-height: 94vh; overflow: auto; }
@media (max-height: 800px) { .welcome .qr { width: min(26vh, 240px); } .welcome h1 { font-size: 1.5rem; margin-bottom: 4px; } .big-code { font-size: 2.6rem; } }

/* ---------- languages ---------- */

html[lang="he"] body, html[lang="he"] .btn, html[lang="he"] input, html[lang="he"] select { font-family: "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
.lang-corner { position: fixed; top: 14px; inset-inline-end: 14px; z-index: 5; border: 2px solid var(--line); }
.topbar.compact .logo { font-size: 1.2rem; }
.topbar.compact .me { flex-wrap: wrap; justify-content: flex-end; }
.lang-toggle { white-space: nowrap; }
[dir="rtl"] .how { text-align: right; }
[dir="rtl"] .toasts { left: auto; right: 14px; }
[dir="rtl"] .world-toast.out { transform: translateX(30px); }

/* ---------- host login ---------- */

.auth-gate {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(27, 19, 64, 0.82); backdrop-filter: blur(8px);
}
.auth-card {
  width: min(420px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); display: flex; flex-direction: column; gap: 12px;
}
.auth-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.auth-card h2 { margin: 4px 0 0; font-size: 1.25rem; }
.auth-wait { color: var(--muted); margin: 8px 0; }
.auth-tabs { display: flex; gap: 6px; background: rgba(0, 0, 0, .2); border-radius: 12px; padding: 4px; }
.auth-tabs button {
  flex: 1; border: 0; border-radius: 9px; padding: 9px; font: inherit; font-weight: 700;
  background: transparent; color: var(--muted); cursor: pointer;
}
.auth-tabs button.on { background: var(--accent); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.auth-form .btn { margin-top: 6px; }
.auth-error { margin: 0; color: var(--bad); font-weight: 700; }
#auth-denied { display: flex; flex-direction: column; gap: 12px; }
#auth-denied[hidden], #auth-forms[hidden] { display: none; }

/* ---------- "Made by Liam" ---------- */

.made-by {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 30;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.85rem; font-weight: 700;
  color: rgba(255, 255, 255, 0.85); background: rgba(27, 19, 64, 0.55); padding: 4px 12px; border-radius: 999px;
  pointer-events: none; white-space: nowrap; letter-spacing: 0.03em;
}
html[lang="he"] .made-by { font-family: "Rubik", system-ui, sans-serif; letter-spacing: 0; }
.made-by:empty { display: none; }
.made-by-cursor { color: var(--accent2); margin-inline-start: 2px; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
body.landing, body.play { padding-bottom: 44px; }

/* ---------- loading screen (logo video) ---------- */

.intro {
  position: fixed; inset: 0; z-index: 1000; background: #fff;
  display: flex; align-items: center; justify-content: center; transition: opacity .6s ease;
}
.intro.out { opacity: 0; pointer-events: none; }
.intro-media { width: min(80vmin, 560px); height: auto; aspect-ratio: 1; object-fit: contain; }
.intro-skip {
  position: absolute; bottom: 22px; inset-inline-end: 22px; border: 0; border-radius: 999px; padding: 10px 18px;
  font: inherit; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(90deg, #2448ff, #d43cf0); box-shadow: 0 6px 18px rgba(80, 60, 200, .35);
}

/* ---------- admin page ---------- */

body.admin { min-height: 100%; padding-bottom: 24px; }
body.admin .phone h2 { margin: 6px 0 0; }
.admin-row input { text-transform: none; letter-spacing: normal; font-weight: 400; text-align: start; }
.admin-tools { display: flex; gap: 8px; align-items: center; }
.admin-tools input { flex: 1; padding: 9px 12px; font-size: 1rem; }
.admin-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.admin-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
}
.admin-user.on { border-color: rgba(61, 220, 132, .45); }
.admin-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.admin-who small { color: var(--muted); }

/* Scan a coloured paper sheet (play screen) */
.scan-btn { width: 100%; margin-top: 10px; }
