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

:root {
  --bg-deep:    #0b0015;
  --bg-mid:     #1a0a2e;
  --bg-card:    rgba(35, 10, 60, 0.85);
  --accent:     #c455f5;
  --accent-2:   #ff6eb4;
  --accent-yes: #ff4d8d;
  --accent-no:  #7a4fa3;
  --text:       #f0d6ff;
  --text-dim:   #c0a0dd;
  --glow:       rgba(196, 85, 245, 0.4);
  --glow-yes:   rgba(255, 77, 141, 0.5);
  --shadow-card: 0 8px 40px rgba(0,0,0,0.6), 0 0 60px rgba(196,85,245,0.15);
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: radial-gradient(ellipse at 50% 30%, var(--bg-mid) 0%, var(--bg-deep) 70%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text);
  position: relative;
  padding: 1rem;
}

#starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--dur, 3s) ease-in-out infinite var(--delay, 0s);
  opacity: 0;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50%       { opacity: var(--max-op, 0.8); transform: scale(1); }
}

.floaty-heart {
  position: fixed;
  pointer-events: none;
  font-size: var(--sz, 1.2rem);
  animation: floatUp var(--dur, 6s) ease-in var(--delay, 0s) infinite;
  opacity: 0;
  z-index: 0;
}

@keyframes floatUp {
  0%   { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

#card {
  position: relative;
  z-index: 10;
  background: var(--bg-card);
  border: 1px solid rgba(196, 85, 245, 0.25);
  border-radius: 2rem;
  padding: 2rem 1.5rem 2.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  transition: transform 0.3s ease;
}

#img-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 1.4rem;
}

#img-wrap::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(var(--accent), var(--accent-2), var(--accent), var(--accent-2), var(--accent));
  animation: spin 4s linear infinite;
  z-index: -1;
}

@keyframes spin { to { transform: rotate(360deg); } }

#valentine-img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  border: 4px solid var(--bg-deep);
  /* Replace src with your own image! */
}

/* SVG heart fallback shown when no image is set */
#heart-fallback {
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  animation: heartbeat 1.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14%       { transform: scale(1.15); }
  28%       { transform: scale(1); }
  42%       { transform: scale(1.1); }
  56%       { transform: scale(1); }
}

#question {
  font-size: clamp(1.3rem, 5vw, 1.7rem);
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.4rem;
  text-shadow: 0 0 20px var(--glow);
  transition: all 0.5s ease;
}

#sub-text {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1.8rem;
  min-height: 1.4em;
  transition: all 0.4s ease;
  font-style: italic;
}

#btn-wrap {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  border-radius: 2rem;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.3s ease;
  outline: none;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.03em;
}

.btn:active { transform: scale(0.95) !important; }

#btn-yes {
  background: linear-gradient(135deg, #ff4d8d, #ff79a8);
  color: white;
  box-shadow: 0 4px 20px var(--glow-yes);
  font-size: 1.25rem;
  padding: 0.85rem 2.2rem;
  z-index: 2;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), font-size 0.4s ease, box-shadow 0.2s ease;
}

#btn-yes:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px var(--glow-yes);
}

#btn-no {
  background: linear-gradient(135deg, #3d1f6b, #5a2fa0);
  color: var(--text-dim);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  font-size: 0.95rem;
  z-index: 2;
  transition: transform 0.2s ease, font-size 0.4s ease, opacity 0.3s ease;
}

#btn-no:hover { transform: scale(1.05); }

#celebration {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: popIn 0.6s cubic-bezier(.34,1.56,.64,1) forwards;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

#celebration .big-emoji {
  font-size: 5rem;
  animation: heartbeat 1s ease-in-out infinite;
  filter: drop-shadow(0 0 20px #ff6eb4);
}

#celebration p {
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  color: #ffb3d9;
  text-shadow: 0 0 20px #ff6eb4;
}

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

#no-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transform: scale(0);
  animation: rippleAnim 0.5s linear;
  pointer-events: none;
}

@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

#no-count-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff4d8d;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  z-index: 3;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  15%      { transform: translateX(-8px) rotate(-1deg); }
  30%      { transform: translateX(8px)  rotate(1deg); }
  45%      { transform: translateX(-6px); }
  60%      { transform: translateX(6px); }
  75%      { transform: translateX(-3px); }
}

.do-shake { animation: shake 0.5s ease; }

@keyframes cardGlow {
  0%,100% { box-shadow: var(--shadow-card); }
  50%      { box-shadow: var(--shadow-card), 0 0 60px rgba(255,77,141,0.3); }
}

@media (max-width: 360px) {
  #card { padding: 1.5rem 1rem 2rem; border-radius: 1.5rem; }
  #valentine-img, #heart-fallback { width: 140px; height: 140px; }
  #heart-fallback { font-size: 4.5rem; }
}

/* Cambio from here */

#cambio-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 0, 14, 0.97);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 0.5rem;
  animation: fadeInCambio 0.3s ease;
}

@keyframes fadeInCambio {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

#cambio-game {
  background: linear-gradient(160deg, #1e0840 0%, #0d0022 100%);
  border: 1px solid rgba(196, 85, 245, 0.3);
  border-radius: 1.5rem;
  padding: 0.9rem 0.8rem;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: 0 0 80px rgba(196,85,245,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
  max-height: 100vh;
  overflow: auto;
  padding: 25px;
}

.cambio-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cambio-hdr-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cambio-x {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.cambio-x:hover { background: rgba(255,77,141,0.2); color: #ff6eb4; }

.cambio-msg {
  background: rgba(196,85,245,0.07);
  border: 1px solid rgba(196,85,245,0.16);
  border-radius: 0.75rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  min-height: 2.2rem;
  line-height: 1.4;
  transition: all 0.3s ease;
}

/* Player areas */
.cambio-side { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }

.cambio-avatar-row { display: flex; align-items: center; gap: 0.45rem; }

.cambio-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.cambio-name { font-size: 0.78rem; color: var(--text-dim); font-style: italic; }

.cambio-score-badge {
  font-size: 0.68rem;
  background: rgba(196,85,245,0.18);
  border-radius: 1rem;
  padding: 1px 6px;
  color: var(--accent);
}

.card-row { display: flex; gap: 5px; justify-content: center; }

/* Playing cards */
.ccard {
  width: 52px; height: 74px;
  perspective: 600px;
  flex-shrink: 0;
  cursor: default;
  position: relative;
}

.ccard-inner {
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.38s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.ccard-inner.flipped { transform: rotateY(180deg); }

.ccard-face {
  position: absolute; inset: 0;
  border-radius: 6px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.ccard-back {
  background: repeating-linear-gradient(45deg, #2d0a50, #2d0a50 4px, #3d1565 4px, #3d1565 8px);
  border: 1.5px solid rgba(196,85,245,0.45);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  color: rgba(196,85,245,0.3);
}

.ccard-front {
  background: #fffef8;
  transform: rotateY(180deg);
  border: 1.5px solid #ccc;
  border-radius: 6px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 3px;
}
.ccard-front.red   { color: #cc1111; }
.ccard-front.black { color: #111; }

.ccard-corner {
  font-size: 0.57rem; font-weight: bold;
  line-height: 1.1; text-align: center;
}
.ccard-corner.br { transform: rotate(180deg); align-self: end; justify-self: end; }
.ccard-suit-center { font-size: 1.25rem; text-align: center; align-self: center; }

/* Selectable glow */
.ccard.selectable { cursor: pointer; }
.ccard.selectable .ccard-back {
  border-color: #ff6eb4;
  box-shadow: 0 0 10px rgba(255,110,180,0.55), inset 0 0 6px rgba(255,110,180,0.1);
  animation: pulseSelCard 1.1s ease-in-out infinite;
}
.ccard.selectable .ccard-front {
  outline: 2px solid #ff6eb4;
  outline-offset: 1px;
}

@keyframes pulseSelCard {
  0%,100% { box-shadow: 0 0 6px rgba(255,110,180,0.4); }
  50%      { box-shadow: 0 0 16px rgba(255,110,180,0.9); }
}

/* Table center */
.cambio-table {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1rem;
  padding: 0.1rem 0;
}

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

.pile-label { font-size: 0.58rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.07em; }
.deck-count  { font-size: 0.58rem; color: var(--text-dim); }

.ccard.deck-card .ccard-back { cursor: pointer; }
.ccard.deck-card:hover .ccard-back {
  border-color: #c455f5;
  box-shadow: 0 0 12px rgba(196,85,245,0.5);
}

/* Actions area */
.cambio-actions {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.45rem;
  min-height: 72px;
}

.cbtn {
  border: none; border-radius: 2rem;
  padding: 0.52rem 1.3rem;
  font-size: 0.86rem; font-weight: bold;
  cursor: pointer; font-family: inherit;
  width: 100%; max-width: 260px;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
  letter-spacing: 0.02em;
}
.cbtn:hover:not(:disabled) { transform: scale(1.04); }
.cbtn:active:not(:disabled) { transform: scale(0.97); }
.cbtn:disabled { opacity: 0.4; cursor: not-allowed; }

.cbtn-primary   { background: linear-gradient(135deg,#ff4d8d,#ff79a8); color:#fff; box-shadow:0 3px 14px var(--glow-yes); }
.cbtn-secondary { background: linear-gradient(135deg,#3d1f6b,#5a2fa0); color:var(--text); box-shadow:0 2px 8px rgba(0,0,0,0.3); }
.cbtn-danger    { background: linear-gradient(135deg,#2d0a50,#4a1870); color:var(--text-dim); border:1px solid rgba(196,85,245,0.25); }

/* Result */
.cambio-result { width:100%; text-align:center; display:flex; flex-direction:column; align-items:center; gap:0.55rem; }

.result-scores { display:flex; justify-content:center; gap:2.5rem; }
.rscore { display:flex; flex-direction:column; align-items:center; gap:0.15rem; }
.rscore .rname { font-size:0.72rem; color:var(--text-dim); }
.rscore .rnum  { font-size:2rem; font-weight:bold; color:var(--text); }
.rscore.winner .rnum { color:#ff6eb4; }

.result-msg { font-size:0.92rem; color:var(--text); line-height:1.5; }

.intro-text {
  text-align:center; color:var(--text-dim);
  font-size:0.8rem; line-height:1.65; padding:0 0.4rem;
}
.intro-text strong { color:var(--text); }
.intro-text em     { color:var(--accent-2); font-style:normal; }

/* Action log */
#cambio-log {
  border-top: 1px solid rgba(196,85,245,0.12);
  padding-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.log-hdr {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(196,85,245,0.45);
  padding: 0 0.2rem;
}

#log-body {
  max-height: 100px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(196,85,245,0.25) transparent;
}

#log-body::-webkit-scrollbar { width: 3px; }
#log-body::-webkit-scrollbar-thumb { background: rgba(196,85,245,0.3); border-radius: 2px; }

.log-entry {
  font-size: 0.68rem;
  color: var(--text-dim);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1.35;
}

.log-entry:first-child {
  color: var(--text);
  background: rgba(196,85,245,0.07);
}

.log-entry.log-snap  { color: #ffb3d9; }
.log-entry.log-event { color: #c9a0ff; }
.log-entry.log-penalty { color: #ff8c8c; }

@media (max-width: 360px) {
  .ccard { width:44px; height:63px; }
  .ccard-suit-center { font-size:1rem; }
  .ccard-corner { font-size:0.5rem; }
  .card-row { gap:3px; }
}
