/* ==========================================
   RIDGE AGAINST HUMANITY - Styles
   Black / White / Gold CAH aesthetic
   ========================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:   #0a0a0a;
  --black2:  #141414;
  --black3:  #1e1e1e;
  --white:   #ffffff;
  --offwhite:#f5f5f5;
  --gold:    #D4AF37;
  --gold2:   #f0d060;
  --red:     #ef4444;
  --green:   #22c55e;
  --dim:     #888;
  --radius:  8px;
  --card-radius: 10px;
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--black);
  color: var(--white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Canvas ---- */
#fx-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
}

/* ---- Screens ---- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ---- Toasts ---- */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  max-width: 360px; word-break: break-word;
  animation: slideIn 0.2s ease;
}
.toast.info    { background: #1e293b; border: 1px solid #334155; color: #cbd5e1; }
.toast.success { background: #052e16; border: 1px solid #16a34a; color: #86efac; }
.toast.error   { background: #450a0a; border: 1px solid #dc2626; color: #fca5a5; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 15px; font-weight: 800; letter-spacing: 0.05em;
  cursor: pointer; border: none; transition: all 0.15s;
  text-transform: uppercase;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary  { background: var(--gold); color: var(--black); }
.btn-primary:not(:disabled):hover { background: var(--gold2); }
.btn-secondary { background: var(--white); color: var(--black); }
.btn-secondary:not(:disabled):hover { background: var(--offwhite); }
.btn-ghost    { background: transparent; color: var(--gold); border: 1px solid var(--gold); }
.btn-ghost:not(:disabled):hover { background: rgba(212,175,55,0.1); }
.btn-large    { padding: 16px 40px; font-size: 17px; }
.btn-small    { padding: 7px 14px; font-size: 12px; }

/* ---- Input ---- */
.input {
  background: var(--black3); color: var(--white);
  border: 1px solid #333; border-radius: var(--radius);
  padding: 12px 16px; font-size: 15px; width: 100%;
}
.input:focus { outline: none; border-color: var(--gold); }
.input-small { padding: 8px 12px; font-size: 13px; }

/* ---- Panel ---- */
.panel {
  background: var(--black2); border: 1px solid #222;
  border-radius: var(--radius); padding: 20px;
}
.panel-title {
  font-size: 11px; font-weight: 800; letter-spacing: 0.15em;
  color: var(--gold); text-transform: uppercase; margin-bottom: 14px;
}

/* ---- Misc ---- */
.text-dim { color: var(--dim); font-size: 14px; }
.hidden { display: none !important; }
.divider {
  color: var(--dim); font-size: 13px; text-align: center;
  margin: 10px 0; letter-spacing: 0.05em;
}

/* ===========================================
   HOME SCREEN
   =========================================== */
#screen-home {
  display: none;
  align-items: center; justify-content: center;
  min-height: 100vh;
}
#screen-home.active { display: flex; }

.home-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 48px; padding: 40px 20px; max-width: 400px; width: 100%;
}

.home-logo { text-align: center; line-height: 1.05; }
.logo-line1 {
  font-size: clamp(36px, 8vw, 64px);
  font-weight: 900;
  color: var(--white);
  letter-spacing: -0.02em;
}
.logo-line2 {
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 900;
  color: var(--gold);
  letter-spacing: -0.02em;
}
.logo-sub {
  font-size: clamp(12px, 2.5vw, 15px);
  font-weight: 400;
  color: var(--dim);
  margin-top: 14px;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.home-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; text-transform: uppercase; letter-spacing: 0.1em; }

/* ===========================================
   LOBBY
   =========================================== */
.lobby-wrap {
  max-width: 900px; margin: 0 auto; padding: 32px 20px;
  display: flex; flex-direction: column; gap: 24px;
}
.lobby-header { text-align: center; }
.lobby-title {
  font-size: 28px; font-weight: 900; letter-spacing: 0.08em;
  color: var(--white); margin-bottom: 16px;
}
.room-code-block {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; flex-wrap: wrap;
}
.room-code-label { font-size: 11px; font-weight: 700; letter-spacing: 0.15em; color: var(--dim); }
.room-code-value { font-size: 36px; font-weight: 900; letter-spacing: 0.2em; color: var(--gold); }

.lobby-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .lobby-body { grid-template-columns: 1fr; } }

.player-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #222; font-size: 14px;
}
.player-item:last-child { border-bottom: none; }
.player-item.me { color: var(--gold); }
.player-handle { flex: 1; font-weight: 600; }
.player-host-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em;
  background: var(--gold); color: var(--black); padding: 2px 6px; border-radius: 4px;
}
.badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em;
  background: #1e293b; color: #94a3b8; padding: 2px 6px; border-radius: 4px;
}

.name-row { display: flex; gap: 8px; margin-top: 14px; }
.rules-list { list-style: disc; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.rules-list li { font-size: 13px; color: #ccc; line-height: 1.5; }

.lobby-footer { text-align: center; }

/* ===========================================
   GAME HEADER
   =========================================== */
.game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--black2); border-bottom: 1px solid #222;
  position: sticky; top: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.round-label  { font-size: 12px; font-weight: 800; letter-spacing: 0.15em; color: var(--dim); }
.judge-badge  { font-size: 13px; font-weight: 700; color: var(--gold); }

.timer-display {
  background: var(--black3); border: 1px solid #333;
  border-radius: 6px; padding: 4px 12px; font-size: 18px; font-weight: 900;
}
.timer-display.urgent { border-color: var(--red); color: var(--red); animation: pulse 0.5s ease infinite alternate; }
.timer-unit { font-size: 12px; margin-left: 2px; color: var(--dim); }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

.follower-count { font-size: 13px; font-weight: 700; color: var(--gold); }

/* Goal bar */
.goal-bar-wrap { display: flex; align-items: center; gap: 8px; padding: 6px 20px; background: var(--black2); border-bottom: 1px solid #1a1a1a; }
.goal-bar { flex: 1; height: 4px; background: #222; border-radius: 2px; }
.goal-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.4s ease; width: 0%; }
.goal-percent { font-size: 11px; font-weight: 700; color: var(--gold); min-width: 40px; text-align: right; }
.goal-label { font-size: 11px; color: var(--dim); }

.next-round-preview {
  background: #1a1500; border-bottom: 1px solid #3a2a00;
  color: var(--gold); font-size: 12px; font-weight: 600;
  padding: 6px 20px; letter-spacing: 0.05em;
}

/* Game phases */
.game-phase { padding: 24px 20px; max-width: 960px; margin: 0 auto; }

/* ===========================================
   BLACK CARD
   =========================================== */
.black-card-display {
  background: var(--black); border: 2px solid var(--gold);
  border-radius: var(--card-radius); padding: 28px 28px 20px;
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}
.black-card-text {
  font-size: 22px; font-weight: 700; line-height: 1.45;
  color: var(--white); min-height: 60px;
}
.black-card-footer {
  font-size: 11px; font-weight: 800; letter-spacing: 0.2em;
  color: var(--gold); text-transform: uppercase; align-self: flex-end;
}
.black-card-sm { max-width: 380px; margin-top: 20px; }
.black-card-sm .black-card-text { font-size: 16px; }

/* ===========================================
   SUBMIT PHASE — WHITE CARD HAND
   =========================================== */
.submit-wrap { display: flex; flex-direction: column; gap: 28px; }

.hand-section { display: flex; flex-direction: column; gap: 16px; }
.hand-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.15em;
  color: var(--dim); text-transform: uppercase;
}

.white-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.white-card {
  background: var(--white); color: var(--black);
  border: 2px solid transparent; border-radius: var(--card-radius);
  padding: 16px 14px 28px; min-height: 120px;
  cursor: pointer; transition: all 0.15s; position: relative;
  font-size: 15px; font-weight: 600; line-height: 1.4;
  user-select: none;
}
.white-card::after {
  content: '♠';
  position: absolute; bottom: 8px; right: 10px;
  font-size: 14px; color: #ccc;
}
.white-card:hover { border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 6px 20px rgba(212,175,55,0.25); }
.white-card.selected {
  border-color: var(--gold); background: #fffbea;
  transform: translateY(-3px); box-shadow: 0 6px 20px rgba(212,175,55,0.4);
}
.white-card.selected::before {
  content: '✓';
  position: absolute; top: 8px; right: 10px;
  font-size: 16px; font-weight: 900; color: var(--gold);
}

/* Custom write-in card */
.custom-card-wrap { }
.custom-card {
  cursor: default; display: flex; align-items: flex-start;
  background: #f9f9f9; max-width: 300px;
}
.custom-card:hover { transform: none; box-shadow: none; border-color: transparent; }
.custom-card.selected { border-color: var(--gold); background: #fffbea; transform: none; }
.custom-card-input {
  border: none; background: transparent; font-size: 14px;
  font-weight: 600; color: var(--black); width: 100%;
  resize: none; outline: none; font-family: inherit; line-height: 1.4;
}
.custom-card-input::placeholder { color: #999; font-weight: 400; }

.submit-btn { align-self: flex-start; margin-top: 8px; }

/* ===========================================
   JUDGE WAIT / CONTESTANT WAIT
   =========================================== */
.waiting-wrap {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 60px 20px; text-align: center;
}
.waiting-icon { font-size: 56px; }
.waiting-wrap h2 { font-size: 22px; font-weight: 800; }
.submit-progress { font-size: 28px; font-weight: 900; color: var(--gold); }

.submitted-preview {
  margin-top: 8px; max-width: 440px;
}
.submitted-answer {
  background: var(--white); color: var(--black);
  border-radius: var(--card-radius); padding: 20px;
  font-size: 18px; font-weight: 700; line-height: 1.45;
}
.submitted-black-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.15em;
  color: var(--dim); text-transform: uppercase; margin-bottom: 8px;
}

/* ===========================================
   JUDGE PICK — TWEET CARDS (legacy, replaced by Slack cards)
   =========================================== */
.judge-pick-wrap { display: flex; flex-direction: column; gap: 20px; }
.judge-pick-title {
  font-size: 20px; font-weight: 900; text-align: center;
  color: var(--gold); letter-spacing: 0.05em;
}

.fill-in {
  color: var(--gold); font-weight: 800;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 1px;
}

/* ===========================================
   SLACK MESSAGE CARDS (judge + contestant view)
   =========================================== */
.slack-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 640px;
    margin: 0 auto;
}

.slack-msg {
    background: #1a1d21;
    border: 1px solid #2a2d31;
    border-radius: var(--card-radius);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.slack-msg:hover { border-color: #444; }
.slack-msg.selected { border-color: var(--gold); background: #1e1a00; }

.slack-avatar {
    width: 36px; height: 36px;
    border-radius: 6px;
    background: linear-gradient(135deg, #4a154b, #1264a3);
    flex-shrink: 0;
    margin-top: 2px;
}

.slack-content { flex: 1; min-width: 0; }

.slack-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.slack-username {
    font-size: 15px;
    font-weight: 700;
    filter: blur(5px);
    user-select: none;
    color: var(--white);
}
.slack-username.revealed { filter: none; color: var(--gold); }
.slack-timestamp { font-size: 12px; color: var(--dim); }

.slack-body {
    font-size: 15px;
    line-height: 1.6;
    color: #d1d2d3;
    margin-bottom: 10px;
}

.slack-reactions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.slack-reaction {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
    padding: 3px 10px;
    font-size: 13px;
    color: #ccc;
}

.slack-pick-btn {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    background: var(--gold);
    color: var(--black);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}
.slack-pick-btn:hover { background: var(--gold2); }

.redraw-bar { margin: -4px 0 8px; }

.watching-header {
    text-align: center;
    padding: 24px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.watching-header h2 { font-size: 20px; font-weight: 800; }

/* ===========================================
   REVEAL PHASE
   =========================================== */
.reveal-wrap { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px 0; }
.winner-handle { font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 0.05em; }
.winning-tweet { max-width: 400px; width: 100%; }

.scoring-breakdown {
  max-width: 360px; width: 100%;
  background: var(--black2); border: 1px solid #222; border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.score-row { display: flex; justify-content: space-between; font-size: 14px; color: #ccc; }
.score-row.total { font-size: 16px; font-weight: 800; border-top: 1px solid #333; padding-top: 8px; margin-top: 4px; color: var(--white); }
.score-positive { color: var(--green); font-weight: 700; }
.score-negative { color: var(--red); font-weight: 700; }

/* ===========================================
   SHOP PHASE
   =========================================== */
.shop-wrap { display: grid; grid-template-columns: 1fr 1.6fr; gap: 24px; }
@media (max-width: 680px) { .shop-wrap { grid-template-columns: 1fr; } }

.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid #1a1a1a;
  font-size: 14px;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.me { color: var(--gold); }
.lb-rank { font-weight: 900; color: var(--dim); width: 28px; }
.lb-name { flex: 1; font-weight: 600; }
.lb-followers { font-weight: 700; font-size: 13px; }

.goal-block { margin-top: 16px; display: flex; align-items: center; gap: 8px; }

.shop-upgrades { display: flex; flex-direction: column; gap: 10px; }

.upgrade-card {
  background: var(--black3); border: 1px solid #2a2a2a;
  border-radius: var(--radius); padding: 14px;
  cursor: pointer; transition: all 0.15s;
  display: grid; grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto auto;
  gap: 2px 10px; align-items: start;
}
.upgrade-card:not(.owned):not(.locked):not(.too-expensive):hover {
  border-color: var(--gold); background: #110f00;
}
.upgrade-card.owned    { border-color: #2a4a2a; opacity: 0.7; cursor: default; }
.upgrade-card.locked   { opacity: 0.4; cursor: not-allowed; }
.upgrade-card.too-expensive { opacity: 0.5; cursor: not-allowed; }

.upgrade-icon { font-size: 24px; grid-row: 1 / 3; align-self: center; }
.upgrade-name { font-size: 14px; font-weight: 800; color: var(--white); }
.upgrade-desc { font-size: 12px; color: var(--dim); line-height: 1.4; }
.upgrade-cost { grid-column: 2; font-size: 12px; font-weight: 700; color: var(--gold); margin-top: 4px; }

.shop-footer { margin-top: 20px; text-align: center; }

/* ===========================================
   END SCREEN
   =========================================== */
.end-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; padding: 40px 20px; text-align: center;
}
.end-emoji  { font-size: 72px; margin-bottom: 8px; }
.end-title  { font-size: 42px; font-weight: 900; letter-spacing: 0.08em; }
.end-subtitle { font-size: 18px; color: var(--dim); margin-top: 8px; }

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 480px) {
  .white-card-grid { grid-template-columns: repeat(2, 1fr); }
  .slack-grid { max-width: 100%; }
  .black-card-text { font-size: 18px; }
  .game-header { padding: 10px 12px; }
  .game-phase { padding: 16px 12px; }
}
