:root {
  --bg: #050505;
  --panel: #0f0f12;
  --panel-2: #111119;
  --text: #f7f7fb;
  --muted: #9ca0b5;
  --accent: #7c5dff;
  --accent-2: #66e7ff;
  --card-black: #0d0d0f;
  --card-white: #f9f9fb;
  --shadow: 0 16px 40px rgba(0,0,0,0.45);
  --radius: 16px;
  --glow: 0 0 0 2px rgba(124,93,255,0.25), 0 16px 40px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 25% 20%, rgba(124,93,255,0.08), transparent 35%),
              radial-gradient(circle at 80% 10%, rgba(102,231,255,0.08), transparent 30%),
              #050505;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
}
input, textarea, button, select { user-select: text; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #181820;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.brand {
  font-weight: 800;
  text-transform: lowercase;
  letter-spacing: 0.5px;
  font-size: 1.2rem;
}
.brand span { color: #bfbff5; }
.brand-wobble {
  animation: brandAlarm 0.9s ease;
}

main {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  background: linear-gradient(135deg, #0c0c12, #08080c);
  border: 1px solid #151520;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.hero-text h1 { margin: 6px 0 12px; font-size: 2.2rem; line-height: 1.1; }
.hero-text .eyebrow { letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-size: 0.85rem; }
.hero-text .sub { color: var(--muted); max-width: 540px; }
.controls { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.controls input {
  background: #12121a;
  color: var(--text);
  border: 1px solid #222235;
  border-radius: 12px;
  padding: 12px 14px;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
button {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #050505;
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.15s ease;
  box-shadow: 0 12px 26px rgba(124,93,255,0.25);
  user-select: none;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(1px); opacity: 0.9; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid #232334;
  box-shadow: none;
}
.fine-print { color: var(--muted); font-size: 0.9rem; }

.hero-card {
  background: var(--panel);
  border: 1px solid #1a1a28;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}
.card-preview {
  display: grid;
  gap: 10px;
}
.preview-black, .preview-white {
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.preview-black { background: var(--card-black); color: #fff; }
.preview-white { background: var(--card-white); color: #0b0b0b; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mini-note { color: var(--muted); font-size: 0.95rem; }

.table.hidden { display: none; }
.table {
  background: var(--panel-2);
  border: 1px solid #191926;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.table-meta { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.meta-block { display: flex; flex-direction: column; gap: 4px; }
.round-block { min-width: 120px; }
.round-value {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.6px;
}
.label { color: var(--muted); font-size: 0.95rem; letter-spacing: 0.3px; }
.seed-display {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.card {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.big-card {
  background: var(--card-black);
  color: #fff;
  border: 1px solid #1d1d2a;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 36px;
  cursor: pointer;
  animation: floaty 6s ease-in-out infinite;
  position: relative;
}
.big-card .text {
  font-size: 1.4rem;
  line-height: 1.45;
  font-weight: 800;
}
.big-card .hint { color: var(--muted); font-size: 0.9rem; }
.big-card:active { transform: translateY(2px); }

.hand {
  background: var(--panel);
  border: 1px solid #1c1c2a;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}
.hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.white-card {
  background: var(--card-white);
  color: #0b0b0b;
  border-radius: 12px;
  padding: 12px;
  padding-bottom: 38px;
  min-height: 120px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.2);
  display: flex;
  align-items: flex-start;
  font-weight: 700;
  line-height: 1.3;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  cursor: pointer;
  opacity: 0;
  animation: deal 0.4s ease forwards;
}
.card-brand {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-weight: 800;
  letter-spacing: 0.4px;
  font-size: 0.78rem;
  pointer-events: none;
}
.card-brand .brand-icon {
  width: 16px;
  height: 16px;
  background: url("icon.ico") center/contain no-repeat;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}
.big-card .card-brand { color: #fff; opacity: 0.9; }
.white-card .card-brand { color: #0b0b0b; opacity: 0.78; }
.white-card:nth-child(1) { animation-delay: 0.02s; }
.white-card:nth-child(2) { animation-delay: 0.04s; }
.white-card:nth-child(3) { animation-delay: 0.06s; }
.white-card:nth-child(4) { animation-delay: 0.08s; }
.white-card:nth-child(5) { animation-delay: 0.10s; }
.white-card:nth-child(6) { animation-delay: 0.12s; }
.white-card:nth-child(7) { animation-delay: 0.14s; }
.white-card:nth-child(8) { animation-delay: 0.16s; }
.white-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 12px;
  pointer-events: none;
}
.white-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 14px 30px rgba(0,0,0,0.28);
}
.white-card.selected {
  transform: translateY(-6px) scale(1.02) rotate(-1deg);
  box-shadow: var(--glow);
  filter: saturate(1.1);
  animation: pulseGlow 1.6s ease-in-out infinite;
}

.play-area {
  background: rgba(255,255,255,0.03);
  border: 1px dashed #2b2b3a;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.play-label { color: var(--muted); font-size: 0.9rem; }
.play-slot {
  min-height: 100px;
  min-width: 220px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid #232336;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.play-slot .selected-visual {
  background: var(--card-white);
  color: #0b0b0b;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.32);
  font-weight: 700;
  line-height: 1.3;
  animation: popIn 0.2s ease, floatySmall 5s ease-in-out infinite;
}
.placeholder { color: var(--muted); font-size: 0.95rem; }

.howto {
  background: rgba(14,14,20,0.9);
  border: 1px solid #1f1f2d;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.howto h2 { margin-top: 0; }
.howto ol { padding-left: 1.2rem; }
.howto li { margin-bottom: 8px; }
.note { color: var(--muted); font-size: 0.95rem; }

.toast {
  position: fixed;
  bottom: 18px; /* tuck into footer band */
  right: 22px;
  transform: translateY(6px);
  background: rgba(10,10,18,0.92);
  border: 1px solid #2a2a40;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.02);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
  z-index: 10;
  max-width: min(420px, calc(100vw - 44px));
}
.toast.warn {
  background: rgba(255, 132, 0, 0.14);
  border-color: rgba(255, 184, 108, 0.85);
  color: #ffd9aa;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
  filter: drop-shadow(0 6px 24px rgba(0,0,0,0.35));
}

footer {
  padding: 16px 22px;
  border-top: 1px solid #14141c;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
footer span { text-align: center; }

/* Animations */
@keyframes floaty {
  0% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}
@keyframes floatySmall {
  0% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}
@keyframes pulseGlow {
  0% { box-shadow: var(--glow); }
  50% { box-shadow: 0 0 0 2px rgba(124,93,255,0.35), 0 18px 36px rgba(0,0,0,0.5); }
  100% { box-shadow: var(--glow); }
}
@keyframes popIn {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes deal {
  0% { opacity: 0; transform: translateY(8px) rotate(-1deg) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
}

@keyframes brandAlarm {
  0% { transform: translateY(0) scale(1); }
  15% { transform: translateX(-4px) rotate(-1deg); }
  30% { transform: translateX(4px) rotate(2deg); }
  45% { transform: translateX(-3px) rotate(-1deg); }
  60% { transform: translateX(3px) rotate(1deg); }
  85% { transform: translateX(0) rotate(0); }
  100% { transform: translateY(0) scale(1); }
}

/* Mobile tweaks */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; }
  .cards-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .table-header { align-items: flex-start; }
}

.showcase {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  z-index: 30;
}
.showcase.visible { display: flex; }
.showcase-card {
  max-width: 90vw;
  width: min(480px, 90vw);
  min-height: 140px;
  border-radius: 16px;
  padding: 18px;
  padding-bottom: 48px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 800;
  text-align: left;
  position: relative;
}
.black-show {
  background: #0d0d0f;
  color: #fff;
  border: 1px solid #2a2a35;
}
.white-show {
  background: #f9f9fb;
  color: #0b0b0b;
  border: 1px solid #dcdce5;
}
.black-show .card-brand { color: #fff; opacity: 0.9; }
.white-show .card-brand { color: #0b0b0b; opacity: 0.78; }
.show-text { word-break: break-word; }
.show-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.show-actions .ghost { min-width: 120px; }
.slim-btn {
  padding: 10px 12px;
  font-weight: 700;
}

/* End-of-deck overlay */
.end-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at 20% 30%, rgba(124,93,255,0.14), transparent 40%),
              radial-gradient(circle at 80% 20%, rgba(102,231,255,0.14), transparent 45%),
              rgba(0,0,0,0.88);
  backdrop-filter: blur(4px);
  z-index: 60;
}
.end-overlay.visible { display: flex; }
.end-overlay .end-glow {
  position: absolute;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 30% 30%, rgba(124,93,255,0.35), transparent 45%),
              radial-gradient(circle at 70% 60%, rgba(102,231,255,0.35), transparent 50%);
  filter: blur(70px);
  opacity: 0.6;
  animation: swirl 16s ease-in-out infinite;
}
.end-card {
  position: relative;
  background: #0f0f18;
  border: 1px solid #2a2a38;
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.02);
  max-width: 520px;
  width: min(520px, 92vw);
  text-align: center;
  animation: popIn 0.35s ease, floaty 9s ease-in-out infinite;
  z-index: 2;
}
.end-card h2 { margin: 8px 0 10px; font-size: 1.8rem; }
.end-card .sub { color: var(--muted); }
.end-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.end-overlay.hidden { display: none; }

@keyframes swirl {
  0% { transform: translate(-4%, -2%) rotate(0deg) scale(1); }
  50% { transform: translate(4%, 3%) rotate(6deg) scale(1.05); }
  100% { transform: translate(-4%, -2%) rotate(0deg) scale(1); }
}
