/* ==========================================
   ccgiggle — Main Stylesheet
   ========================================== */

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
body { background: #F5F4F0; padding: 20px; transition: background 0.3s; max-width: 600px; margin: 0 auto; }

/* ── Screens ── */
.screen { display: none; opacity: 0; transition: opacity 0.3s ease; }
.screen.active { display: block; opacity: 1; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Layout ── */
.card { background: #fff; border: 1px solid #E5E3DC; border-radius: 16px; padding: 20px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
h1 { font-size: 22px; font-weight: 700; color: #1A1A1A; margin-bottom: 2px; }
.label { font-size: 12px; color: #888; font-weight: 600; margin-bottom: 10px; display: block; text-transform: uppercase; letter-spacing: 0.5px; }
.sep { border: none; border-top: 1px solid #E5E3DC; margin: 16px 0; }
.stat { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed #E5E3DC; font-size: 14px; color: #555; }
.stat:last-child { border-bottom: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 500px) { .grid3 { grid-template-columns: 1fr; } }

/* ── Language Toggle ── */
.lang-toggle { background: #EEEDFE; border: 1px solid #C5C2F5; color: #534AB7; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 20px; cursor: pointer; transition: all 0.2s; }
.lang-toggle:hover { background: #E0DEFD; }

/* ── Chips ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 16px; border-radius: 20px; border: 1.5px solid #D0CEC7; background: #fff; color: #555; font-size: 13px; cursor: pointer; user-select: none; transition: all 0.15s; }
.chip:hover { border-color: #1D9E75; color: #1D9E75; }
.chip.active { border-color: #1D9E75; background: #E6F7F1; color: #0F6E56; font-weight: 600; }
.chip-desc { font-size: 13px; color: #666; margin-top: 10px; padding: 10px; background: #F9F8F5; border-radius: 8px; min-height: 20px; }

/* ── Pick Buttons ── */
.pick-btn { padding: 14px 10px; border-radius: 12px; border: 1.5px solid #D0CEC7; background: #fff; color: #333; font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; width: 100%; transition: all 0.15s; }
.pick-btn:hover { border-color: #1D9E75; }
.pick-btn.active { border-color: #1D9E75 !important; background: #E6F7F1 !important; color: #0F6E56 !important; box-shadow: 0 4px 12px rgba(29,158,117,0.1); }

/* ── Grade Buttons ── */
.grade-btn { padding: 12px 8px; border-radius: 12px; border: 1.5px solid #D0CEC7; background: #fff; color: #333; font-size: 14px; font-weight: 600; cursor: pointer; text-align: center; width: 100%; transition: all 0.15s; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.grade-btn:hover { border-color: #7C5CBF; }
.grade-btn.active { border-color: #7C5CBF !important; background: #F0EDFB !important; color: #4A2FA0 !important; font-weight: 700 !important; }
.grade-age { font-size: 11px; color: #888; font-weight: 500; }
.grade-btn.active .grade-age { color: #6950B3; }

/* ── Action Buttons ── */
.q-btn { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid #D0CEC7; background: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #555; }
.q-num { font-size: 20px; font-weight: 700; color: #1A1A1A; min-width: 30px; text-align: center; }
.action-btn { width: 100%; padding: 16px; background: #1D9E75; color: #fff; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; margin-bottom: 10px; transition: transform 0.1s, background 0.2s; box-shadow: 0 4px 12px rgba(29,158,117,0.2); }
.action-btn:active { transform: scale(0.98); }
.action-btn:hover { background: #0F6E56; }
.action-btn.sec { background: #F0EEE8; color: #333; box-shadow: none; }
.action-btn.sec:hover { background: #E5E3DC; }
.action-btn.share { background: #534AB7; box-shadow: 0 4px 12px rgba(83,74,183,0.2); }
.action-btn.share:hover { background: #3C3489; }

/* ── Error Box ── */
.err { background: #FEF0EF; border: 1px solid #F5B8B7; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #C0392B; margin-bottom: 12px; line-height: 1.5; display: none; }

/* ── API Key Input ── */
.key-input { width: 100%; padding: 12px 14px; border: 1.5px solid #D0CEC7; border-radius: 10px; font-size: 13px; color: #1A1A1A; background: #F9F8F5; font-family: monospace; outline: none; }
.key-input:focus { border-color: #1D9E75; }

/* ── Gameplay ── */
.bubble { display: flex; gap: 12px; background: #EEEDFE; border-radius: 14px; padding: 14px; margin-bottom: 14px; border: 1px solid #C5C2F5; }
.av { width: 42px; height: 42px; border-radius: 50%; background: #534AB7; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; }
.av-name { font-size: 12px; color: #7F77DD; font-weight: 700; margin-bottom: 4px; text-transform: uppercase; }
.av-text { font-size: 14px; color: #3C3489; line-height: 1.5; font-weight: 500; }
.pbar { height: 8px; background: #E5E3DC; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.pfill { height: 100%; background: #1D9E75; border-radius: 4px; transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); }

/* ── Question & Answer ── */
.q-text { font-size: 18px; font-weight: 700; color: #1A1A1A; line-height: 1.6; margin-bottom: 24px; }
.q-blank { display: inline-block; min-width: 60px; border-bottom: 3px solid #1A1A1A; text-align: center; color: transparent; padding: 0 10px; margin: 0 4px; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); vertical-align: baseline; position: relative; top: -2px; }
.q-blank.filled { border-bottom: none; border-radius: 8px; color: #fff; font-weight: 700; padding: 4px 14px; top: 0; }
.q-blank.filled.right { background: #1D9E75; box-shadow: 0 4px 10px rgba(29,158,117,0.3); transform: scale(1.05); }
.q-blank.filled.wrong { background: #E24B4A; box-shadow: 0 4px 10px rgba(226,75,74,0.3); }
.ans-btn { padding: 16px 12px; border-radius: 12px; border: 2px solid #D0CEC7; background: #fff; color: #333; font-size: 15px; font-weight: 600; cursor: pointer; text-align: center; width: 100%; line-height: 1.4; transition: all 0.2s; }
.ans-btn:hover:not(:disabled) { border-color: #1D9E75; background: #F9F8F5; transform: translateY(-2px); }
.ans-btn:disabled { cursor: default; opacity: 0.6; transform: none; }
.ans-btn.right { border-color: #1D9E75 !important; background: #E6F7F1 !important; color: #0F6E56 !important; opacity: 1 !important; }
.ans-btn.wrong { border-color: #E24B4A !important; background: #FEF0EF !important; color: #C0392B !important; opacity: 1 !important; }
.ans-btn.reveal { border-color: #1D9E75 !important; background: #E6F7F1 !important; color: #0F6E56 !important; opacity: 1 !important; border-style: dashed; }
.fb { border-radius: 10px; padding: 14px; margin-top: 16px; font-size: 14px; line-height: 1.6; border-left: 4px solid #1D9E75; background: #F5F4F0; color: #333; display: none; font-weight: 500; }
.fb.bad { border-left-color: #E24B4A; }

/* ── Badges & Tags ── */
.star-row { display: flex; gap: 4px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px; }
.bt { background: #E6F7F1; color: #0F6E56; }
.bb { background: #E6F1FB; color: #185FA5; }
.bp { background: #FFF3DC; color: #8A5A00; }
.subtopic-tag { display: inline-block; font-size: 12px; background: #FFF3DC; color: #8A5A00; border: 1px solid #F5D88A; border-radius: 20px; padding: 4px 12px; font-weight: 600; margin-left: 8px; }

/* ── Seed & Leaderboard ── */
.seed-box { background: #F0EDFB; border: 1px solid #C5C2F5; border-radius: 12px; padding: 14px; margin-bottom: 14px; text-align: center; }
.seed-id { font-size: 11px; color: #7F77DD; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.seed-val { font-size: 15px; color: #3C3489; font-family: monospace; font-weight: 700; }
.lb-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px dashed #E5E3DC; font-size: 14px; }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 30px; height: 30px; border-radius: 50%; background: #F5F4F0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #888; flex-shrink: 0; }
.lb-rank.gold { background: #FFF3DC; color: #8A5A00; font-size: 16px; }
.lb-rank.silver { background: #F0F0F0; color: #666; font-size: 16px; }
.lb-rank.bronze { background: #FFF0EA; color: #8A4A00; font-size: 16px; }
.lb-name { flex: 1; margin: 0 12px; color: #1A1A1A; font-weight: 600; }
.lb-score { color: #1D9E75; font-weight: 800; }

/* ── Toast ── */
.copy-toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #1A1A1A; color: #fff; padding: 12px 24px; border-radius: 30px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; z-index: 999; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(-10px); }

/* ── Shared Banner ── */
.shared-banner { background: linear-gradient(135deg, #534AB7, #1D9E75); border-radius: 14px; padding: 16px; margin-bottom: 16px; color: #fff; text-align: center; box-shadow: 0 4px 12px rgba(83,74,183,0.3); }
.shared-banner h2 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.shared-banner p { font-size: 13px; opacity: 0.9; font-weight: 500; }

/* ── Loading ── */
.dots { display: flex; gap: 8px; justify-content: center; padding: 2rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #1D9E75; animation: bop 1.2s infinite; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bop { 0%,80%,100%{transform:scale(0.7);opacity:0.5}40%{transform:scale(1);opacity:1} }

/* ── Name Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: #fff; border-radius: 20px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-title { font-size: 20px; font-weight: 800; color: #1A1A1A; margin-bottom: 6px; }
.modal-sub { font-size: 14px; color: #888; margin-bottom: 20px; line-height: 1.5; }
.name-input { width: 100%; padding: 14px 16px; border: 2px solid #E5E3DC; border-radius: 12px; font-size: 16px; color: #1A1A1A; outline: none; transition: border-color 0.2s; font-family: system-ui; }
.name-input:focus { border-color: #1D9E75; }

/* ── API Provider Buttons ── */
.provider-btn {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1.5px solid #D0CEC7; background: #fff;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: all 0.15s; text-align: left;
}
.provider-btn:hover { border-color: #1D9E75; }
.provider-btn.active { border-color: #1D9E75 !important; background: #E6F7F1 !important; }
.provider-label { font-size: 13px; font-weight: 600; color: #1A1A1A; }
.provider-btn.active .provider-label { color: #0F6E56; }
.provider-vendor {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.vendor-google { background: #E8F0FE; color: #1967D2; }
.vendor-anthropic { background: #FFF0E6; color: #C45C00; }

/* ── Provider Select Dropdown ── */
.provider-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #D0CEC7;
  border-radius: 12px;
  background: #fff;
  color: #1A1A1A;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  transition: border-color 0.2s;
}
.provider-select:focus,
.provider-select:hover { border-color: #1D9E75; }

.provider-select optgroup {
  font-size: 12px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.provider-select option {
  font-size: 14px;
  font-weight: 500;
  color: #1A1A1A;
  padding: 8px;
}

/* ── Pre-selected Answer (before confirm) ── */
.ans-btn.pre-selected {
  border-color: #534AB7 !important;
  background: #F0EDFB !important;
  color: #4A2FA0 !important;
  font-weight: 700;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(83,74,183,0.2);
}

/* ── Confirm Button ── */
.confirm-btn {
  background: #534AB7 !important;
  box-shadow: 0 4px 12px rgba(83,74,183,0.25) !important;
  margin-bottom: 10px;
}
.confirm-btn:hover { background: #3C3489 !important; }

/* ==========================================
   Card Drag Interaction System
   ========================================== */

/* ── Question card ── */
.q-card { transition: box-shadow 0.3s; }

/* ── Drop zone ── */
.drop-zone {
  min-height: 72px;
  border: 2.5px dashed #D0CEC7;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.drop-zone.drag-over {
  border-color: #1D9E75;
  background: #E6F7F1;
  transform: scale(1.02);
  box-shadow: 0 0 0 4px rgba(29,158,117,0.15);
}
.drop-zone.has-card {
  border-style: solid;
  border-color: #534AB7;
  background: #F0EDFB;
  min-height: 72px;
}
.drop-zone.result-right {
  border-color: #1D9E75 !important;
  background: #E6F7F1 !important;
}
.drop-zone.result-wrong {
  border-color: #E24B4A !important;
  background: #FEF0EF !important;
}
.drop-zone-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #C0BDB5;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  transition: opacity 0.2s;
}
.drop-zone-hint span:first-child { font-size: 24px; }
.drop-zone.has-card .drop-zone-hint { display: none; }

/* ── Card in drop zone ── */
.dropped-card-label {
  font-size: 15px;
  font-weight: 700;
  color: #4A2FA0;
  text-align: center;
  padding: 12px 16px;
  width: 100%;
  pointer-events: none;
}

/* ── Answer cards tray ── */
.cards-tray {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 16px 0 4px;
  flex-wrap: wrap;
}

/* ── Answer card ── */
.answer-card {
  background: #fff;
  border: 2px solid #E5E3DC;
  border-radius: 16px;
  padding: 16px 20px;
  min-width: 130px;
  max-width: 200px;
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #1A1A1A;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s,
              opacity 0.2s,
              border-color 0.2s;
  position: relative;
  line-height: 1.4;
}
.answer-card::before {
  content: attr(data-index);
  position: absolute;
  top: -8px; left: -8px;
  width: 22px; height: 22px;
  background: #534AB7;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(83,74,183,0.4);
}
.answer-card:hover:not(.is-placed):not(.is-locked) {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow: 0 10px 24px rgba(0,0,0,0.14);
  border-color: #534AB7;
}
.answer-card:active:not(.is-placed):not(.is-locked) {
  cursor: grabbing;
}
.answer-card.is-placed {
  opacity: 0.35;
  transform: scale(0.95);
  cursor: default;
  border-color: #C5C2F5;
  box-shadow: none;
}
.answer-card.is-locked {
  cursor: default;
}
.answer-card.result-right {
  border-color: #1D9E75 !important;
  background: #E6F7F1 !important;
  color: #0F6E56 !important;
  opacity: 1 !important;
  transform: none !important;
}
.answer-card.result-wrong {
  border-color: #E24B4A !important;
  background: #FEF0EF !important;
  color: #C0392B !important;
  opacity: 1 !important;
  transform: none !important;
}
.answer-card.result-reveal {
  border-color: #1D9E75 !important;
  background: #E6F7F1 !important;
  color: #0F6E56 !important;
  opacity: 1 !important;
  border-style: dashed !important;
  transform: none !important;
}

/* ── Dragging ghost (follows finger/cursor) ── */
.dragging-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: #fff;
  border: 2.5px solid #534AB7;
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #4A2FA0;
  box-shadow: 0 16px 40px rgba(83,74,183,0.35);
  transform: rotate(4deg) scale(1.06);
  transition: none;
  max-width: 220px;
  text-align: center;
  line-height: 1.4;
}

/* ── Confirm button (card mode) ── */
.confirm-btn {
  margin-top: 14px;
  background: #534AB7 !important;
  box-shadow: 0 4px 14px rgba(83,74,183,0.3) !important;
  animation: pulse-confirm 1.5s infinite;
}
.confirm-btn:hover { background: #3C3489 !important; animation: none; }
@keyframes pulse-confirm {
  0%,100% { box-shadow: 0 4px 14px rgba(83,74,183,0.3); }
  50% { box-shadow: 0 4px 24px rgba(83,74,183,0.55); }
}
