/* ═══════════════════════════════════════════════════
   KINGEN – Sella Ronda Alpine Theme
   ═══════════════════════════════════════════════════ */

:root {
  --orange:    #FF6600;
  --orange-d:  #CC5200;
  --green:     #2D6A4F;
  --green-l:   #40916C;
  --green-d:   #1B4332;
  --night:     #0a0f1e;
  --night-mid: #111827;
  --snow:      #F0F4F8;
  --snow-dim:  #c8d6e5;
  --felt:      #1e4d2b;
  --felt-l:    #2D6033;
  --card-bg:   #FEFDF5;
  --card-red:  #CC1122;
  --card-blk:  #111827;
  --gold:      #FFD700;
  --text:      #e8edf5;
  --text-dim:  #8899aa;
  --radius:    12px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --card-w:    52px;
  --card-h:    78px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--night);
  color: var(--text);
  user-select: none;
}

/* ───────── VIEWS ───────── */
.view {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  overflow: hidden;
}
.view.active { display: flex; }

/* ───────── SCROLLABLE INNER ───────── */
.scroll { overflow-y: auto; flex: 1; padding: 1rem; }

/* ═══════════════════════════════════
   HOME
   ═══════════════════════════════════ */
#view-home {
  background: linear-gradient(180deg, #060c1a 0%, #0d1d3a 50%, #1a3a2a 100%);
  align-items: center; justify-content: center;
}

/* Mountain silhouette */
.mountains {
  position: absolute; bottom: 0; left: 0; right: 0; height: 45%;
  background:
    /* far peaks */
    linear-gradient(135deg, transparent 50%, #0d2218 50%) 0 100% / 160px 120px no-repeat,
    linear-gradient(225deg, transparent 50%, #0d2218 50%) 160px 100% / 160px 120px no-repeat,
    /* near peaks */
    linear-gradient(145deg, transparent 50%, #162e1e 50%) -30px 100% / 200px 150px no-repeat,
    linear-gradient(215deg, transparent 50%, #162e1e 50%) 170px 100% / 200px 150px no-repeat,
    linear-gradient(150deg, transparent 50%, #162e1e 50%) 280px 100% / 180px 140px no-repeat,
    linear-gradient(210deg, transparent 50%, #162e1e 50%) 420px 100% / 180px 140px no-repeat;
  pointer-events: none;
}

/* Stars */
#view-home::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,.8) 0, transparent 0),
    radial-gradient(1px 1px at 25% 8%,  rgba(255,255,255,.6) 0, transparent 0),
    radial-gradient(1px 1px at 40% 20%, rgba(255,255,255,.7) 0, transparent 0),
    radial-gradient(1px 1px at 60% 5%,  rgba(255,255,255,.5) 0, transparent 0),
    radial-gradient(1px 1px at 75% 18%, rgba(255,255,255,.8) 0, transparent 0),
    radial-gradient(1px 1px at 88% 10%, rgba(255,255,255,.6) 0, transparent 0),
    radial-gradient(1px 1px at 15% 35%, rgba(255,255,255,.4) 0, transparent 0),
    radial-gradient(1px 1px at 55% 30%, rgba(255,255,255,.5) 0, transparent 0),
    radial-gradient(1.5px 1.5px at 32% 12%, rgba(255,255,255,.9) 0, transparent 0),
    radial-gradient(1.5px 1.5px at 68% 25%, rgba(255,255,255,.7) 0, transparent 0);
  pointer-events: none;
}

.home-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; padding: 2rem 1.5rem;
  width: 100%; max-width: 420px;
}

/* Sella Ronda circuit ring */
.sella-ring {
  width: 100px; height: 100px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  animation: spin 12s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sella-arc {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 8px solid transparent;
}
.sella-arc.orange {
  border-top-color: var(--orange);
  border-right-color: var(--orange);
  transform: rotate(-10deg);
}
.sella-arc.green {
  border-bottom-color: var(--green-l);
  border-left-color: var(--green-l);
  transform: rotate(-10deg);
}
.sella-center {
  font-size: 2rem;
  position: relative; z-index: 1;
  animation: spin 12s linear infinite reverse;
}

.game-title {
  font-size: clamp(2.8rem, 10vw, 4rem);
  font-weight: 900;
  letter-spacing: .15em;
  background: linear-gradient(135deg, var(--orange) 40%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.game-subtitle {
  font-size: .9rem; color: var(--text-dim);
  letter-spacing: .05em; text-align: center;
}

.home-buttons {
  display: flex; flex-direction: column; gap: .75rem;
  width: 100%; margin-top: .5rem;
}

.other-games-teaser {
  display: flex; flex-wrap: wrap; gap: .4rem;
  align-items: center; justify-content: center;
  margin-top: .5rem;
}
.teaser-label { font-size: .75rem; color: var(--text-dim); }
.teaser-item { font-size: .75rem; color: var(--text-dim); opacity: .5;
  padding: .2rem .5rem; border: 1px solid rgba(255,255,255,.1); border-radius: 20px; }

/* ═══════════════════════════════════
   BUTTONS
   ═══════════════════════════════════ */
.btn-primary, .btn-secondary, .btn-ghost {
  border: none; border-radius: var(--radius);
  padding: .85rem 1.5rem;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: transform .12s, opacity .12s, box-shadow .12s;
  letter-spacing: .03em;
}
.btn-primary:active, .btn-secondary:active, .btn-ghost:active { transform: scale(.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-d) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255,102,0,.35);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(255,102,0,.5); }

.btn-secondary {
  background: linear-gradient(135deg, var(--green-l) 0%, var(--green) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(45,106,79,.35);
}

.btn-ghost {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }

.btn-large { font-size: 1.15rem; padding: 1rem 2rem; }
.btn-sm { font-size: .85rem; padding: .5rem 1rem; }

.btn-back {
  background: none; border: none; color: var(--text); font-size: 1.4rem;
  cursor: pointer; padding: .3rem .6rem; border-radius: 8px;
  transition: background .15s;
}
.btn-back:hover { background: rgba(255,255,255,.1); }

/* ═══════════════════════════════════
   SETUP VIEW
   ═══════════════════════════════════ */
#view-setup {
  background: var(--night-mid);
}

.view-header {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem;
  background: rgba(0,0,0,.3);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.view-header h2 { font-size: 1.2rem; font-weight: 700; }

.setup-form {
  display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.5rem 1.25rem; flex: 1; overflow-y: auto;
}

.form-group { display: flex; flex-direction: column; gap: .5rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em; }

input[type="text"], input[type="datetime-local"] {
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 1rem;
  padding: .75rem 1rem;
  width: 100%; outline: none;
  transition: border-color .2s;
}
input:focus { border-color: var(--orange); }

.card-style-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
}
.style-btn {
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  padding: .75rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  transition: border-color .2s, background .2s; color: var(--text);
}
.style-btn.active {
  border-color: var(--orange);
  background: rgba(255,102,0,.12);
}
.style-label { font-size: .8rem; font-weight: 700; }
.style-cards { font-size: 1.1rem; font-weight: 800; color: var(--orange); }

.error-msg {
  color: #ff6b6b; font-size: .85rem; min-height: 1.2em;
  padding: 0 .25rem;
}

/* ═══════════════════════════════════
   LOBBY VIEW
   ═══════════════════════════════════ */
#view-lobby { background: var(--night-mid); }

.room-code-display {
  display: flex; align-items: center; gap: .75rem;
}
.code-label { font-size: .8rem; color: var(--text-dim); }
.code-value {
  font-size: 1.8rem; font-weight: 900; letter-spacing: .25em;
  color: var(--orange); font-family: monospace;
}
.btn-copy {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--text-dim);
  padding: .3rem; border-radius: 6px;
  transition: background .15s;
}
.btn-copy:hover { background: rgba(255,255,255,.1); }

.lobby-players {
  flex: 1; overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex; flex-direction: column; gap: .6rem;
}

.player-slot {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  border: 1px solid rgba(255,255,255,.07);
  animation: fadeIn .25s ease;
}
.player-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800;
  flex-shrink: 0;
}
.avatar-human { background: linear-gradient(135deg, var(--orange), var(--orange-d)); }
.avatar-computer { background: linear-gradient(135deg, var(--green), var(--green-d)); }
.player-info { flex: 1; }
.player-name { font-weight: 700; font-size: .95rem; }
.player-tag { font-size: .75rem; color: var(--text-dim); }
.btn-remove-computer {
  background: none; border: 1px solid rgba(255,255,255,.15);
  color: var(--text-dim); font-size: .75rem; cursor: pointer;
  padding: .3rem .6rem; border-radius: 4px;
  transition: color .15s, border-color .15s;
}
.btn-remove-computer:hover { color: #ff6b6b; border-color: #ff6b6b; }

.player-slot-empty {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(255,255,255,.02);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  border: 1px dashed rgba(255,255,255,.1);
  color: var(--text-dim); font-size: .85rem;
}

.lobby-actions {
  padding: .75rem 1.25rem;
  display: flex; flex-direction: column; gap: .75rem;
  border-top: 1px solid rgba(255,255,255,.07);
}

.schedule-area { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.schedule-label { font-size: .8rem; color: var(--text-dim); flex-basis: 100%; }
.schedule-input { flex: 1; min-width: 180px; }
.schedule-display {
  background: rgba(255,102,0,.1); border: 1px solid rgba(255,102,0,.3);
  border-radius: var(--radius-sm); padding: .5rem .75rem;
  font-size: .85rem; color: var(--orange);
}

.lobby-bottom {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: .75rem; align-items: center;
}
.lobby-hint { font-size: .85rem; color: var(--text-dim); text-align: center; }

/* ═══════════════════════════════════
   TRUMP CALLING
   ═══════════════════════════════════ */
#view-trump {
  background: rgba(6,10,24,.9);
  backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}

.trump-panel {
  background: linear-gradient(160deg, #111827 0%, #1B2E1F 100%);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 360px; width: 90%;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
}

.trump-ski-icon { font-size: 2.5rem; }
.trump-title { font-size: 1.5rem; font-weight: 900; }
.trump-subtitle { font-size: .9rem; color: var(--text-dim); }

.suit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem;
  width: 100%;
}
.suit-btn {
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 1rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  transition: all .2s; color: var(--text);
}
.suit-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.suit-btn:active { transform: scale(.95); }
.suit-btn.red { border-color: rgba(204,17,34,.3); }
.suit-btn.red:hover { border-color: var(--card-red); background: rgba(204,17,34,.1); }
.suit-btn.black:hover { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.08); }
.suit-symbol { font-size: 2.2rem; line-height: 1; }
.suit-btn.red .suit-symbol { color: var(--card-red); }
.suit-name { font-size: .8rem; font-weight: 700; color: var(--text-dim); }

.trump-waiting { color: var(--text-dim); font-size: .9rem; }

/* ═══════════════════════════════════
   GAME VIEW
   ═══════════════════════════════════ */
#view-game {
  background: var(--felt);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 40%, rgba(27,77,51,.5) 0%, transparent 70%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.04) 0, rgba(0,0,0,.04) 1px, transparent 0, transparent 50%);
  background-size: auto, 8px 8px;
}

.game-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem;
  background: rgba(0,0,0,.35);
  flex-shrink: 0;
  min-height: 48px;
}

.round-badge {
  display: flex; align-items: center; gap: .4rem;
  background: rgba(255,102,0,.15);
  border: 1px solid rgba(255,102,0,.3);
  border-radius: 20px;
  padding: .25rem .75rem;
  flex: 1;
}
.round-num {
  background: var(--orange);
  color: #fff; font-weight: 900; font-size: .75rem;
  border-radius: 50%; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.round-name { font-size: .8rem; font-weight: 700; color: var(--orange); }

.trick-counter { font-size: .8rem; color: var(--text-dim); white-space: nowrap; }

.btn-score-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--text-dim);
  padding: .25rem;
}

.trump-indicator {
  text-align: center;
  padding: .25rem;
  font-size: .8rem; font-weight: 700;
  background: rgba(255,102,0,.2);
  color: var(--orange);
  flex-shrink: 0;
}

.table-area {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; position: relative;
}

/* Opponents */
.opponents-row {
  display: flex; justify-content: space-around; align-items: flex-end;
  padding: .5rem .5rem 0;
  flex-shrink: 0;
  gap: .25rem;
}

.opponent-widget {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  flex: 1; max-width: 120px;
}
.opponent-cards {
  display: flex; position: relative; height: 34px;
}
.opp-card-back {
  width: 22px; height: 32px; border-radius: 4px;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-d) 50%, var(--green-d) 100%);
  border: 1.5px solid rgba(255,255,255,.2);
  margin-left: -8px;
  box-shadow: 1px 1px 4px rgba(0,0,0,.4);
  position: relative;
}
.opp-card-back::after {
  content: '⛷';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; opacity: .6;
}
.opp-card-back:first-child { margin-left: 0; }
.opponent-name {
  font-size: .7rem; font-weight: 700;
  color: var(--text-dim); text-align: center;
  max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.opponent-score-mini {
  font-size: .65rem; color: var(--text-dim);
}
.opponent-widget.active-turn .opponent-name {
  color: var(--gold);
}
.opponent-widget.active-turn .opp-card-back {
  border-color: var(--gold);
}
.turn-arrow {
  font-size: .9rem;
  animation: bounce 1s ease-in-out infinite;
}
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }

/* Trick center */
.trick-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 0;
  padding: .25rem;
}

.trick-center {
  display: grid;
  grid-template-columns: var(--card-w) var(--card-w);
  grid-template-rows: var(--card-h) var(--card-h);
  gap: 6px;
}

.trick-slot {
  width: var(--card-w); height: var(--card-h);
  border-radius: 8px;
  border: 2px dashed rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  transition: all .3s ease;
  position: relative;
}
.trick-slot.has-card {
  border-color: transparent;
}

.trick-winner-msg {
  font-size: .85rem; font-weight: 700; color: var(--gold);
  height: 1.4em;
  text-align: center;
  opacity: 0; transition: opacity .3s;
  margin-top: .25rem;
}
.trick-winner-msg.visible { opacity: 1; }

/* Score panel */
.score-panel {
  background: rgba(0,0,0,.5);
  border-top: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
  max-height: 0; transition: max-height .3s ease;
  flex-shrink: 0;
}
.score-panel.open { max-height: 180px; }

.score-rows {
  display: flex; flex-direction: column; gap: 2px;
  padding: .5rem .75rem;
}
.score-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; padding: .2rem 0;
}
.score-row.me { color: var(--snow); font-weight: 700; }
.score-row .s-name { flex: 1; color: var(--text-dim); }
.score-row .s-score { font-weight: 700; min-width: 30px; text-align: right; }
.score-row.active-turn .s-name { color: var(--gold); }

/* My hand */
.my-hand-area {
  flex-shrink: 0;
  background: rgba(0,0,0,.35);
  border-top: 1px solid rgba(255,255,255,.1);
  padding: .5rem .5rem .6rem;
}
.my-hand {
  display: flex; justify-content: center; flex-wrap: nowrap;
  overflow-x: auto; gap: 4px;
  padding: 2px 0;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
}
.hand-hint {
  text-align: center; font-size: .72rem; color: var(--text-dim);
  margin-top: .25rem; min-height: 1em;
}

/* ═══════════════════════════════════
   CARDS
   ═══════════════════════════════════ */
.card {
  width: var(--card-w); height: var(--card-h);
  background: var(--card-bg);
  border-radius: 8px;
  border: 1.5px solid rgba(0,0,0,.15);
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  position: relative;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s;
  flex-shrink: 0;
  font-family: 'Georgia', serif;
}
.card.red { color: var(--card-red); }
.card.black { color: var(--card-blk); }

.card-corner {
  display: flex; flex-direction: column; align-items: center;
  line-height: 1;
}
.card-rank { font-size: .75rem; font-weight: 900; line-height: 1; }
.card-suit-small { font-size: .6rem; line-height: 1; }
.card-suit-big {
  font-size: 1.5rem; line-height: 1;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
}
.card-corner-bottom {
  transform: rotate(180deg);
  align-self: flex-end;
}

.card.in-hand:hover:not(.invalid) {
  transform: translateY(-10px);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 10;
}
.card.invalid {
  opacity: .4; cursor: not-allowed;
  filter: grayscale(.5);
}
.card.played {
  animation: playCard .25s ease forwards;
}
@keyframes playCard {
  from { transform: scale(1.15); box-shadow: 0 12px 32px rgba(0,0,0,.5); }
  to   { transform: scale(1);    box-shadow: 0 2px 8px rgba(0,0,0,.3); }
}

/* Trick slot positions */
/* 0=top-left → opponent at "top" in 2x2 */
#tslot-0 { grid-row: 1; grid-column: 1; }
#tslot-1 { grid-row: 1; grid-column: 2; }
#tslot-2 { grid-row: 2; grid-column: 1; }
#tslot-3 { grid-row: 2; grid-column: 2; }

/* ═══════════════════════════════════
   ROUND SUMMARY
   ═══════════════════════════════════ */
#view-round {
  background: linear-gradient(160deg, #0a1628 0%, #0f2d1a 100%);
  align-items: center; justify-content: center;
  overflow: hidden;
}

.gondola-anim {
  position: absolute; top: 8%; left: -5%;
  font-size: 2.5rem;
  animation: gondola 5s ease-in-out infinite;
}
@keyframes gondola {
  0%   { left: -8%; }
  50%  { left: 108%; }
  100% { left: -8%; }
}

.round-summary {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  max-width: 400px; width: 90%;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  position: relative; z-index: 1;
  max-height: 85vh; overflow-y: auto;
}

.round-end-badge {
  background: linear-gradient(135deg, var(--orange), var(--orange-d));
  color: #fff; font-weight: 900; font-size: 1rem;
  border-radius: 20px; padding: .3rem 1rem;
}
.round-end-title { font-size: 1.4rem; font-weight: 900; text-align: center; }
.round-end-subtitle { font-size: .85rem; color: var(--text-dim); text-align: center; }

.round-scores-table, .total-scores-table {
  width: 100%;
}
.score-table-title {
  font-size: .75rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: .4rem;
}
.score-table-row {
  display: flex; justify-content: space-between;
  padding: .4rem .5rem;
  border-radius: 6px;
  transition: background .2s;
}
.score-table-row:nth-child(even) { background: rgba(255,255,255,.04); }
.score-table-row .st-name { color: var(--text); font-size: .9rem; }
.score-table-row .st-pts {
  font-weight: 900; font-size: .9rem;
  color: var(--orange);
}
.score-table-row .st-total { color: var(--text-dim); font-size: .8rem; }
.score-table-row.winner-row .st-name { color: var(--gold); }

.round-next-hint { font-size: .8rem; color: var(--text-dim); }

/* ═══════════════════════════════════
   GAME END
   ═══════════════════════════════════ */
#view-end {
  background: radial-gradient(ellipse at 50% 30%, #0d2245 0%, #060c1a 70%);
  align-items: center; justify-content: center;
  overflow: hidden;
}

#snowCanvas {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
}

.end-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 1.5rem;
  padding: 2rem 1.5rem; width: 100%; max-width: 420px;
  overflow-y: auto; max-height: 100vh;
}

.end-title {
  font-size: 2rem; font-weight: 900;
  text-align: center;
  text-shadow: 0 0 30px rgba(255,215,0,.5);
}

.podium {
  display: flex; align-items: flex-end; gap: .5rem;
  justify-content: center; width: 100%;
}
.podium-place {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  min-width: 80px;
}
.podium-name { font-size: .8rem; font-weight: 700; text-align: center; }
.podium-score { font-size: .75rem; color: var(--text-dim); }
.podium-block {
  width: 70px; border-radius: 8px 8px 0 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 900;
}
.podium-place:nth-child(1) .podium-block { height: 80px; background: linear-gradient(180deg, #FFD700, #B8860B); color: #fff; }
.podium-place:nth-child(2) .podium-block { height: 60px; background: linear-gradient(180deg, #C0C0C0, #888); color: #fff; }
.podium-place:nth-child(3) .podium-block { height: 45px; background: linear-gradient(180deg, #CD7F32, #8B4513); color: #fff; }
.podium-place:nth-child(4) .podium-block { height: 32px; background: rgba(255,255,255,.15); color: var(--text-dim); }

.final-table {
  width: 100%;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  overflow: hidden;
}
.final-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1rem;
}
.final-row:nth-child(odd) { background: rgba(255,255,255,.03); }
.final-row .fr-pos { color: var(--text-dim); font-size: .8rem; width: 24px; }
.final-row .fr-name { flex: 1; font-weight: 700; }
.final-row .fr-score { font-weight: 900; font-size: 1.1rem; color: var(--orange); }
.final-row:first-child .fr-name { color: var(--gold); }

/* ═══════════════════════════════════
   HISTORY
   ═══════════════════════════════════ */
#view-history { background: var(--night-mid); }

.history-list {
  flex: 1; overflow-y: auto;
  padding: 1rem;
  display: flex; flex-direction: column; gap: .75rem;
}
.history-entry {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  cursor: pointer; transition: background .2s;
}
.history-entry:hover { background: rgba(255,255,255,.08); }

.he-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .4rem;
}
.he-date { font-size: .75rem; color: var(--text-dim); }
.he-winner {
  font-size: .75rem; font-weight: 700; color: var(--gold);
  background: rgba(255,215,0,.1); border-radius: 20px;
  padding: .15rem .6rem;
}
.he-players { font-size: .85rem; color: var(--text); }
.he-scores {
  font-size: .75rem; color: var(--text-dim); margin-top: .2rem;
}
.history-empty {
  text-align: center; color: var(--text-dim);
  padding: 3rem 1rem; font-size: .9rem;
}

/* ═══════════════════════════════════
   DEAL OVERLAY
   ═══════════════════════════════════ */
.deal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(6,10,24,.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem;
  backdrop-filter: blur(4px);
}
.sella-arrows {
  position: relative; width: 120px; height: 120px;
}
.arrow {
  position: absolute;
  font-size: 2.5rem; font-weight: 900;
  opacity: 0;
}
.arrow.orange { color: var(--orange); }
.arrow.green  { color: var(--green-l); }
.arrow.top    { top: 0; left: 50%; transform: translateX(-50%); }
.arrow.right  { right: 0; top: 50%; transform: translateY(-50%); }
.arrow.bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.arrow.left   { left: 0; top: 50%; transform: translateY(-50%); }

.arrow.dealing { animation: arrowPulse .6s ease-in-out infinite alternate; }
@keyframes arrowPulse {
  from { opacity: .3; transform: translateX(-50%) scale(.9); }
  to   { opacity: 1;  transform: translateX(-50%) scale(1.1); }
}
.arrow.right.dealing { animation: arrowPulseR .6s ease-in-out infinite alternate .15s; }
@keyframes arrowPulseR {
  from { opacity: .3; transform: translateY(-50%) scale(.9); }
  to   { opacity: 1;  transform: translateY(-50%) scale(1.1); }
}
.arrow.bottom.dealing { animation: arrowPulseB .6s ease-in-out infinite alternate .3s; }
@keyframes arrowPulseB {
  from { opacity: .3; transform: translateX(-50%) scale(.9); }
  to   { opacity: 1;  transform: translateX(-50%) scale(1.1); }
}
.arrow.left.dealing { animation: arrowPulseL .6s ease-in-out infinite alternate .45s; }
@keyframes arrowPulseL {
  from { opacity: .3; transform: translateY(-50%) scale(.9); }
  to   { opacity: 1;  transform: translateY(-50%) scale(1.1); }
}

.deal-text { font-size: 1rem; color: var(--text-dim); }

/* ═══════════════════════════════════
   TOAST
   ═══════════════════════════════════ */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
  background: rgba(30,40,60,.95);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 25px;
  padding: .7rem 1.25rem;
  font-size: .9rem; font-weight: 600;
  z-index: 9999; pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  max-width: 90%;
  text-align: center;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255,107,107,.4); color: #ff8a8a; }
.toast.success { border-color: rgba(45,106,79,.5); color: #74c69d; }

/* ═══════════════════════════════════
   UTILITIES / ANIMATIONS
   ═══════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.waiting-dots::after {
  content: ''; animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: '';    }
  25%  { content: '.';   }
  50%  { content: '..';  }
  75%  { content: '...'; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */
@media (max-height: 600px) {
  :root { --card-w: 44px; --card-h: 66px; }
  .opponents-row { padding-top: .25rem; }
  .card-suit-big { font-size: 1.2rem; }
  .card-rank { font-size: .65rem; }
}

@media (min-width: 600px) {
  :root { --card-w: 58px; --card-h: 87px; }
  .card-rank { font-size: .85rem; }
  .card-suit-big { font-size: 1.8rem; }
  .trick-center { gap: 10px; }
  .opp-card-back { width: 26px; height: 38px; }
}
