/* ---------- Fonts (Catamaran, from the club website; full Turkish glyph coverage) ---------- */
@font-face { font-family: "Catamaran"; src: url("/fonts/Catamaran-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Catamaran"; src: url("/fonts/Catamaran-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Catamaran"; src: url("/fonts/Catamaran-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Catamaran"; src: url("/fonts/Catamaran-Black.ttf") format("truetype"); font-weight: 900; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --bg: #06142b;
  --surface: #0d2346;
  --surface-2: #163463;
  --text: #ffffff;
  --muted: #b9c7dd;
  --brand: #0e78b6;
  --brand-2: #1bb3d7;
  --gold: #f5b700;
  --silver: #c9d3e0;
  --bronze: #d9894a;
  --success: #2e7d32;
  --danger: #c62828;
  /* Answer tiles: every color keeps >= 4.5:1 contrast with white text. */
  --a0: #c62828;
  --a1: #1565c0;
  --a2: #b45309;
  --a3: #2e7d32;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Catamaran", system-ui, sans-serif;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; touch-action: manipulation; }
img { display: block; }
.hidden { display: none !important; }

.shape { display: inline-block; flex: none; width: 1em; height: 1em; }
.shape svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.ans-0 { background: var(--a0); }
.ans-1 { background: var(--a1); }
.ans-2 { background: var(--a2); }
.ans-3 { background: var(--a3); }

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 3px solid rgba(255, 255, 255, 0.85);
}

.btn {
  background: var(--brand-2);
  color: #04203a;
  font-weight: 800;
  border-radius: 14px;
  padding: 0.6em 1.4em;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { filter: grayscale(1) brightness(0.7); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 2px solid var(--surface-2); }

/* =====================================================================
   HOST / PROJECTOR  (sized in vw/vh so 720p and 1080p look identical)
   ===================================================================== */
body.host { overflow: hidden; }
.host .screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding: 2.2vh 2.6vw 9vh; }

/* Host login */
.host-login { align-items: center; justify-content: center; gap: 2vh; }
.host-login form { display: flex; gap: 1vw; }
.host-login input {
  font-size: 1.6vw; padding: 0.5em 0.8em; border-radius: 12px;
  border: 2px solid var(--surface-2); background: var(--surface); min-width: 22vw;
}
.host-login .btn { font-size: 1.6vw; }
.host-login .error { color: #ff8a80; font-size: 1.3vw; min-height: 1.5em; }

/* Brand header */
.brandbar { display: flex; align-items: center; gap: 1.2vw; }
.brandbar::after { content: ""; margin-left: auto; width: 22vw; height: 4.6vw; background: url("/brand/kufi_cropped.svg") right center / contain no-repeat; opacity: 0.35; }
.brandbar .logo { width: 4.6vw; height: 4.6vw; border-radius: 22%; background: #fff; padding: 0.35vw; }
.brandbar h1 { margin: 0; font-size: 2.4vw; font-weight: 900; letter-spacing: 0.01em; line-height: 1; }
.brandbar h1 small { display: block; font-size: 0.55em; font-weight: 700; color: var(--brand-2); letter-spacing: 0.08em; margin-top: 0.35vh; }

/* Lobby */
.lobby { display: grid; grid-template-columns: 40vw 1fr; gap: 3vw; flex: 1; min-height: 0; margin-top: 2.5vh; }
.join-card {
  background: var(--surface);
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.5vh 2vw; gap: 2vh;
}
.join-card .qr { background: #fff; border-radius: 16px; padding: 1.2vh; width: min(48vh, 34vw); aspect-ratio: 1; }
.join-card .qr img { width: 100%; height: 100%; }
.join-card .step { font-size: 1.7vw; color: var(--muted); margin: 0; text-align: center; line-height: 1.2; }
.join-card .url { font-size: 2.5vw; font-weight: 900; color: #fff; margin: 0; letter-spacing: 0.01em; text-align: center; line-height: 1.1; word-break: break-all; }

.lobby-side { display: flex; flex-direction: column; min-height: 0; }
.player-count { display: flex; align-items: baseline; gap: 1vw; margin: 0 0 1.5vh; }
.player-count b { font-size: 6vw; font-weight: 900; line-height: 0.9; color: var(--brand-2); }
.player-count span { font-size: 2vw; color: var(--muted); }
.player-grid {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 1vh 0.8vw;
}
.chip {
  display: flex; align-items: center; gap: 0.6vw;
  background: var(--surface); border-radius: 999px; padding: 0.4vh 1.1vw 0.4vh 0.4vh;
  font-size: 1.45vw; max-width: 100%;
  animation: pop-in 0.35s ease-out;
}
.chip img { width: 3.2vw; height: 3.2vw; border-width: 2px; }
.chip .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.offline { opacity: 0.45; }
.chip:hover { outline: 2px solid var(--danger); }
.lobby-empty { font-size: 1.8vw; color: var(--muted); }

/* Question & reveal */
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 2vw; }
.q-meta { display: flex; align-items: center; gap: 1.2vw; }
.q-index { font-size: 2.2vw; font-weight: 900; }
.q-cat { font-size: 1.5vw; background: var(--surface-2); color: var(--brand-2); padding: 0.3vh 1vw; border-radius: 999px; }
.q-answered { font-size: 1.7vw; color: var(--muted); }
.q-answered b { color: #fff; font-size: 1.2em; }

.timer { position: relative; width: 9vh; height: 9vh; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 9; }
.timer .track { stroke: var(--surface-2); }
.timer .bar { stroke: var(--brand-2); stroke-linecap: round; transition: stroke 0.3s; }
.timer.low .bar { stroke: #ff5252; }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 4.2vh; font-weight: 900; }

.q-text-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 1.5vh 3vw; }
.q-text-wrap { overflow: hidden; gap: 2.5vw; }
.q-text-box { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
/* Image questions: picture on the left, question on the right (uses the 16:9 width, keeps the text large). */
.q-image { height: 100%; max-width: 42vw; object-fit: contain; border-radius: 14px; background: #000; box-shadow: 0 0.6vh 2vh rgba(0, 0, 0, 0.5); }
.has-image .q-text { text-align: left; }
.q-text { margin: 0; text-align: center; font-weight: 800; line-height: 1.18; max-width: 88vw; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6vh 1.2vw; height: 38vh; flex: none; }
.answer {
  position: relative; display: flex; align-items: center; gap: 1.4vw;
  border-radius: var(--radius); padding: 1.2vh 1.6vw; overflow: hidden;
  transition: opacity 0.3s, transform 0.3s;
}
.answer .shape { font-size: 3.4vw; opacity: 0.95; }
.answer .text { flex: 1; font-weight: 800; line-height: 1.12; }
.answer .count { font-size: 2.6vw; font-weight: 900; margin-left: auto; padding-left: 1vw; }
.answer .tick { position: absolute; top: 0.8vh; right: 0.8vw; font-size: 2.6vw; }
.reveal .answer.wrong { opacity: 0.28; }
.reveal .answer.right { outline: 0.5vh solid #fff; transform: scale(1.015); }

/* Leaderboard */
.board { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 1.6vh; padding: 0 12vw; }
.board h2 { margin: 0 0 1vh; text-align: center; font-size: 3.6vw; font-weight: 900; }
.board-row {
  display: flex; align-items: center; gap: 1.6vw;
  background: var(--surface); border-radius: var(--radius); padding: 1.2vh 2vw;
  font-size: 2.6vw; animation: slide-in 0.45s ease-out both;
}
.board-row .rank { width: 3.4vw; text-align: center; font-weight: 900; color: var(--brand-2); }
.board-row img { width: 6.4vh; height: 6.4vh; }
.board-row .name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-row .score { font-weight: 900; font-variant-numeric: tabular-nums; }
.board-row .move { font-size: 0.75em; font-weight: 900; min-width: 4.5vw; text-align: center; }
.board-row .move.up { color: #69f0ae; }
.board-row .move.down { color: #ff8a80; }
.board-row .move.same { color: var(--muted); }
.board-row:nth-child(2) { background: linear-gradient(90deg, #5a4300, var(--surface) 60%); }

/* Podium */
.podium { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2vw; padding-bottom: 2vh; }
.podium .place { display: flex; flex-direction: column; align-items: center; width: 22vw; opacity: 0; transform: translateY(6vh); transition: opacity 0.7s, transform 0.7s; }
.podium .place.show { opacity: 1; transform: none; }
.podium .place img { width: 17vh; height: 17vh; border-width: 6px; margin-bottom: 1.2vh; }
.podium .place .name { font-size: 2.4vw; font-weight: 900; text-align: center; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .place .avatar-name { font-size: 1.6vw; font-weight: 700; color: var(--brand-2); margin-top: 0.3vh; }
.podium .place .score { font-size: 1.8vw; color: var(--muted); margin-bottom: 1.2vh; }
.podium .block { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: center; font-size: 6vw; font-weight: 900; color: #06142b; }
.podium .p1 .block { height: 30vh; background: var(--gold); }
.podium .p2 .block { height: 21vh; background: var(--silver); }
.podium .p3 .block { height: 14vh; background: var(--bronze); }
.podium .p1 img { border-color: var(--gold); width: 22vh; height: 22vh; }
.podium-title { text-align: center; font-size: 3.4vw; font-weight: 900; margin: 1vh 0 0; }

/* Host control bar (bottom, small: it is for the presenter, not the audience) */
.controls {
  position: fixed; left: 0; right: 0; bottom: 0; height: 7vh;
  display: flex; align-items: center; justify-content: space-between; padding: 0 2.6vw;
  background: rgba(3, 10, 22, 0.85);
}
.controls .hint { font-size: 1.1vw; color: var(--muted); font-weight: 600; }
.controls .group { display: flex; gap: 0.8vw; }
.controls .btn { font-size: 1.4vw; padding: 0.35em 1.2em; }
.toast {
  position: fixed; top: 2vh; left: 50%; transform: translateX(-50%);
  background: var(--danger); padding: 0.6em 1.2em; border-radius: 12px; font-size: 1.4vw; z-index: 20;
}

.follow {
  position: fixed; inset: 0; z-index: 5; background: rgba(6, 20, 43, 0.96);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh;
  animation: pop-in 0.5s ease-out;
}
.follow-logo { width: 9vw; height: 9vw; border-radius: 22%; background: #fff; padding: 0.6vw; }
.follow h2 { margin: 0; font-size: 3.6vw; font-weight: 900; }
.follow-row { display: flex; align-items: center; gap: 4vw; }
.follow .qr { background: #fff; border-radius: 16px; padding: 1.2vh; width: min(42vh, 28vw); aspect-ratio: 1; }
.follow .qr img { width: 100%; height: 100%; }
.follow-call { margin: 0; font-size: 2.6vw; color: var(--muted); }
.follow-handle { margin: 0.5vh 0; font-size: 5.2vw; font-weight: 900; color: var(--brand-2); line-height: 1; }
.follow-url { margin: 0; font-size: 1.8vw; color: var(--muted); }
.insta-btn { display: inline-block; text-decoration: none; font-size: 18px; margin-top: 8px;
  background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); color: #fff; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

@keyframes pop-in { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-in { from { transform: translateX(-4vw); opacity: 0; } to { transform: none; opacity: 1; } }

/* =====================================================================
   PLAYER / PHONE
   ===================================================================== */
body.player { min-height: 100%; min-height: 100dvh; }
.player .screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.player .center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }

.p-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.p-head .logo { width: 48px; height: 48px; border-radius: 12px; background: #fff; padding: 3px; }
.p-head h1 { margin: 0; font-size: 22px; font-weight: 900; line-height: 1.05; }
.p-head h1 small { display: block; font-size: 13px; color: var(--brand-2); letter-spacing: 0.06em; font-weight: 700; margin-top: 4px; line-height: 1.2; }

.field-label { font-size: 15px; color: var(--muted); margin: 6px 0; display: block; }
.name-input {
  width: 100%; font-size: 20px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--surface-2); background: var(--surface); outline: none;
}
.name-input:focus { border-color: var(--brand-2); }

.avatar-hint { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--gold); }
.avatar-group { font-size: 14px; font-weight: 800; color: var(--brand-2); letter-spacing: 0.06em; text-transform: uppercase; margin: 12px 0 6px; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 8px; margin: 4px 0 8px; }
.avatar-option { background: none; padding: 4px 0; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.avatar-option img { width: 100%; max-width: 76px; aspect-ratio: 1; border-color: transparent; border-width: 3px; }
.avatar-option span { font-size: 11.5px; line-height: 1.1; color: var(--muted); font-weight: 600; text-align: center; }
.avatar-option[aria-pressed="true"] img { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(27, 179, 215, 0.35); }
.avatar-option[aria-pressed="true"] span { color: #fff; font-weight: 800; }

.join-bar { position: sticky; bottom: 0; padding-top: 10px; background: linear-gradient(transparent, var(--bg) 30%); }
.join-bar .btn { width: 100%; font-size: 21px; padding: 15px; }
.form-error { color: #ff8a80; min-height: 1.3em; font-size: 15px; margin: 6px 0 0; }

.me-avatar { width: 130px; height: 130px; border-width: 5px; }
.big-name { font-size: 28px; font-weight: 900; margin: 0; }
.muted { color: var(--muted); font-weight: 600; font-size: 17px; margin: 0; }

.p-qtop { display: flex; justify-content: space-between; align-items: center; font-size: 16px; color: var(--muted); margin-bottom: 8px; }
.p-qtop .p-timer { font-size: 22px; font-weight: 900; color: #fff; min-width: 2ch; text-align: right; }
.p-qimage { display: block; max-width: 100%; max-height: 24vh; margin: 0 auto 10px; border-radius: 12px; object-fit: contain; }
.p-qtext { font-size: 19px; line-height: 1.25; margin: 0 0 14px; font-weight: 700; }
.p-answers { flex: 1; display: grid; grid-auto-rows: 1fr; gap: 10px; }
.p-answer {
  display: flex; align-items: center; gap: 14px; text-align: left;
  border-radius: 16px; padding: 12px 16px; font-size: 19px; font-weight: 800; color: #fff; min-height: 64px; line-height: 1.15;
}
.p-answer .shape { font-size: 30px; }
.p-answer:active { transform: scale(0.98); }

.result { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; border-radius: 22px; padding: 24px; }
.result.ok { background: var(--success); }
.result.bad { background: var(--danger); }
.result.neutral { background: var(--surface); }
.result .icon { font-size: 64px; line-height: 1; }
.result h2 { margin: 0; font-size: 34px; font-weight: 900; }
.result .pts { font-size: 26px; font-weight: 900; }
.result .sub { font-size: 18px; font-weight: 700; opacity: 0.92; }
.chosen { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 14px; font-size: 20px; }

.rank-big { font-size: 64px; font-weight: 900; line-height: 1; color: var(--brand-2); margin: 0; }
.medal { font-size: 72px; line-height: 1; }

.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  background: var(--a2); color: #fff; text-align: center; font-size: 15px; padding: 8px;
}
