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

:root {
  --bg:      #0d0d0f;
  --surface: #18181c;
  --surface2:#222228;
  --border:  #2e2e38;
  --text:    #e8e8f0;
  --muted:   #888898;
  --accent:  #7c6af7;
  --green:   #4caf50;
  --red:     #f44336;
  --blue:    #2196f3;
  --orange:  #ff9800;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ======== LOBBY ======== */
.lobby-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

#lobby-view {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: .08em;
  background: linear-gradient(135deg, #7c6af7 0%, #f76a6a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.card-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 300px;
}

input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
input:focus { border-color: var(--accent); }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
button:hover  { opacity: .88; }
button:active { transform: scale(.97); }

.btn-row { display: flex; gap: 8px; }
.btn-row button { flex: 1; }

#pin-row { display: flex; gap: 8px; align-items: center; }
#pin-row input { flex: 1; }
#pin-row button { flex: 0 0 auto; }

.big-pin {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: .25em;
  color: var(--accent);
  background: var(--surface2);
  padding: 14px 28px;
  border-radius: 12px;
  border: 2px solid var(--accent);
}

.waiting-dots .dots::after {
  content: '';
  animation: dots 1.5s infinite;
}
@keyframes dots {
  0%  { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
}

.hidden { display: none !important; }
.error-msg { color: var(--red); font-size: .85rem; }

/* ======== GAME LAYOUT ======== */
#game-view {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* Board — left/main column */
#board {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  padding: 8px;
  gap: 6px;
}

/* ---- Opponent area ---- */
#opponent-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 210px;
}

#opp-info, #my-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
  flex-shrink: 0;
}

.points-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-weight: 700;
  font-size: .82rem;
  color: var(--green);
}

.status-tag {
  font-size: .72rem;
  color: var(--muted);
  font-style: italic;
}

#opp-hand {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 2px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
#opp-hand::-webkit-scrollbar { height: 3px; }
#opp-hand::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- Center area ---- */
#center-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

#phase-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
#round-label { font-size: .75rem; color: var(--muted); }

#number-display {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 20px;
  text-align: center;
}

#number-digits {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-wrap: wrap;
}

.digit-cell {
  display: inline-block;
  width: 34px;
  height: 46px;
  line-height: 46px;
  text-align: center;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 1.8rem;
  font-weight: 800;
  transition: background .25s, color .25s;
}
.digit-cell.revealed      { color: var(--text); background: var(--surface); }
.digit-cell.hidden-digit  { color: transparent; background: var(--surface2); }
.digit-cell.new-reveal    { animation: pop-in .4s ease; color: var(--accent); }
@keyframes pop-in {
  0%   { transform: scale(1.55); color: #fff; }
  100% { transform: scale(1); }
}

/* ---- My area ---- */
#my-area {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

/* --- Normal hand + offer --- */
#normal-area {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

#my-hand, #offer-area {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 2px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
#my-hand::-webkit-scrollbar,
#offer-area::-webkit-scrollbar { height: 3px; }
#my-hand::-webkit-scrollbar-thumb,
#offer-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.offer-section-label {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 2px 8px;
  flex-shrink: 0;
}

.offer-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 8px;
  flex-shrink: 0;
}

.waiting-msg {
  padding: 4px 10px;
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
}

/* ======== CARDS ======== */
.game-card {
  width: 100px;
  height: 148px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 2px solid transparent;
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  cursor: default;
  transition: transform .15s, box-shadow .15s;
  user-select: none;
  position: relative;
}
.game-card.pickable {
  cursor: pointer;
  border-color: var(--accent);
}
.game-card.pickable:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(124,106,247,.35);
}
.game-card.activated { box-shadow: 0 0 10px 2px currentColor; }
.game-card.dragging  { opacity: .5; }
.game-card.draggable-card { cursor: grab; }
.game-card.draggable-card:active { cursor: grabbing; }

.game-card .card-rarity-bar {
  height: 3px;
  border-radius: 2px;
  margin-bottom: 1px;
  flex-shrink: 0;
}
.game-card .card-name {
  font-weight: 700;
  font-size: .78rem;
  line-height: 1.2;
  flex-shrink: 0;
}
.game-card .card-desc {
  font-size: .68rem;
  color: var(--muted);
  flex: 1;
  line-height: 1.25;
  overflow: hidden;
}
.game-card .card-meta {
  display: flex;
  justify-content: space-between;
  font-size: .66rem;
  font-weight: 600;
  flex-shrink: 0;
}
.card-cost { color: var(--red); }
.card-pts  { color: var(--green); }

.card-back {
  width: 100px;
  height: 148px;
  flex-shrink: 0;
  border-radius: 10px;
  background: repeating-linear-gradient(
    45deg,
    var(--surface2),
    var(--surface2) 7px,
    var(--surface) 7px,
    var(--surface) 14px
  );
  border: 2px solid var(--border);
}

.card-face-up-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--green);
  color: #000;
  font-size: .55rem;
  font-weight: 800;
  border-radius: 3px;
  padding: 1px 3px;
  text-transform: uppercase;
}

.card-cant-afford { opacity: .45; }

/* ======== PLACEMENT DRAG UI ======== */
#placement-ui {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 8px;
  overflow: hidden;
}

.drop-zone {
  flex: 1 1 0;
  min-height: 60px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, background .15s;
  overflow: hidden;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124,106,247,.08);
}
#zone-front { border-color: rgba(244,67,54,.35); }
#zone-front.drag-over { border-color: var(--red); background: rgba(244,67,54,.08); }
#zone-back  { border-color: rgba(33,150,243,.35); }
#zone-back.drag-over  { border-color: var(--blue); background: rgba(33,150,243,.08); }

.zone-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  flex-shrink: 0;
}
.zone-hint {
  font-weight: 400;
  font-size: .65rem;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
  color: var(--muted);
  opacity: .7;
}
.staging-label { color: var(--text); }

#placement-staging {
  flex: 0 0 auto;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.zone-cards {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  min-height: 40px;
  padding-bottom: 2px;
}
.zone-cards::-webkit-scrollbar { height: 3px; }
.zone-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.placement-waiting-msg {
  font-size: .8rem;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0;
}

/* ======== OVERLAYS ======== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 36px;
  max-width: 440px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.overlay-box h2 { font-size: 1.3rem; }

.tally-row { font-size: .95rem; padding: 5px 0; border-bottom: 1px solid var(--border); }
.tally-row:last-child { border: none; }
.tally-gain { color: var(--green); font-weight: 700; }
.tally-loss { color: var(--red);   font-weight: 700; }

/* ======== CHAT ======== */
#chat-panel {
  flex: 0 0 220px;
  width: 220px;
  min-width: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#chat-log::-webkit-scrollbar { width: 4px; }
#chat-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-msg { font-size: .78rem; line-height: 1.35; word-break: break-word; }
.chat-msg .chat-name { font-weight: 700; color: var(--accent); }
#chat-input-row { display: flex; border-top: 1px solid var(--border); flex-shrink: 0; }
#chat-input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 7px 8px;
  font-size: .82rem;
  background: var(--surface2);
  min-width: 0;
}
#btn-chat-send {
  border-radius: 0;
  padding: 7px 10px;
  font-size: .78rem;
  flex-shrink: 0;
}

/* ======== ACTIVATION FLASH ======== */
.activation-flash { animation: flash-card .7s ease; }
@keyframes flash-card {
  0%   { box-shadow: 0 0 0 0 #fff8; }
  50%  { box-shadow: 0 0 22px 8px #fff5; }
  100% { box-shadow: 0 0 10px 2px currentColor; }
}
