/* ═══════════════════════════════════════════════════════════
   LILY WARS — CSS
   ═══════════════════════════════════════════════════════════ */

:root {
  --faction-primary: #3498db;
  --faction-bg:      #1a3a5c;
  --faction-text:    #7ec8e3;
  --bg-dark:         #0d0d1a;
  --bg-card:         #1a1a2e;
  --text-main:       #f0f0f0;
  --text-dim:        #8a8a9a;
  --gold:            #f1c40f;
  --red:             #e74c3c;
  --green:           #2ecc71;
  --border-radius:   8px;
  --card-w:          58px;
  --card-h:          82px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ─── Screens ──────────────────────────────────────────── */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-dark);
}
.screen.active { display: flex; }

/* ─── Main Menu ─────────────────────────────────────────── */
.main-logo {
  font-size: 32px;
  font-weight: 900;
  color: var(--faction-primary);
  letter-spacing: 3px;
  text-shadow: 0 0 20px var(--faction-primary);
  margin-bottom: 8px;
}
.player-rating {
  color: var(--gold);
  font-size: 14px;
  margin-bottom: 32px;
}
.main-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn-primary, .btn-secondary {
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.btn-primary {
  background: var(--faction-primary);
  color: #fff;
}
.btn-secondary {
  background: transparent;
  color: var(--faction-primary);
  border: 1px solid var(--faction-primary);
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.96); opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; pointer-events: none; }

/* ─── Queue ─────────────────────────────────────────────── */
.queue-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--faction-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.queue-status { font-size: 16px; margin-bottom: 24px; }

/* ─── Mulligan ──────────────────────────────────────────── */
.screen-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.opponent-label { color: var(--faction-primary); margin-bottom: 8px; }
.mulligan-hint { color: var(--text-dim); font-size: 12px; margin-bottom: 12px; }
.mulligan-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}
.mulligan-status { color: var(--text-dim); margin-bottom: 12px; min-height: 18px; }

/* ─── Game Board ────────────────────────────────────────── */
#screen-game {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px;
  gap: 2px;
  background: linear-gradient(180deg, var(--faction-bg) 0%, var(--bg-dark) 50%, var(--faction-bg) 100%);
}
#screen-game.active { display: flex; }

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--border-radius);
  min-height: 48px;
}
.top-center { text-align: center; flex: 1; }
.round-display { font-size: 11px; color: var(--text-dim); }
.turn-indicator {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin: 2px auto;
  display: inline-block;
}
.turn-indicator.my-turn  { background: rgba(46,204,113,0.25); color: var(--green); }
.turn-indicator.opp-turn { background: rgba(231,76,60,0.2);   color: #ff6b6b; }

.coins-row { display: flex; gap: 4px; justify-content: center; align-items: center; }
.coins { color: var(--gold); font-size: 14px; letter-spacing: 2px; }
.coins-label { color: var(--text-dim); font-size: 10px; }

.opp-info { text-align: right; font-size: 10px; color: var(--text-dim); }
.opp-name { font-size: 12px; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.deck-info { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }

/* Leader */
.leader-slot { width: 44px; }
.leader-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--faction-bg);
  border: 2px solid var(--faction-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 8px;
  text-align: center;
  transition: box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.leader-icon:active { box-shadow: 0 0 12px var(--faction-primary); }
.leader-icon.used { opacity: 0.4; border-color: var(--text-dim); }
.leader-icon.opponent { border-color: var(--red); }
.leader-name { font-size: 8px; color: var(--faction-text); font-weight: 600; line-height: 1.1; padding: 0 2px; }
.leader-charges {
  position: absolute; bottom: 1px; right: 1px;
  background: var(--gold); color: #000;
  font-size: 8px; font-weight: 700;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Fields */
.field-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.opp-section { border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 2px; }
.me-section  { border-top:    1px solid rgba(255,255,255,0.08); padding-top: 2px; }

.field-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: calc(var(--card-h) + 4px);
  padding: 2px 4px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  transition: background 0.2s;
}
.field-row:has(.drop-zone) { background: rgba(var(--faction-primary), 0.1); }
.row-label { width: 10px; font-size: 10px; color: var(--text-dim); }

.field-row-cards {
  display: flex;
  gap: 3px;
  flex: 1;
  flex-wrap: nowrap;
  overflow: hidden;
  min-height: var(--card-h);
  align-items: center;
  cursor: pointer;
}
.field-row-cards.drop-zone {
  background: rgba(46,204,113,0.1);
  border: 1px dashed var(--green);
  border-radius: 6px;
}

.row-score {
  width: 20px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--faction-text);
}

/* Score bar */
.score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  min-height: 32px;
}
.score-number { font-size: 22px; font-weight: 900; }
.me-score  { color: var(--green); }
.opp-score { color: var(--red); }
.score-divider { flex: 1; display: flex; justify-content: center; }

.btn-pass {
  padding: 6px 16px;
  border: 2px solid var(--faction-primary);
  border-radius: 20px;
  background: transparent;
  color: var(--faction-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.btn-pass:active { background: var(--faction-primary); color: #fff; }
.btn-pass:disabled { opacity: 0.3; pointer-events: none; }

/* Bottom bar */
.bottom-bar {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--border-radius);
}
.my-info { font-size: 10px; color: var(--text-dim); text-align: right; }
.btn-forfeit {
  background: none; border: none;
  font-size: 16px; cursor: pointer;
  display: block; margin-top: 4px;
}

/* Hand */
.hand-container {
  display: flex;
  gap: 3px;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  scrollbar-width: none;
  align-items: flex-end;
  min-height: calc(var(--card-h) + 8px);
  transition: height 0.3s;
}
.hand-container.expanded { height: 200px; align-items: flex-start; flex-wrap: wrap; overflow-y: auto; }
.hand-container::-webkit-scrollbar { display: none; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
  width: var(--card-w);
  min-width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  border: 2px solid #444;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 3px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.card:active { transform: scale(0.95); }
.card.interactive:hover { transform: translateY(-4px); box-shadow: 0 6px 16px rgba(0,0,0,0.5); }
.card.selected {
  transform: translateY(-10px);
  box-shadow: 0 0 0 2px var(--green), 0 8px 20px rgba(46,204,113,0.3);
}

/* Card type specific */
.card-white  { background: #2a2a3e; border-color: #555; }
.card-gray   { background: #2d3436; border-color: #636e72; }
.card-purple { background: #2d1b4e; border-color: #9b59b6; }
.card-gold   { background: #3d2b00; border-color: #f1c40f; box-shadow: 0 0 6px rgba(241,196,15,0.3); }
.card-special { background: #3d0000; border-color: #e74c3c; }

.card-power {
  position: absolute;
  top: 2px; left: 3px;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  line-height: 1;
}
.card-gold .card-power   { color: var(--gold); }
.card-special .card-power { color: var(--red); }

.card-name {
  position: absolute;
  bottom: 2px;
  left: 0; right: 0;
  font-size: 7px;
  text-align: center;
  color: rgba(255,255,255,0.8);
  line-height: 1.2;
  padding: 0 2px;
  overflow: hidden;
}

.card-effect-dot {
  position: absolute;
  top: 2px; right: 3px;
  font-size: 8px;
  color: var(--gold);
  opacity: 0.8;
}
.card-charges {
  position: absolute;
  bottom: 10px; right: 2px;
  font-size: 8px;
  color: #ffd700;
  background: rgba(0,0,0,0.5);
  border-radius: 3px;
  padding: 0 2px;
}
.card-curse {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 16px;
  opacity: 0.6;
  color: #9b59b6;
}

/* ─── Modals ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: #1a1a2e;
  border: 1px solid var(--faction-primary);
  border-radius: 12px;
  padding: 20px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-wide { max-width: 95vw; }
.modal-title { font-size: 16px; font-weight: 700; text-align: center; color: var(--faction-primary); }
.modal-buttons { display: flex; gap: 12px; justify-content: center; }
.card-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* Card detail modal */
.detail-name    { font-size: 18px; font-weight: 700; text-align: center; }
.detail-type    { text-align: center; color: var(--text-dim); font-size: 11px; }
.detail-power   { text-align: center; font-size: 22px; font-weight: 900; color: var(--gold); }
.detail-faction { text-align: center; color: var(--faction-text); font-size: 11px; }
.detail-effect  { background: rgba(255,255,255,0.05); border-radius: 6px; padding: 8px; font-size: 12px; line-height: 1.5; }

/* ─── Game Over ──────────────────────────────────────────── */
#screen-gameover {
  background: radial-gradient(circle, rgba(30,10,50,1) 0%, var(--bg-dark) 100%);
  gap: 16px;
}
.gameover-title { font-size: 36px; font-weight: 900; text-align: center; }
.gameover-reason { color: var(--text-dim); font-size: 13px; }
.gameover-rating { color: var(--gold); font-size: 16px; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: rgba(20,20,40,0.95);
  border: 1px solid var(--faction-primary);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  color: #fff;
  z-index: 200;
  transition: transform 0.3s;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
#toast.visible { transform: translateX(-50%) translateY(0); }

/* ─── Misc ───────────────────────────────────────────────── */
.clickable { cursor: pointer; }
.clickable:hover { opacity: 0.7; }