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

:root {
  --bg:        #0f172a;
  --bg2:       #1e293b;
  --bg3:       #334155;
  --border:    #475569;
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --primary:   #6366f1;
  --primary-h: #4f46e5;
  --warning:   #f59e0b;
  --warning-h: #d97706;
  --danger:    #ef4444;
  --success:   #22c55e;
  --radius:    10px;
  --shadow:    0 4px 32px rgba(0,0,0,.5);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.hint   { font-size: .75rem; color: var(--muted); font-weight: 400; }
.error  { color: var(--danger); font-size: .85rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  cursor: pointer; font-size: .9rem; font-weight: 600;
  transition: background .15s, transform .1s; white-space: nowrap;
}
.btn:disabled      { opacity: .5; cursor: not-allowed; }
.btn:active        { transform: scale(.97); }
.btn-primary       { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-warning       { background: var(--warning);   color: #000; }
.btn-warning:hover { background: var(--warning-h); }
.btn-ghost         { background: transparent; color: var(--muted); }
.btn-ghost:hover   { background: var(--bg3); color: var(--text); }
.btn-outline       { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg3); }
.btn-full          { width: 100%; }
.btn-sm            { padding: 6px 14px; font-size: .8rem; }

/* ── Form controls ───────────────────────────────────────────────────────────── */
input[type="text"],
input[type="number"] {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .9rem;
  outline: none; transition: border-color .15s;
}
input:focus        { border-color: var(--primary); }
input::placeholder { color: var(--muted); }

.field       { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: .8rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}

/* ── Lobby ───────────────────────────────────────────────────────────────────── */
.lobby-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px; padding: 44px 40px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 20px;
}
.lobby-card h1 { font-size: 2rem; text-align: center; }
.room-hint     { font-size: .8rem; color: var(--muted); text-align: center; }

/* ── Header ──────────────────────────────────────────────────────────────────── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--bg2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.logo          { color: var(--text); text-decoration: none; font-size: 1.1rem; font-weight: 700; }
.room-badge    { font-size: .9rem; color: var(--muted); }
.room-badge strong { color: var(--text); letter-spacing: .08em; }
.username-tag  {
  background: var(--primary); color: #fff; padding: 4px 14px;
  border-radius: 20px; font-size: .85rem; font-weight: 600;
}

/* ── Three-column layout ─────────────────────────────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 230px 1fr 270px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 57px);
}
.panel {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; overflow-y: auto;
}
.panel > h2 {
  font-size: .85rem; color: var(--muted); text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: 18px;
}

/* ── Players ─────────────────────────────────────────────────────────────────── */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.player-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg3); border-radius: 8px;
  transition: opacity .2s;
}
.player-item.offline { opacity: .45; }
.player-item.you .player-avatar { background: var(--warning); color: #000; }

.player-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.player-info  { flex: 1; min-width: 0; }
.player-name  {
  font-size: .9rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-name em { font-style: normal; color: var(--muted); font-weight: 400; font-size: .8rem; }
.player-role    { font-size: .72rem; color: var(--muted); }

.player-status         { font-size: .75rem; flex-shrink: 0; }
.player-status.offline { color: var(--danger); }
.player-status.voted   { color: var(--success); }
.player-status.muted   { color: var(--muted); }
.player-status.waiting { color: var(--warning); }

/* ── Game panel ──────────────────────────────────────────────────────────────── */
.game-panel  { display: flex; flex-direction: column; }

.voting-area {
  display: flex; flex-direction: column; align-items: center;
  gap: 28px; padding-top: 28px; flex: 1;
}
.instruction {
  color: var(--muted); font-size: .95rem;
  min-height: 1.4em; text-align: center;
}

.card-deck {
  display: flex; flex-wrap: wrap; gap: 14px;
  justify-content: center; max-width: 640px;
}

.poker-card {
  width: 72px; height: 104px;
  background: var(--bg3); border: 2px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; user-select: none;
  transition: transform .15s, border-color .15s, background .15s, box-shadow .15s;
}
.poker-card:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
}
.poker-card.selected {
  background: var(--primary); border-color: var(--primary);
  transform: translateY(-10px);
  box-shadow: 0 10px 28px rgba(99,102,241,.45);
}
.poker-card.observer       { cursor: default; opacity: .4; }
.poker-card.observer:hover { transform: none; border-color: var(--border); }

.card-label { font-size: 1.25rem; font-weight: 700; }
.card-sub   { font-size: .65rem; color: var(--muted); margin-top: 4px; }
.poker-card.selected .card-sub { color: rgba(255,255,255,.65); }

.game-actions {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
  padding-bottom: 20px;
}

/* ── Results ─────────────────────────────────────────────────────────────────── */
.results-area {
  padding-top: 20px;
  display: flex; flex-direction: column; gap: 20px; align-items: center;
}
.results-area h2 {
  color: var(--text); font-size: 1.3rem;
  text-transform: none; letter-spacing: 0;
}

.results-grid {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: center; width: 100%;
}
.result-card {
  background: var(--bg3); border: 2px solid var(--border);
  border-radius: 14px; padding: 18px 22px; text-align: center; min-width: 110px;
}
.result-name         { font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.result-vote         { font-size: 2.2rem; font-weight: 700; color: var(--primary); }
.result-vote.no-vote { font-size: 1.4rem; color: var(--muted); }

.result-summary {
  background: var(--bg3); border-radius: var(--radius); padding: 18px 28px;
  text-align: center; color: var(--muted); font-size: .95rem; width: 100%;
}
.result-summary strong { color: var(--text); font-size: 1.1rem; }

/* ── Settings panel ──────────────────────────────────────────────────────────── */
.cards-settings-list {
  list-style: none; display: flex; flex-direction: column;
  gap: 6px; margin-bottom: 16px;
}
.card-setting-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border-radius: 8px; padding: 8px 12px;
}
.card-setting-label { flex: 1; font-size: .9rem; font-weight: 600; }
.card-setting-value { font-size: .8rem; color: var(--muted); }
.card-setting-del {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 2px;
}
.card-setting-del:hover { color: #ff7070; }

.add-card-form { display: flex; flex-direction: column; gap: 8px; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px;
}
.modal h2      { text-align: center; font-size: 1.2rem; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}
/* ── Room list (lobby) ───────────────────────────────────────────────────────── */
.rooms-section {
  display: flex; flex-direction: column; gap: 8px;
}
.rooms-header {
  display: flex; align-items: center; justify-content: space-between;
}
.rooms-title {
  font-size: .8rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}

.room-list {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px;
  background: var(--bg3);
}
.room-list-empty {
  padding: 16px; text-align: center; font-size: .875rem;
}
.room-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--bg2); border-radius: 8px;
  border: 1px solid var(--border); transition: border-color .15s;
}
.room-list-item:hover { border-color: var(--primary); }

.room-list-info {
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; flex: 1; min-width: 0;
}
.room-list-name {
  font-size: .95rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-list-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: .72rem; color: var(--muted); background: var(--bg3);
  padding: 2px 7px; border-radius: 10px;
}
.badge-online { color: var(--success); }

.divider {
  text-align: center; color: var(--muted); font-size: .8rem;
  position: relative;
}
.divider::before, .divider::after {
  content: ''; position: absolute; top: 50%;
  width: 25%; height: 1px; background: var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

.muted { color: var(--muted); }

/* Refresh spin animation */
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { animation: spin .6s linear; }

/* ── Room list action buttons ────────────────────────────────────────────────── */
.room-list-actions {
  display: flex; gap: 6px; align-items: center; flex-shrink: 0;
}

.btn-danger       { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ── Collapsible settings panel ──────────────────────────────────────────────── */
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; margin-bottom: 18px;
}
.settings-header h2 { margin-bottom: 0; }

.collapse-btn { font-size: .75rem; transition: transform .25s; }
.settings-panel.collapsed .collapse-btn { transform: rotate(180deg); }

#settingsBody {
  overflow: hidden;
  max-height: 600px;
  transition: max-height .3s ease, opacity .3s ease;
  opacity: 1;
}
.settings-panel.collapsed #settingsBody {
  max-height: 0;
  opacity: 0;
}

.game-control-section {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px;
}
.panel-divider {
  border: none; border-top: 1px solid var(--border); margin: 16px 0;
}