/* ═══════════════════════════════════════════════════════════════
   KALOOKI ROYALE — Complete Visual System
   Deep-luxury casino aesthetic. Mobile-first, landscape primary.
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Rajdhani:wght@400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --kr-bg:          #060b16;
  --kr-bg2:         #0a1020;
  --kr-table:       #0b3622;
  --kr-table-mid:   #0e4228;
  --kr-table-edge:  #1a6040;
  --kr-rail:        #3d1c08;
  --kr-rail-top:    #6b3010;
  --kr-gold:        #d4af37;
  --kr-gold-light:  #f0d878;
  --kr-gold-dim:    rgba(212,175,55,0.35);
  --kr-ivory:       #faf4e8;
  --kr-red:         #c8102e;
  --kr-red-deep:    #7a0019;
  --kr-text:        #e8dcc8;
  --kr-text-dim:    rgba(232,220,200,0.45);
  --kr-text-faint:  rgba(232,220,200,0.2);
  --kr-white:       #ffffff;

  /* Buttons */
  --btn-h:          52px;
  --btn-h-sm:       44px;
  --btn-radius:     14px;

  /* Cards */
  --card-w:         62px;
  --card-h:         88px;
  --card-w-sm:      46px;
  --card-h-sm:      65px;
  --card-radius:    7px;
}

/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--kr-bg); }

/* ── Root container ────────────────────────────────────────────── */
#krRoot {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
  z-index: 100;
  background: var(--kr-bg);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Background atmosphere ─────────────────────────────────────── */
#krBg {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(11,54,34,0.6) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 20% 0%,  rgba(212,175,55,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 0%,  rgba(212,175,55,0.06) 0%, transparent 60%);
}
/* Noise texture via SVG data URI */
#krBg::after {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 180px;
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════
   TOP HUD
   ═══════════════════════════════════════════════════════════════ */
#krTopHud {
  position: relative; z-index: 20;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 6px 12px 4px;
  height: 48px;
  flex-shrink: 0;
  background: linear-gradient(to bottom, rgba(6,11,22,0.95), transparent);
}

/* Title */
#krTitle {
  font-family: 'Cinzel', serif;
  font-size: 13px; font-weight: 700;
  letter-spacing: 6px;
  color: rgba(212,175,55,0.5);
  text-transform: uppercase;
  text-align: center;
  flex: 1;
}
#krTitle span { color: var(--kr-gold); }

/* Score panel */
#krScores {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 90px;
}
.kr-score-row {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  color: var(--kr-text-dim);
  transition: color 0.3s;
}
.kr-score-row.active { color: var(--kr-text); }
.kr-score-dot {
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
.kr-score-name { flex: 1; font-size: 10px; letter-spacing: 0.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52px; }
.kr-score-val { font-family: 'Cinzel', serif; font-size: 11px; font-weight: 700; color: var(--kr-gold); }

/* Timer */
#krTimer {
  position: relative; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#krTimerSvg {
  position: absolute; inset: 0;
  width: 44px; height: 44px;
  transform: rotate(-90deg);
}
#krTimerTrack {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 3;
}
#krTimerArc {
  fill: none;
  stroke: var(--kr-gold);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 132;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear, stroke 0.4s;
  filter: drop-shadow(0 0 4px rgba(212,175,55,0.6));
}
#krTimerArc.urgent {
  stroke: #ef4444;
  filter: drop-shadow(0 0 5px rgba(239,68,68,0.8));
}
#krTimerNum {
  position: relative; z-index: 1;
  font-family: 'Cinzel', serif;
  font-size: 13px; font-weight: 700;
  color: var(--kr-gold);
  line-height: 1;
  transition: color 0.3s;
}
#krTimerNum.urgent { color: #ef4444; }

/* ═══════════════════════════════════════════════════════════════
   MAIN TABLE
   ═══════════════════════════════════════════════════════════════ */
#krTable {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
  position: relative; z-index: 10;
  padding: 0 10px;
}

/* Opponents row — compact strips across top */
#krOpponents {
  display: flex; gap: 8px;
  justify-content: center;
  padding: 4px 0 6px;
  flex-shrink: 0;
}

.kr-opp {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 5px 9px 5px 6px;
  min-width: 100px;
  transition: border-color 0.3s, background 0.3s;
  position: relative; overflow: hidden;
}
.kr-opp.active-turn {
  border-color: var(--kr-gold-dim);
  background: rgba(212,175,55,0.07);
}
.kr-opp.active-turn::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--kr-gold), transparent);
  animation: krSweep 1.5s ease-in-out infinite;
}
@keyframes krSweep { 0%,100%{opacity:0.3} 50%{opacity:1} }

.kr-opp-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 12px; font-weight: 700;
  flex-shrink: 0; border: 1.5px solid rgba(255,255,255,0.15);
}
.kr-opp-info { flex: 1; min-width: 0; }
.kr-opp-name {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px;
  color: var(--kr-text); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.kr-opp-cards {
  display: flex; align-items: center; gap: 3px;
  font-size: 9px; color: var(--kr-text-dim); margin-top: 1px;
}
.kr-opp-card-mini {
  width: 10px; height: 14px; border-radius: 2px;
  background: linear-gradient(135deg, #1e3a8a, #1e1b4b);
  border: 0.5px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.kr-opp-score {
  font-family: 'Cinzel', serif; font-size: 11px; font-weight: 700;
  color: var(--kr-gold); text-align: right;
}

/* ── Table surface ─────────────────────────────────────────────── */
#krTableSurface {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
  justify-content: center;
}

#krTableFelt {
  flex: 1;
  border-radius: 16px;
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, #0e4a2c 0%, #0b3622 50%, #091e14 100%);
  border: 2px solid rgba(26,96,64,0.5);
  box-shadow:
    inset 0 0 40px rgba(0,0,0,0.5),
    inset 0 0 80px rgba(0,0,0,0.3),
    0 0 0 1px rgba(0,0,0,0.5);
}

/* Felt texture */
#krTableFelt::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='0.12'/%3E%3C/svg%3E");
  background-size: 120px;
  pointer-events: none;
}

/* Table rail (wooden edge) */
#krTableRail {
  position: absolute; inset: -3px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--kr-rail-top), var(--kr-rail), #1a0800);
  z-index: -1;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7), 0 2px 6px rgba(0,0,0,0.5);
}

/* Rail inlay line */
#krTableRail::after {
  content: '';
  position: absolute; inset: 2px; border-radius: 16px;
  border: 1px solid rgba(212,175,55,0.2);
  pointer-events: none;
}

/* ── Center row: deck / melds / discard ──────────────────────── */
#krCenterRow {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 14px; padding: 8px;
}

/* Deck */
#krDeck {
  position: relative; cursor: pointer;
  width: var(--card-w); height: var(--card-h);
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
  transition: transform 0.15s;
}
#krDeck:active { transform: scale(0.95); }
#krDeckBack {
  width: 100%; height: 100%;
  border-radius: var(--card-radius);
}
#krDeckBack svg { width: 100%; height: 100%; display: block; }
#krDeckCount {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  background: rgba(6,11,22,0.9); border: 1px solid var(--kr-gold-dim);
  color: var(--kr-gold); font-size: 9px; font-weight: 700;
  font-family: 'Cinzel', serif; letter-spacing: 0.5px;
  padding: 1px 6px; border-radius: 8px;
  white-space: nowrap;
}

/* Discard pile */
#krDiscardPile {
  position: relative; cursor: pointer;
  width: var(--card-w); height: var(--card-h);
  flex-shrink: 0;
  transition: transform 0.15s;
}
#krDiscardPile:hover { transform: scale(1.03); }
#krDiscardTop { width: 100%; height: 100%; }
#krDiscardTop svg { width: 100%; height: 100%; display: block; }
/* Empty discard slot */
#krDiscardPile.empty #krDiscardTop {
  border-radius: var(--card-radius);
  border: 2px dashed rgba(212,175,55,0.2);
  background: rgba(0,0,0,0.15);
}
#krDiscardLabel {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  font-size: 8px; color: var(--kr-text-faint); letter-spacing: 1px;
  white-space: nowrap; font-weight: 600;
}

/* Meld zone — center area showing played melds */
#krMeldZone {
  flex: 1; max-width: 400px;
  display: flex; flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px; padding: 6px;
  min-height: 60px;
  overflow-y: auto;
  scrollbar-width: none;
}
#krMeldZone::-webkit-scrollbar { display: none; }

.kr-meld-group {
  display: flex; align-items: center;
  gap: 2px; padding: 4px 6px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.kr-meld-group:hover {
  border-color: rgba(212,175,55,0.3);
  background: rgba(212,175,55,0.04);
}
.kr-meld-group.target-glow {
  border-color: var(--kr-gold);
  box-shadow: 0 0 12px rgba(212,175,55,0.35);
}

.kr-meld-card { flex-shrink: 0; }
.kr-meld-card svg { display: block; }

/* Meld zone empty state */
#krMeldEmpty {
  width: 100%; text-align: center; padding: 10px;
  font-size: 9px; letter-spacing: 2px; color: rgba(255,255,255,0.08);
  text-transform: uppercase; font-weight: 600;
  align-self: center;
}

/* ═══════════════════════════════════════════════════════════════
   TURN BAR
   ═══════════════════════════════════════════════════════════════ */
#krTurnBar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 8px; height: 32px;
  position: relative; z-index: 15;
}
#krTurnText {
  font-family: 'Cinzel', serif; font-size: 11px; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--kr-gold); opacity: 0.8;
}
#krTurnText.my-turn {
  opacity: 1;
  animation: krPulseText 2s ease-in-out infinite;
}
@keyframes krPulseText { 0%,100%{opacity:0.7} 50%{opacity:1} }
#krTurnHint {
  font-size: 10px; color: var(--kr-text-dim);
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════════════════════
   ACTION BUTTONS
   ═══════════════════════════════════════════════════════════════ */
#krActions {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 4px 10px 6px;
  position: relative; z-index: 15;
}

.kr-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  min-width: 54px; height: var(--btn-h);
  border-radius: var(--btn-radius);
  border: none; cursor: pointer;
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase;
  color: rgba(255,255,255,0.92);
  position: relative; overflow: hidden;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex: 1; max-width: 72px;
}
.kr-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.kr-btn::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 40%;
  background: rgba(255,255,255,0.12); border-radius: inherit;
  pointer-events: none;
}
.kr-btn:active {
  transform: scale(0.93) translateY(2px);
  box-shadow: none !important;
}
.kr-btn:disabled {
  opacity: 0.32; pointer-events: none; filter: saturate(0.3);
}

/* DRAW DECK */
.kr-btn-draw {
  background: linear-gradient(160deg, #1d4ed8, #1e40af, #1e3a8a);
  box-shadow: 0 4px 0 #1e3a8a, 0 6px 14px rgba(30,58,138,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
/* PICK DISCARD */
.kr-btn-pick {
  background: linear-gradient(160deg, #059669, #047857, #065f46);
  box-shadow: 0 4px 0 #065f46, 0 6px 14px rgba(6,95,70,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
/* MELD */
.kr-btn-meld {
  background: linear-gradient(160deg, #b45309, #92400e, #78350f);
  box-shadow: 0 4px 0 #78350f, 0 6px 14px rgba(120,53,15,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
.kr-btn-meld.ready {
  background: linear-gradient(160deg, #d4af37, #b8962e, #9a7d1a);
  box-shadow: 0 4px 0 #7a5f10, 0 6px 18px rgba(212,175,55,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
  color: #1a0e00;
}
/* ADD TO MELD */
.kr-btn-add {
  background: linear-gradient(160deg, #7c3aed, #6d28d9, #5b21b6);
  box-shadow: 0 4px 0 #4c1d95, 0 6px 14px rgba(91,33,182,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
/* DISCARD */
.kr-btn-discard {
  background: linear-gradient(160deg, #dc2626, #b91c1c, #991b1b);
  box-shadow: 0 4px 0 #7f1d1d, 0 6px 14px rgba(153,27,27,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
}
/* SORT */
.kr-btn-sort {
  background: linear-gradient(160deg, #374151, #1f2937, #111827);
  box-shadow: 0 4px 0 #0a0e18, 0 6px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  max-width: 48px; min-width: 44px;
}
/* Button label */
.kr-btn span {
  display: block; line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ═══════════════════════════════════════════════════════════════
   PLAYER HAND
   ═══════════════════════════════════════════════════════════════ */
#krHandArea {
  flex-shrink: 0;
  position: relative; z-index: 15;
  height: 108px;
  padding: 0 8px 8px;
  overflow: hidden;
}

#krHandScroll {
  width: 100%; height: 100%;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  padding: 10px 4px 2px;
  display: flex; align-items: flex-end;
}
#krHandScroll::-webkit-scrollbar { display: none; }

#krHandCards {
  display: flex; align-items: flex-end;
  gap: 4px; padding: 0 8px;
  height: 100%;
  position: relative;
}

/* Individual card in hand */
.kr-card {
  flex-shrink: 0; position: relative; cursor: pointer;
  width: var(--card-w); height: var(--card-h);
  border-radius: var(--card-radius);
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.18s,
              filter 0.15s;
  transform-origin: bottom center;
  touch-action: pan-x;
}
.kr-card svg { display: block; width: 100%; height: 100%; border-radius: var(--card-radius); }

/* Hover */
.kr-card:hover {
  transform: translateY(-10px) scale(1.04);
  box-shadow: 0 8px 22px rgba(0,0,0,0.5);
  z-index: 5;
}

/* Selected state — gold lift */
.kr-card.selected {
  transform: translateY(-16px) scale(1.05);
  z-index: 10;
  filter: drop-shadow(0 0 8px rgba(212,175,55,0.8));
}
.kr-card.selected::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: calc(var(--card-radius) + 2px);
  border: 2.5px solid var(--kr-gold);
  pointer-events: none;
  animation: krCardGlow 1.5s ease-in-out infinite;
}
@keyframes krCardGlow { 0%,100%{opacity:0.7} 50%{opacity:1} }

/* Drag ghost */
.kr-card.dragging {
  opacity: 0.4; transform: scale(0.9);
}
.kr-card.drag-over {
  transform: translateY(-8px);
  box-shadow: -4px 0 12px rgba(212,175,55,0.4);
}

/* Card on meld zone (smaller) */
.kr-meld-card-wrap {
  width: var(--card-w-sm); height: var(--card-h-sm);
  flex-shrink: 0;
}
.kr-meld-card-wrap svg {
  width: 100%; height: 100%; display: block;
  border-radius: 5px;
}

/* ═══════════════════════════════════════════════════════════════
   JOKER POSITION MODAL
   ═══════════════════════════════════════════════════════════════ */
#krJokerModal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(12px);
  animation: krFadeIn 0.25s ease;
}
@keyframes krFadeIn { from{opacity:0} to{opacity:1} }

#krJokerPanel {
  width: min(340px, 92vw);
  background: linear-gradient(145deg, #0e1a2e, #0a1020);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(212,175,55,0.1);
}
#krJokerPanel h3 {
  font-family: 'Cinzel', serif; font-size: 14px; font-weight: 700;
  letter-spacing: 3px; text-transform: uppercase;
  color: var(--kr-gold); text-align: center; margin-bottom: 4px;
}
#krJokerPanel p {
  font-size: 10px; color: var(--kr-text-dim); text-align: center;
  letter-spacing: 0.5px; margin-bottom: 16px;
}

#krJokerPreview {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-bottom: 16px;
  min-height: 90px;
}
.kr-jp-card { flex-shrink: 0; }

.kr-jp-arrows {
  display: flex; justify-content: center; gap: 12px; margin-bottom: 16px;
}
.kr-jp-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(212,175,55,0.3);
  background: rgba(212,175,55,0.08);
  color: var(--kr-gold); font-size: 18px;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.kr-jp-btn:active { background: rgba(212,175,55,0.18); transform: scale(0.93); }

.kr-jp-confirm {
  width: 100%; height: 46px; border-radius: 12px; border: none;
  background: linear-gradient(135deg, var(--kr-gold), #b8962e);
  color: #0a0800; font-family: 'Cinzel', serif; font-size: 13px;
  font-weight: 700; letter-spacing: 2px; cursor: pointer;
  box-shadow: 0 4px 0 #7a5f10, 0 6px 16px rgba(212,175,55,0.3);
  transition: transform 0.1s;
}
.kr-jp-confirm:active { transform: scale(0.97) translateY(2px); }

/* ═══════════════════════════════════════════════════════════════
   VICTORY / GAME OVER SCREEN
   ═══════════════════════════════════════════════════════════════ */
#krVictory {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3,5,12,0.9); backdrop-filter: blur(18px);
  animation: krFadeIn 0.4s ease;
}

#krVictoryPanel {
  width: min(360px, 92vw);
  background: linear-gradient(145deg, #0e1a2e, #060b16);
  border-radius: 24px;
  border: 1px solid rgba(212,175,55,0.25);
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.8), 0 0 60px rgba(212,175,55,0.06);
  animation: krVictoryPop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes krVictoryPop {
  from { transform: scale(0.7) translateY(30px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.kr-vic-crown {
  font-size: 40px; margin-bottom: 8px;
  animation: krVicBounce 0.8s cubic-bezier(0.34,1.56,0.64,1) 0.3s both;
}
@keyframes krVicBounce {
  from { transform: translateY(-20px) scale(0.5); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

#krVicTitle {
  font-family: 'Cinzel', serif;
  font-size: 22px; font-weight: 900; letter-spacing: 4px;
  color: var(--kr-gold); margin-bottom: 4px;
}
#krVicSubtitle {
  font-size: 12px; color: var(--kr-text-dim); letter-spacing: 2px;
  margin-bottom: 20px;
}

#krVicScores {
  background: rgba(0,0,0,0.3);
  border-radius: 12px; padding: 14px;
  margin-bottom: 20px;
}
.kr-vic-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13px;
}
.kr-vic-row:last-child { border-bottom: none; }
.kr-vic-row .name { color: var(--kr-text); font-weight: 600; }
.kr-vic-row .pts { font-family: 'Cinzel', serif; font-size: 13px; color: var(--kr-gold); }
.kr-vic-row.winner .name { color: var(--kr-gold-light); }
.kr-vic-row.winner .pts { color: #4ade80; }

#krVicBtns {
  display: flex; gap: 10px;
}
.kr-vic-btn {
  flex: 1; height: 48px; border-radius: 14px; border: none;
  font-family: 'Cinzel', serif; font-size: 12px; font-weight: 700;
  letter-spacing: 1.5px; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.kr-vic-btn:active { transform: scale(0.96) translateY(2px); }
#krVicBtnAgain {
  background: linear-gradient(135deg, var(--kr-gold), #9a7d1a);
  color: #080500;
  box-shadow: 0 4px 0 #5a4808, 0 6px 16px rgba(212,175,55,0.35);
}
#krVicBtnLobby {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--kr-text-dim);
}
#krVicBtnLobby:hover { background: rgba(255,255,255,0.1); color: var(--kr-text); }

/* ═══════════════════════════════════════════════════════════════
   WAITING HUD (slim, shows joining players)
   ═══════════════════════════════════════════════════════════════ */
#krWaitHud {
  position: fixed; inset: 0; z-index: 460;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,7,16,0.94);
  backdrop-filter: blur(22px);
  transition: opacity 0.5s;
}

#krWaitPanel {
  width: min(320px, 90vw); text-align: center;
  animation: krVictoryPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
#krWaitTitle {
  font-family: 'Cinzel', serif; font-size: 24px; font-weight: 900;
  letter-spacing: 8px;
  background: linear-gradient(135deg, var(--kr-gold-light), var(--kr-gold), #9a7d1a);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 3px;
}
#krWaitSub {
  font-size: 8px; letter-spacing: 5px; text-transform: uppercase;
  color: rgba(212,175,55,0.35); margin-bottom: 24px;
}
#krWaitStatus {
  font-size: 12px; color: var(--kr-text-dim);
  letter-spacing: 0.5px; margin-bottom: 16px;
}
#krWaitSeats {
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 20px; flex-wrap: wrap;
}
.krw-seat {
  width: 64px; border-radius: 12px; padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.krw-seat-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 15px; font-weight: 700;
  transition: all 0.3s;
}
.krw-seat-name {
  font-size: 9px; font-weight: 600; letter-spacing: 0.3px;
  max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color 0.3s;
}
.krw-bar-wrap {
  background: rgba(255,255,255,0.05); border-radius: 6px;
  height: 3px; overflow: hidden; margin-bottom: 18px;
}
#krWaitBar {
  height: 100%;
  background: linear-gradient(90deg, #c8102e, var(--kr-gold));
  border-radius: 6px; transition: width 0.5s ease;
  width: 0%;
}
#krWaitBtns {
  display: flex; gap: 10px; justify-content: center;
}
#krWaitBtnStart {
  padding: 10px 24px; border-radius: 14px; border: none;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white; font-family: 'Cinzel', serif;
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 4px 0 #14532d, 0 6px 16px rgba(22,163,74,0.35);
  transition: transform 0.1s;
  display: none;
}
#krWaitBtnStart:active { transform: scale(0.96) translateY(2px); }
#krWaitBtnCancel {
  padding: 10px 20px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--kr-text-dim); font-size: 11px; cursor: pointer;
}

/* Board countdown overlay */
#krBoardCd {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.kr-cd-num {
  font-family: 'Cinzel', serif;
  font-size: clamp(70px, 18vw, 120px);
  font-weight: 900; color: var(--kr-gold);
  text-shadow: 0 0 50px rgba(212,175,55,0.6), 0 0 100px rgba(212,175,55,0.25);
  line-height: 1;
  animation: krCdPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes krCdPop {
  from { transform: scale(1.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes krCdFade {
  to { transform: scale(0.3); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */
#krToastArea {
  position: fixed; bottom: 130px; left: 50%;
  transform: translateX(-50%);
  z-index: 800; pointer-events: none;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.kr-toast {
  background: rgba(6,11,22,0.92);
  border: 1px solid rgba(212,175,55,0.25);
  color: var(--kr-text);
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px;
  padding: 8px 16px; border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  white-space: nowrap;
  animation: krToastIn 0.3s ease, krToastOut 0.3s ease 2.5s forwards;
}
.kr-toast.error {
  border-color: rgba(239,68,68,0.4);
  background: rgba(60,8,8,0.92);
}
.kr-toast.success {
  border-color: rgba(74,222,128,0.35);
  color: #86efac;
}
@keyframes krToastIn  { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes krToastOut { to{opacity:0;transform:translateY(-8px)} }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — LANDSCAPE PRIMARY
   ═══════════════════════════════════════════════════════════════ */
@media (max-height: 500px) {
  :root {
    --card-w: 54px;
    --card-h: 76px;
    --card-w-sm: 38px;
    --card-h-sm: 54px;
    --btn-h: 44px;
  }

  #krTopHud { height: 38px; padding: 4px 10px 2px; }
  #krTitle { font-size: 11px; letter-spacing: 4px; }
  #krTimer { width: 36px; height: 36px; }
  #krTimerSvg { width: 36px; height: 36px; }
  #krTimerNum { font-size: 11px; }

  #krHandArea { height: 92px; padding-bottom: 6px; }

  #krActions { gap: 4px; padding: 2px 8px 4px; }
  .kr-btn { min-width: 46px; max-width: 62px; font-size: 9px; }
  .kr-btn svg { width: 17px; height: 17px; }

  #krTurnBar { height: 26px; }
  #krTurnText { font-size: 10px; }
  #krOppStrip { padding: 3px 0; }
}

/* Portrait adjustments */
@media (orientation: portrait) {
  :root {
    --card-w: 58px;
    --card-h: 82px;
  }
  #krHandArea { height: 100px; }
  #krOpponents { flex-wrap: wrap; }
}

/* ═══════════════════════════════════════════════════════════════
   CARD DEAL ANIMATION
   ═══════════════════════════════════════════════════════════════ */
@keyframes krDealIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.8) rotate(-5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}
.kr-card.deal-anim {
  animation: krDealIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════════════════ */
.kr-hidden { display: none !important; }
.kr-gold-text { color: var(--kr-gold); }

/* Scrollbar for meld zone */
#krMeldZone::-webkit-scrollbar { width: 3px; }
#krMeldZone::-webkit-scrollbar-track { background: transparent; }
#krMeldZone::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.2); border-radius: 3px; }
