/* =========================================================================
   PEANUTS HOLD'EM — styles
   Late-night card room, drawn in crayon.
   ========================================================================= */

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

:root {
  --felt: #1e6b3a;
  --felt-dark: #14502a;
  --bg: #17141f;
  --panel: #221e2e;
  --panel-2: #2c2740;
  --ink: #f2eee6;
  --dim: #9c94ad;
  --accent: #ffd166;
  --danger: #ef5b5b;
  --comic: "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--comic);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------------- top bar ---------------- */

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 3px solid #000;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { height: 44px; }
.logo h1 {
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 2px 2px 0 #000;
}
.tagline { font-size: 12px; color: var(--dim); font-style: italic; }
.logo-text { display: flex; flex-direction: column; }
.topbar-right { display: flex; gap: 16px; align-items: center; font-size: 14px; color: var(--dim); }
.top-btn {
  background: var(--panel-2);
  border: 2px solid #000;
  border-radius: 8px;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
}
.top-btn.off { opacity: .45; }

/* ---------------- layout ---------------- */

#layout {
  display: flex;
  flex: 1;
  min-height: 0;
}
#table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-width: 0;
}

/* ---------------- table ---------------- */

#poker-table {
  position: relative;
  flex: 1;
  min-height: 480px;
  margin: 62px 72px 92px;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 85%);
  border-radius: 50% / 42%;
  border: 12px solid #4a2c17;
  box-shadow: 0 0 0 4px #000, inset 0 0 60px rgba(0,0,0,.45), 0 14px 30px rgba(0,0,0,.6);
}

#table-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#pot-display {
  font-size: 17px;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 1px 1px 0 #000;
  background: rgba(0,0,0,.35);
  padding: 3px 14px;
  border-radius: 14px;
}
#community-cards { display: flex; gap: 7px; }

#winner-banner {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--accent);
  color: #000;
  font-weight: bold;
  font-size: 16px;
  padding: 6px 18px;
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: 4px 4px 0 #000;
  z-index: 30;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(.6); } to { transform: translateX(-50%) scale(1); } }
.hidden { display: none !important; }

/* ---------------- cards ---------------- */

.card {
  width: 46px;
  height: 64px;
  background: #fdfaf2;
  border: 2px solid #000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: bold;
  font-family: Georgia, serif;
  box-shadow: 2px 2px 0 rgba(0,0,0,.5);
}
.card.red { color: #c0392b; }
.card.black { color: #1a1a2a; }
.card.back {
  background: repeating-linear-gradient(45deg, #b03a3a 0 6px, #8e2c2c 6px 12px);
}
.card.placeholder {
  background: rgba(255,255,255,.06);
  border: 2px dashed rgba(255,255,255,.25);
  box-shadow: none;
}
.seat-cards {
  display: flex;
  gap: 4px;
  justify-content: center;
  min-height: 52px; /* reserved even when empty so seats never shift */
  align-items: flex-end;
}
.seat-cards .card { width: 36px; height: 50px; font-size: 13px; }

/* ---------------- seats ---------------- */

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 10;
  transition: opacity .3s;
}
.seat.folded { opacity: .65; }
.seat.folded .seat-cards { visibility: hidden; }

/* seat positions: 0 = you (bottom center), clockwise */
.seat-0 { bottom: -76px; left: 50%; transform: translateX(-50%); }
.seat-1 { bottom: 6%; left: -52px; }
.seat-2 { top: 6%; left: -52px; }
.seat-3 { top: -74px; left: 50%; transform: translateX(-50%); }
.seat-4 { top: 6%; right: -52px; }
.seat-5 { bottom: 6%; right: -52px; }

.seat-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 3px solid #000;
  border-radius: 14px;
  padding: 6px 12px 6px 6px;
  box-shadow: 3px 3px 0 #000;
  width: 238px; /* fixed — content changes must never resize/re-center the seat */
}
.seat.acting .seat-box {
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent), 3px 3px 0 #000;
}
.seat-info { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.seat-name { font-size: 13px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-chips { font-size: 13px; color: var(--accent); }
.seat-status { font-size: 10px; color: var(--danger); font-weight: bold; height: 13px; overflow: hidden; }

.seat-badge {
  position: absolute;
  top: -10px; right: -10px;
  width: 24px; height: 24px;
  background: #fff;
  color: #000;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seat-bet {
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  background: rgba(0,0,0,.55);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 1px 10px;
  min-height: 20px;
}
.seat-bet:empty { visibility: hidden; } /* keeps its space so seats don't shift */

.avatar {
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #444;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-slot .avatar {
  width: 96px !important;
  height: 96px !important;
  transition: transform .15s ease-out;
  position: relative;
}
/* hover any seat portrait to admire the art up close */
.avatar-slot:hover .avatar {
  transform: scale(2.3);
  z-index: 80;
  box-shadow: 0 4px 18px rgba(0,0,0,.6);
}

/* online-player pulse dot */
.avatar-slot { position: relative; }
.avatar-slot::after {
  content: "";
  position: absolute;
  bottom: 2px; right: 2px;
  width: 12px; height: 12px;
  background: #3ddc84;
  border: 2px solid #000;
  border-radius: 50%;
  animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* speech bubbles */
.speech-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(.7);
  max-width: 230px;
  width: max-content;
  background: #fff;
  color: #111;
  font-size: 12px;
  padding: 7px 11px;
  border: 2px solid #000;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
}
.speech-bubble::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: #000;
}
.speech-bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* ---------------- action bar ---------------- */

#action-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--panel);
  border: 3px solid #000;
  border-radius: 16px;
  padding: 12px 18px;
  box-shadow: 4px 4px 0 #000;
}
#action-bar.disabled { opacity: .55; pointer-events: none; }
#action-info { font-size: 14px; color: var(--dim); min-width: 170px; }
#action-buttons { display: flex; gap: 10px; }

.act-btn {
  font-family: var(--comic);
  font-size: 15px;
  font-weight: bold;
  padding: 9px 20px;
  border: 3px solid #000;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #000;
  transition: transform .08s;
}
.act-btn:hover { transform: translate(-1px, -1px); }
.act-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.act-btn:disabled { opacity: .4; pointer-events: none; }
.act-btn.fold  { background: #777; color: #fff; }
.act-btn.check { background: #4a90d9; color: #fff; }
.act-btn.raise { background: var(--accent); color: #000; }
.act-btn.allin { background: var(--danger); color: #fff; }

#raise-controls { display: flex; align-items: center; gap: 10px; flex: 1; }
#raise-slider { flex: 1; accent-color: var(--accent); }
#raise-amount { font-weight: bold; color: var(--accent); min-width: 56px; text-align: right; }
.raise-presets { display: flex; gap: 6px; }
.raise-presets button {
  font-family: var(--comic);
  font-size: 11px;
  padding: 4px 8px;
  background: var(--panel-2);
  color: var(--ink);
  border: 2px solid #000;
  border-radius: 8px;
  cursor: pointer;
}

/* ---------------- chat panel ---------------- */

#chat-panel {
  width: 320px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 3px solid #000;
}
#chat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px;
  border-bottom: 2px solid #000;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--accent);
}
#online-count { font-size: 11px; color: var(--dim); font-weight: normal; }

#chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
}
.chat-msg { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; animation: slidein .18s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.chat-msg.sys { justify-content: center; }
.sys-text {
  font-size: 11px;
  color: var(--dim);
  font-style: italic;
  text-align: center;
}
.chat-body { display: flex; flex-direction: column; }
.chat-name { font-size: 11px; font-weight: bold; }
.chat-text { color: var(--ink); line-height: 1.35; }

/* ---------------- intro splash ---------------- */

#intro {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: radial-gradient(ellipse at center, #22303f 0%, var(--bg) 75%);
  cursor: pointer;
  transition: opacity .5s;
}
#intro.closing { opacity: 0; pointer-events: none; }

#intro-logo { animation: logo-drop 1.7s cubic-bezier(.3, .7, .4, 1) both; }
#intro-logo img { max-height: 180px; max-width: 80vw; filter: drop-shadow(6px 6px 0 #000); }
#intro-logo .intro-wordmark { display: none; }
#intro-logo.no-img img { display: none; }
#intro-logo.no-img .intro-wordmark {
  display: block;
  font-size: 64px;
  font-weight: bold;
  letter-spacing: 6px;
  line-height: 1.1;
  text-align: center;
  color: var(--accent);
  text-shadow: 4px 4px 0 #000;
}
@keyframes logo-drop {
  0%   { transform: translateY(-120vh); }
  50%  { transform: translateY(0); }
  66%  { transform: translateY(-9vh); }
  80%  { transform: translateY(0); }
  90%  { transform: translateY(-3vh); }
  100% { transform: translateY(0); }
}

.intro-tagline {
  font-size: 17px;
  font-style: italic;
  color: var(--dim);
  opacity: 0;
  animation: intro-fade .6s 1.8s forwards;
}
#intro-avatars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  animation: intro-fade .6s 2.0s forwards;
}
.intro-pick-label { font-size: 12px; letter-spacing: 3px; color: var(--dim); font-weight: bold; }
#intro-avatar-row { display: flex; gap: 12px; }
.intro-avatar {
  background: none;
  border: none;
  padding: 3px;
  cursor: pointer;
  border-radius: 50%;
  transition: transform .12s;
}
.intro-avatar:hover { transform: scale(1.15); }
.intro-avatar.picked { outline: 3px solid var(--accent); }

.intro-cta {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 2px 2px 0 #000;
  opacity: 0;
  animation: intro-fade .5s 2.3s forwards, cta-pulse 1.5s 2.9s infinite;
}
.intro-fineprint {
  position: absolute;
  bottom: 22px;
  font-size: 11px;
  font-style: italic;
  color: var(--dim);
  opacity: 0;
  animation: intro-fade .8s 2.6s forwards;
}
@keyframes intro-fade { to { opacity: 1; } }
@keyframes cta-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ---------------- toasts (cameo popups) ---------------- */

#toast-container {
  position: fixed;
  bottom: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
  max-width: 360px;
}
.toast {
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  background: var(--panel-2);
  border: 3px solid #000;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 4px 4px 0 #000;
  opacity: 0;
  transform: translateX(-24px);
  transition: opacity .35s, transform .35s;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-text { font-size: 12px; line-height: 1.4; }

/* ---------------- overlay ---------------- */

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
#overlay-card {
  background: var(--panel);
  border: 4px solid #000;
  border-radius: 18px;
  box-shadow: 8px 8px 0 #000;
  padding: 36px 44px;
  text-align: center;
  max-width: 460px;
}
#overlay-card h2 { color: var(--danger); margin-bottom: 14px; letter-spacing: 1px; }
#overlay-card p { color: var(--ink); margin-bottom: 24px; line-height: 1.5; }
#btn-restart {
  font-family: var(--comic);
  font-size: 16px;
  font-weight: bold;
  background: var(--accent);
  border: 3px solid #000;
  border-radius: 12px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #000;
}

/* ---------------- footer ---------------- */

footer {
  padding: 8px 20px;
  background: var(--panel);
  border-top: 3px solid #000;
  text-align: center;
}
footer p { font-size: 10px; color: var(--dim); font-style: italic; }

/* ---------------- responsive ---------------- */

@media (max-width: 1100px) {
  #chat-panel { width: 250px; }
}
@media (max-width: 900px) {
  #layout { flex-direction: column; }
  #chat-panel { width: 100%; height: 200px; border-left: none; border-top: 3px solid #000; }
  #poker-table { margin: 46px 46px 66px; min-height: 380px; }
  #action-bar { flex-wrap: wrap; }
}
