/* ──────────────────────────────────────────────────────────
   Design Tokens
   ────────────────────────────────────────────────────────── */
:root {
  --bg:          #0d1117;
  --bg-2:        #161b22;
  --bg-3:        #21262d;
  --bg-hover:    #30363d;
  --border:      #30363d;
  --border-hi:   #484f58;

  --txt:         #e6edf3;
  --txt-2:       #8b949e;
  --txt-muted:   #6e7681;

  --accent:      #7c3aed;
  --accent-dim:  rgba(124,58,237,.15);
  --accent-hi:   #9461fb;
  --accent-fg:   #a78bfa;

  --green:       #238636;
  --green-fg:    #3fb950;
  --red:         #da3633;
  --red-fg:      #f85149;
  --gold-fg:     #e3b341;

  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  18px;
  --r-pill:9999px;

  --sh-sm: 0 1px 3px rgba(0,0,0,.4);
  --sh-md: 0 4px 12px rgba(0,0,0,.5);
  --sh-lg: 0 8px 24px rgba(0,0,0,.6);
  --sh-accent: 0 0 0 3px rgba(124,58,237,.35);

  --ease: cubic-bezier(.4,0,.2,1);
}

/* ──────────────────────────────────────────────────────────
   Reset & Base
   ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ──────────────────────────────────────────────────────────
   HOME VIEW
   ────────────────────────────────────────────────────────── */
#home-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 16px;
  gap: 48px;
}

/* Hero */
.hero { text-align: center; }

.hero-logo {
  display: block;
  width: 124px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 24px rgba(167,139,250,.5));
  animation: float 4s ease-in-out infinite;
}

.hero-logo img {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.hero h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #c4b5fd 0%, #7c3aed 60%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.hero p {
  font-size: 17px;
  color: var(--txt-2);
}

/* Panels */
.home-panels {
  display: flex;
  align-items: stretch;
  gap: 0;
  max-width: 700px;
  width: 100%;
}

.home-panel {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.home-panel:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--sh-md);
}

.panel-head { display: flex; flex-direction: column; gap: 4px; }

.panel-icon { font-size: 28px; margin-bottom: 6px; }

.panel-head h2 { font-size: 18px; font-weight: 700; }

.panel-head p { font-size: 13px; color: var(--txt-2); }

/* Divider */
.home-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  flex-shrink: 0;
  color: var(--txt-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.divider-line {
  flex: 1;
  width: 1px;
  min-height: 30px;
  background: var(--border);
}

/* ──────────────────────────────────────────────────────────
   FORMS
   ────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--txt-2);
}

.label-optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--txt-muted); }

.form-group input,
.form-group textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--txt);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--sh-accent);
}

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--txt-muted); }

/* Big session-code style input */
.code-input {
  font-size: 22px !important;
  font-weight: 700 !important;
  letter-spacing: 6px !important;
  text-align: center;
  text-transform: uppercase;
  font-family: 'Courier New', monospace !important;
}

.form-row { display: flex; gap: 10px; }

/* ──────────────────────────────────────────────────────────
   BUTTONS
   ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  transition: all .15s var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--sh-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hi);
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--txt);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #3d444d; border-color: var(--border-hi); }

.btn-outline {
  background: transparent;
  color: var(--txt);
  border: 1px solid var(--border-hi);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-3); }

.btn-ghost {
  background: transparent;
  color: var(--txt-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--txt); }

.btn-full  { width: 100%; }
.btn-sm    { padding: 6px 12px; font-size: 12px; }
.btn-lg    { padding: 14px 32px; font-size: 15px; border-radius: var(--r-lg); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--txt-2);
  cursor: pointer;
  font-size: 15px;
  height: 30px;
  width: 30px;
  padding: 0;
  transition: all .15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--txt); }

.btn-icon-copy {
  color: var(--accent-fg);
  background: var(--accent-dim);
  border: 1px solid rgba(124,58,237,.35);
  font-size: 16px;
}

.btn-icon-copy:hover {
  background: rgba(124,58,237,.25);
  color: #c4b5fd;
}

/* ──────────────────────────────────────────────────────────
   ERROR BANNER
   ────────────────────────────────────────────────────────── */
.error-banner {
  background: rgba(218,54,51,.12);
  border: 1px solid var(--red);
  border-radius: var(--r-md);
  color: var(--red-fg);
  font-size: 13px;
  padding: 10px 16px;
  text-align: center;
  max-width: 700px;
  width: 100%;
  animation: fadeIn .2s var(--ease);
}

@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ──────────────────────────────────────────────────────────
   GAME VIEW
   ────────────────────────────────────────────────────────── */
#game-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.game-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }

.brand-icon {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 4px;
}

.header-session-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 14px;
}

.pill-label { font-size: 11px; color: var(--txt-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.pill-code {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent-fg);
  font-family: 'Courier New', monospace;
}

.header-right { display: flex; align-items: center; }

.online-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--txt-2);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 5px 12px;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-fg);
  box-shadow: 0 0 6px var(--green-fg);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* Main content */
.game-main {
  flex: 1;
  padding: 32px 24px 48px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Generic card */
.card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
}

/* ──────────────────────────────────────────────────────────
   TICKET
   ────────────────────────────────────────────────────────── */
.ticket-view {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ticket-left { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }

.ticket-badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent-dim);
  border: 1px solid rgba(124,58,237,.35);
  border-radius: var(--r-sm);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-fg);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.ticket-title { font-size: 17px; font-weight: 600; line-height: 1.4; }
.ticket-title.muted { color: var(--txt-muted); font-style: italic; font-weight: 400; }
.ticket-desc { font-size: 13px; color: var(--txt-2); margin-top: 4px; }
.ticket-settings { font-size: 12px; color: var(--txt-muted); margin-top: 8px; }

.ticket-form { display: none; flex-direction: column; gap: 14px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.ticket-form.open { display: flex; }

.settings-grid {
  display: grid;
  gap: 12px;
}

.settings-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.settings-switch.form-check.form-switch {
  min-height: 0;
  padding-left: 0;
}

.settings-switch .form-check-input {
  margin: 0;
  width: 2.75rem;
  height: 1.45rem;
  border: 1px solid var(--accent);
  background-color: var(--bg-2);
  box-shadow: none;
  cursor: pointer;
}

.settings-switch .form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.settings-switch .form-check-input:focus {
  border-color: var(--accent-hi);
  box-shadow: var(--sh-accent);
}

.settings-switch .form-check-label {
  margin: 0;
  color: var(--txt);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ──────────────────────────────────────────────────────────
   SECTION HEADERS
   ────────────────────────────────────────────────────────── */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.team-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

.vote-progress {
  font-size: 12px;
  font-weight: 600;
  color: var(--txt-muted);
}

/* ──────────────────────────────────────────────────────────
   PARTICIPANTS GRID
   ────────────────────────────────────────────────────────── */
.participants-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  min-height: 130px;
}

.participant-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* The 3D card flip container */
.p-card-wrap {
  width: 60px;
  height: 84px;
  perspective: 900px;
}

.p-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.34,1.2,.64,1);
}

.p-card-inner.flipped { transform: rotateY(180deg); }

.p-card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Back face (face-down) */
.p-card-back {
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  flex-direction: column;
  gap: 4px;
}

.p-card-back.voted {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 12px rgba(124,58,237,.2);
}

.card-dots {
  display: grid;
  grid-template-columns: repeat(3, 6px);
  grid-template-rows: repeat(3, 6px);
  gap: 4px;
  opacity: .35;
}

.card-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-fg);
  display: block;
}

.card-check {
  font-size: 22px;
  color: var(--accent-fg);
}

/* Front face (revealed) */
.p-card-front {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  transform: rotateY(180deg);
  flex-direction: column;
  position: relative;
  box-shadow: var(--sh-sm);
}

.cv-corner {
  position: absolute;
  font-size: 10px;
  font-weight: 800;
  color: #6b21a8;
  line-height: 1;
}
.cv-corner.tl { top: 6px; left: 7px; }
.cv-corner.br { bottom: 6px; right: 7px; transform: rotate(180deg); }

.cv-main {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

/* Participant name & tags */
.p-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-2);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.p-tags { display: flex; flex-direction: column; align-items: center; gap: 3px; }

.p-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.tag-host { background: rgba(227,179,65,.12); color: var(--gold-fg); border: 1px solid rgba(227,179,65,.25); }
.tag-you  { background: var(--accent-dim); color: var(--accent-fg); border: 1px solid rgba(124,58,237,.3); }

/* ──────────────────────────────────────────────────────────
   VOTING CARDS
   ────────────────────────────────────────────────────────── */
.voting-card { }

.voting-card .section-title { margin-bottom: 18px; }

.vote-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.vote-btn {
  width: 58px;
  height: 80px;
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  color: var(--txt);
  cursor: pointer;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s var(--ease);
  position: relative;
}

.vote-btn:hover {
  border-color: var(--accent);
  color: var(--accent-fg);
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(124,58,237,.25);
}

.vote-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(124,58,237,.4);
}

.vote-btn:active { transform: translateY(-2px); }

.vote-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
  box-shadow: none;
}

.vote-btn:disabled:hover {
  border-color: var(--border);
  color: var(--txt);
  transform: none;
  box-shadow: none;
}

/* ──────────────────────────────────────────────────────────
   RESULTS
   ────────────────────────────────────────────────────────── */
.results-card .section-title { margin-bottom: 20px; }

.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  text-align: center;
  min-width: 100px;
}

.stat-val {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent-fg);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-lbl {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--txt-muted);
}

.consensus-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

.chip-yes { background: rgba(35,134,54,.15); border: 1px solid rgba(35,134,54,.3); color: var(--green-fg); }
.chip-no  { background: rgba(218,54,51,.12); border: 1px solid rgba(218,54,51,.3); color: var(--red-fg);  }
.chip-info { background: var(--accent-dim); border: 1px solid rgba(124,58,237,.3); color: var(--accent-fg); }

.vote-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vote-pill {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-size: 13px;
  color: var(--txt-2);
}

.vote-pill strong { color: var(--txt); }
.vote-pill .pill-val { color: var(--accent-fg); font-weight: 700; }

/* ──────────────────────────────────────────────────────────
   CONTROLS
   ────────────────────────────────────────────────────────── */
.controls-row {
  display: flex;
  justify-content: center;
  gap: 14px;
}

/* ──────────────────────────────────────────────────────────
   WAITING EMPTY STATE
   ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--txt-muted);
  width: 100%;
}

.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; }

.empty-state p { font-size: 14px; color: var(--txt-2); }

@keyframes slow-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}
.slow-pulse { animation: slow-pulse 2.5s ease-in-out infinite; }

/* ──────────────────────────────────────────────────────────
   TOAST
   ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-hover);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-md);
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  z-index: 9999;
  box-shadow: var(--sh-lg);
  pointer-events: none;
  animation: toastIn .25s var(--ease);
  white-space: nowrap;
}

.toast.success { border-color: var(--green); color: var(--green-fg); }
.toast.error   { border-color: var(--red);   color: var(--red-fg);   }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0);   }
}

/* ──────────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .home-panels { flex-direction: column; }

  .home-divider {
    flex-direction: row;
    width: 100%;
    padding: 4px 0;
  }
  .home-divider .divider-line {
    width: auto;
    height: 1px;
    min-height: unset;
    min-width: 30px;
    flex: 1;
  }

  .game-header { padding: 0 14px; }
  .pill-label  { display: none; }
  .game-main   { padding: 20px 14px 40px; }
  .home-panel  { padding: 24px; }
  .hero h1     { font-size: 34px; }
  .hero-logo   { width: 98px; }
}

@media (max-width: 400px) {
  .header-session-pill { padding: 5px 10px; }
  .pill-code            { font-size: 13px; letter-spacing: 2px; }
}
