/* Supermallows — Marshmallow Candy Theme */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
  --bg-from: #ffe4f0;
  --bg-to: #e8d5f5;
  --card-w: 72px;
  --card-h: 100px;
  --card-radius: 10px;
  --card-back: #f9a8d4;
  --card-back-pattern: #f472b6;
  --shadow: 0 4px 16px rgba(0,0,0,0.12);
  --felt: #4a7c59;
  --btn-primary: #ec4899;
  --btn-primary-hover: #db2777;
  --text: #3b2a4a;
  --font: 'Nunito', sans-serif;
}

body {
  font-family: var(--font);
  background: radial-gradient(ellipse at top left, var(--bg-from), var(--bg-to));
  min-height: 100vh;
  color: var(--text);
  user-select: none;
}

/* ── Screens ──────────────────────────────────────────────────────────── */

.screen { display: none; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ── Setup ────────────────────────────────────────────────────────────── */

#screen-setup {
  justify-content: center;
  min-height: 100vh;
  gap: 1.5rem;
  padding: 2rem;
}

.game-title {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(168,85,247,0.25));
}

.game-subtitle {
  color: #9d6cb5;
  font-size: 1rem;
  font-weight: 600;
  margin-top: -0.5rem;
}

.setup-card {
  background: white;
  border-radius: 20px;
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-weight: 700;
  font-size: 0.85rem;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
  padding: 0.6rem 0.9rem;
  border: 2px solid #e9d5ff;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
  background: #faf5ff;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #a855f7;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  padding: 0.65rem 1.3rem;
  border: none;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
}

.btn:active:not(:disabled) { transform: scale(0.95); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--btn-primary), #a855f7);
  color: white;
  box-shadow: 0 3px 12px rgba(236,72,153,0.35);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--btn-primary-hover), #9333ea);
  box-shadow: 0 5px 18px rgba(236,72,153,0.45);
}

.btn-marshmallow {
  background: linear-gradient(135deg, #ec4899, #f97316);
  color: white;
  font-size: 1rem;
  box-shadow: 0 3px 12px rgba(236,72,153,0.35);
}
.btn-marshmallow:hover:not(:disabled) {
  background: linear-gradient(135deg, #db2777, #ea580c);
}

.btn-action {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  box-shadow: 0 3px 12px rgba(124,58,237,0.35);
}
.btn-action:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d28d9, #4338ca);
}

.btn-secondary {
  background: #f3f4f6;
  color: #6b7280;
  border: 2px solid #e5e7eb;
}
.btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
}

.btn-eliminate {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

/* ── Peek screen ─────────────────────────────────────────────────────── */

#screen-peek {
  min-height: 100vh;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
}

.peek-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}

.peek-subtitle {
  color: #9d6cb5;
  font-size: 0.95rem;
  text-align: center;
}

#peek-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.peek-card { cursor: pointer; }

#peek-counter {
  font-weight: 700;
  color: #7c3aed;
  font-size: 1rem;
}

/* ── Game screen ─────────────────────────────────────────────────────── */

#screen-game {
  min-height: 100vh;
  padding: 0.75rem 1rem;
  gap: 0.6rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.4rem 0.2rem;
}

.round-display {
  font-weight: 800;
  font-size: 1.1rem;
  color: #7c3aed;
}

#score-summary {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.score-chip {
  background: white;
  border-radius: 50px;
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid #e9d5ff;
  color: var(--text);
}

.score-chip.human {
  background: linear-gradient(135deg, #fce7f3, #ede9fe);
  border-color: #a855f7;
}

/* AI player area */
#ai-players-area {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.player-zone {
  background: rgba(255,255,255,0.75);
  border-radius: 16px;
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 120px;
}

.player-zone.active-player {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.2);
}

.player-name {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text);
}

.player-name.active { color: #7c3aed; }

.player-score {
  font-size: 0.75rem;
  color: #9d6cb5;
  font-weight: 600;
}

/* Center table area */
.table-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  background: radial-gradient(ellipse, #5a8a6a 0%, var(--felt) 70%);
  border-radius: 50px;
  padding: 1rem 2rem;
  width: 100%;
  box-shadow: inset 0 4px 16px rgba(0,0,0,0.2), var(--shadow);
}

.pile-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
  margin-bottom: 0.25rem;
  text-align: center;
}

.pile-wrapper { display: flex; flex-direction: column; align-items: center; }

#draw-pile, #discard-pile {
  width: var(--card-w);
  height: var(--card-h);
  position: relative;
}

.pile-count {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  color: rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.25);
  border-radius: 50px;
  padding: 1px 5px;
}

/* Drawn card area */
.drawn-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.drawn-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
}

#drawn-card-area {
  min-width: var(--card-w);
  min-height: var(--card-h);
}

.drawn-card {
  animation: pop-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

/* Human player area */
#human-area {
  background: rgba(255,255,255,0.8);
  border-radius: 20px;
  padding: 1rem 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#human-area.active-player {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168,85,247,0.2);
}

/* Card rows */
.card-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Action panel */
#action-panel {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* Eliminate panel */
#eliminate-panel {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background: rgba(16,185,129,0.1);
  border: 2px solid #10b981;
  border-radius: 16px;
  padding: 0.75rem 1rem;
  width: 100%;
  animation: pop-in 0.2s ease;
}

.eliminate-title {
  font-weight: 800;
  color: #065f46;
  font-size: 0.9rem;
  width: 100%;
  text-align: center;
}

/* Message bar */
.message-bar {
  background: rgba(255,255,255,0.9);
  border-radius: 50px;
  padding: 0.45rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  min-height: 2rem;
  width: 100%;
  border: 2px solid #e9d5ff;
  transition: background 0.2s;
}

.message-info { border-color: #7c3aed; background: #f5f3ff; color: #5b21b6; }

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.card-sm {
  --card-w: 52px;
  --card-h: 72px;
  --card-radius: 8px;
}

.card.face-down {
  background: linear-gradient(145deg, #f9a8d4, #c084fc);
  border: 2px solid #f472b6;
}

.card.face-down::before {
  content: '🍡';
  font-size: 1.6rem;
  opacity: 0.6;
}

.card.face-up {
  background: linear-gradient(160deg, white 60%, color-mix(in srgb, var(--card-color, #ccc) 25%, white));
  border: 2.5px solid var(--card-color, #ccc);
}

.card-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--card-color, #333);
  line-height: 1;
}

.card-action-label {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--card-color);
  background: color-mix(in srgb, var(--card-color) 12%, white);
  border-radius: 4px;
  padding: 1px 4px;
  margin-top: 2px;
}

.card.clickable {
  cursor: pointer;
  outline: 2.5px dashed #a855f7;
  outline-offset: 2px;
}

.card.clickable:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 8px 20px rgba(168,85,247,0.3);
  z-index: 10;
}

.card.highlighted {
  outline: 2.5px dashed #a855f7;
  outline-offset: 2px;
}

.card.peeked {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

.card.card-empty {
  background: rgba(255,255,255,0.3);
  border: 2px dashed rgba(255,255,255,0.5);
  color: rgba(255,255,255,0.6);
  font-size: 0.65rem;
  font-weight: 700;
}

.pile-card {
  width: 100%;
  height: 100%;
}

/* Mini cards for round end table */
.mini-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 44px;
  border-radius: 5px;
  font-size: 0.9rem;
  font-weight: 800;
  background: linear-gradient(160deg, white 60%, color-mix(in srgb, var(--card-color, #ccc) 25%, white));
  border: 2px solid var(--card-color, #ccc);
  color: var(--card-color, #333);
  margin: 1px;
}

/* ── Round end / Game end screens ────────────────────────────────────── */

#screen-round-end, #screen-game-end {
  min-height: 100vh;
  justify-content: flex-start;
  padding: 2rem 1rem;
  gap: 1.2rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.round-end-title, .game-end-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.winner-name {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ec4899, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
}

th {
  background: linear-gradient(135deg, #fce7f3, #ede9fe);
  font-weight: 800;
  color: #7c3aed;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:last-child td { border-bottom: none; }
tr.human-row td { background: #fdf4ff; font-weight: 700; }

.cards-cell { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }

#round-log {
  background: rgba(255,255,255,0.7);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  width: 100%;
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
}

#round-log li {
  font-size: 0.8rem;
  color: #6b7280;
  padding: 0.2rem 0;
  border-bottom: 1px solid #f3f4f6;
}

#round-log li:last-child { border-bottom: none; }

/* ── Animations ──────────────────────────────────────────────────────── */

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.5) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
}

@keyframes flipping {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

@keyframes peek-glow {
  0%, 100% { box-shadow: 0 0 0 3px #f59e0b, 0 0 20px rgba(245,158,11,0.4); }
  50%  { box-shadow: 0 0 0 5px #f59e0b, 0 0 30px rgba(245,158,11,0.7); }
}

.shake { animation: shake 0.4s ease; }
.flipping { animation: flipping 0.3s ease; }
.peek-glow { animation: peek-glow 1s ease infinite; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  :root {
    --card-w: 58px;
    --card-h: 82px;
  }
  .card-value { font-size: 1.4rem; }
  .game-title { font-size: 2.4rem; }
}
