/*
 * Thinko custom styles.
 * Tailwind utility classes do most of the work in the templates; this file
 * holds the few reusable components (buttons, cards, answer tiles) and the
 * animations, so the templates stay short and readable.
 */

:root {
  --bg-1: #1e1048;
  --bg-2: #3b0f6b;
  --accent-1: #a78bfa;
  --accent-2: #f472b6;
  --tile-red: #ef4444;
  --tile-blue: #3b82f6;
  --tile-yellow: #f59e0b;
  --tile-green: #10b981;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: radial-gradient(circle at 20% 0%, var(--bg-2), var(--bg-1) 55%, #0c0624);
  background-attachment: fixed;
}

/* Soft glowing circles behind the content. */
.bg-orbs::before,
.bg-orbs::after {
  content: "";
  position: fixed;
  border-radius: 9999px;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}
.bg-orbs::before { width: 420px; height: 420px; background: #7c3aed; top: -120px; right: -80px; }
.bg-orbs::after { width: 360px; height: 360px; background: #db2777; bottom: -140px; left: -100px; }

.text-gradient {
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- Cards ---------------------------------------------------------------- */

.glass {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* --- Buttons, links and inputs --------------------------------------------- */

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 0.9rem;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  box-shadow: 0 10px 25px rgba(236, 72, 153, 0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(236, 72, 153, 0.45); }
.btn-ghost { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.18); }
.btn-primary:disabled,
.btn-ghost[aria-disabled="true"] { opacity: 0.4; pointer-events: none; transform: none; box-shadow: none; }

.nav-link { padding: 0.4rem 0.75rem; border-radius: 0.6rem; font-weight: 600; color: rgba(237, 233, 254, 0.85); cursor: pointer; }
.nav-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.input,
.select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.8rem;
  background: rgba(15, 8, 40, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: rgba(221, 214, 254, 0.4); }
.input:focus,
.select:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.3); }
.select option { background: #1e1048; }

.form-error {
  padding: 0.6rem 0.9rem;
  border-radius: 0.7rem;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  font-size: 0.9rem;
  font-weight: 600;
}

.badge-guest {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  background: rgba(251, 191, 36, 0.2);
  color: #fde68a;
}

/* --- Answer tiles (shared by the landing page and the game) --------------- */

.tile-red { background: var(--tile-red); }
.tile-blue { background: var(--tile-blue); }
.tile-yellow { background: var(--tile-yellow); }
.tile-green { background: var(--tile-green); }

.mini-tile {
  display: grid;
  place-items: center;
  height: 3.5rem;
  border-radius: 0.8rem;
  font-size: 1.4rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

/* --- Animations ------------------------------------------------------------ */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fade-up 0.45s ease both; }

/* Respect users who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Lobby ------------------------------------------------------------------ */

[x-cloak] { display: none !important; }

.room-card { transition: transform 0.2s ease, border-color 0.2s ease; }
.room-card:hover { transform: translateY(-4px); border-color: rgba(167, 139, 250, 0.45); }

.status-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
}
.status-waiting { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.status-playing { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

.stat { padding: 0.6rem 0.25rem; border-radius: 0.8rem; background: rgba(255, 255, 255, 0.06); }
.stat dt { font-size: 0.7rem; font-weight: 600; color: rgba(221, 214, 254, 0.6); text-transform: uppercase; letter-spacing: 0.04em; }
.stat dd { margin-top: 0.15rem; font-size: 1.15rem; font-weight: 800; }

/* --- Room -------------------------------------------------------------------- */

.room-code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  padding: 0.45rem 0.9rem;
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px dashed rgba(255, 255, 255, 0.3);
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  animation: fade-up 0.3s ease both;
}
.player-row.is-away { opacity: 0.5; }
.player-row.is-me { background: rgba(167, 139, 250, 0.2); outline: 1px solid rgba(167, 139, 250, 0.4); }

.avatar {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 9999px;
  font-weight: 800;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.55); }
  100% { box-shadow: 0 0 0 26px rgba(167, 139, 250, 0); }
}
.pulse-ring {
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  font-size: 2.2rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  animation: pulse-ring 1.6s ease-out infinite;
}

/* --- Game: question --------------------------------------------------------- */

.countdown {
  min-width: 3.5rem;
  padding: 0.35rem 0.8rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 1.25rem;
  font-weight: 900;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.timebar { height: 0.5rem; border-radius: 9999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.timebar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
  transform-origin: left;
  animation: shrink linear forwards;
}
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.question-text { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 900; line-height: 1.25; text-align: center; }

.answer-tile {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 4.5rem;
  padding: 1rem 1.2rem;
  border-radius: 1rem;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22), 0 8px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
}
.answer-tile:not(:disabled):hover { transform: translateY(-3px) scale(1.01); filter: brightness(1.08); }
.answer-tile:not(:disabled):active { transform: translateY(1px); }
.answer-tile:disabled { cursor: default; }
.answer-shape { font-size: 1.5rem; width: 2rem; text-align: center; flex-shrink: 0; }

.answer-tile.is-chosen { outline: 4px solid #fff; outline-offset: 3px; }
.answer-tile.is-dimmed { opacity: 0.3; filter: grayscale(0.6); }
.answer-tile.is-correct { outline: 4px solid #fff; outline-offset: 3px; animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 0 0 rgba(255, 255, 255, 0); } to { box-shadow: 0 0 28px rgba(255, 255, 255, 0.55); } }

.answer-count {
  display: block;
  padding: 0.7rem 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
  font-weight: 700;
}

/* --- Game: reveal ------------------------------------------------------------- */

.result-banner { display: inline-block; padding: 0.6rem 1.4rem; border-radius: 9999px; font-size: 1.4rem; font-weight: 900; }
.result-correct { background: rgba(16, 185, 129, 0.25); color: #a7f3d0; }
.result-wrong { background: rgba(239, 68, 68, 0.25); color: #fecaca; }
.result-timeout { background: rgba(245, 158, 11, 0.25); color: #fde68a; }

@keyframes pop-in {
  0% { opacity: 0; transform: scale(0.4); }
  70% { opacity: 1; transform: scale(1.15); }
  100% { transform: scale(1); }
}
.pop-in { animation: pop-in 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.2) both; }

/* --- Game: podium -------------------------------------------------------------- */

.podium-column { display: flex; flex-direction: column; align-items: center; animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(60px); } to { opacity: 1; transform: translateY(0); } }

.podium-step {
  display: grid;
  place-items: center;
  width: 6rem;
  margin-top: 0.6rem;
  border-radius: 1rem 1rem 0.3rem 0.3rem;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.2);
}
.podium-1 { height: 9rem; background: linear-gradient(180deg, #fbbf24, #d97706); }
.podium-2 { height: 6.5rem; background: linear-gradient(180deg, #cbd5e1, #64748b); }
.podium-3 { height: 5rem; background: linear-gradient(180deg, #fb923c, #9a3412); }
@media (min-width: 640px) { .podium-step { width: 8rem; } }

/* --- Leaderboard ------------------------------------------------------------- */

.leaderboard th { padding: 1rem 1.25rem; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(221, 214, 254, 0.6); background: rgba(255, 255, 255, 0.04); }
.leaderboard td { padding: 0.9rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.leaderboard tbody tr { transition: background 0.15s ease; }
.leaderboard tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
.leaderboard tr.is-me { background: rgba(167, 139, 250, 0.18); }

/* --- Small screens ----------------------------------------------------------- */

.btn-small { padding: 0.5rem 0.9rem; border-radius: 0.75rem; font-size: 0.9rem; }

/* Hide the empty answer counter so it does not leave a gap. */
.answer-slot:not(:has(.answer-count)) { display: none; }

/* Answer tiles: on phones the shape sits above a centered label, like a big button. */
.answer-label { min-width: 0; overflow-wrap: anywhere; }
.answer-mark { position: absolute; top: 0.45rem; right: 0.6rem; }
.answer-tile { position: relative; }

@media (max-width: 639px) {
  .answer-tile {
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    min-height: 6.5rem;
    padding: 0.75rem 0.5rem;
    font-size: 0.95rem;
    line-height: 1.2;
    text-align: center;
  }
  .answer-shape { font-size: 1.35rem; width: auto; }
  .room-code { font-size: 0.95rem; letter-spacing: 0.12em; padding: 0.4rem 0.6rem; }
  .result-banner { font-size: 1.1rem; padding: 0.5rem 1.1rem; }
  .countdown { font-size: 1.05rem; min-width: 3rem; }
  .podium-step { width: 5.5rem; }
  .podium-1 { height: 7rem; }
  .podium-2 { height: 5rem; }
  .podium-3 { height: 3.75rem; }
  .nav-link { padding: 0.45rem 0.6rem; font-size: 1.05rem; }
  .leaderboard th, .leaderboard td { padding: 0.75rem 0.6rem; }
}

@media (min-width: 640px) {
  .answer-label { flex: 1; text-align: left; }
  .answer-mark { position: static; }
}
