:root {
  --primary-bg: #12141d;
  --panel-bg: rgba(30, 32, 44, 0.85);
  --table-felt: radial-gradient(ellipse at center, #1b5e20 0%, #0a330e 100%);
  --table-rail: #2a1b14;
  --accent-gold: #ffd700;
  --accent-green: #00c853;
  --accent-blue: #2962ff;
  --accent-red: #d50000;
  --text-main: #ffffff;
  --text-muted: #9aa0a6;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--primary-bg);
  background-image: radial-gradient(circle at top, #2b2f42, var(--primary-bg));
  color: var(--text-main);
  font-family: "Montserrat", sans-serif;
  overflow: hidden;
}

/* Login & Lobby */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
}
.logo {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 2rem;
  background: linear-gradient(135deg, var(--accent-gold), #ffaa00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  letter-spacing: 2px;
}
#login-screen input {
  padding: 15px 25px;
  font-size: 18px;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: var(--panel-bg);
  color: white;
  margin-bottom: 15px;
  width: 300px;
  text-align: center;
  outline: none;
  transition: all 0.3s;
}
#login-screen input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}
#login-screen button {
  padding: 15px 40px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 50px;
  border: none;
  background: linear-gradient(135deg, var(--accent-green), #009624);
  color: white;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 200, 83, 0.3);
  transition: all 0.2s;
}
#login-screen button:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 25px rgba(0, 200, 83, 0.4);
}

#lobby-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  height: 100dvh;
  box-sizing: border-box;
  overflow-y: auto;
}
#lobby-header {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 30px;
  color: var(--accent-gold);
}
#room-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 600px;
}
.room-card {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  padding: 25px;
  border-radius: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-left: 6px solid var(--accent-gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease;
}
.room-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
}
.room-info h3 {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  font-weight: 700;
}
.room-info p {
  margin: 5px 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}
.highlight-text {
  color: white;
}
.join-room-btn {
  padding: 12px 25px;
  background: linear-gradient(135deg, var(--accent-blue), #1565c0);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(41, 98, 255, 0.3);
  transition: all 0.2s;
}
.join-room-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.1);
}
.join-room-btn:disabled {
  background: #444;
  color: #888;
  cursor: not-allowed;
}

/* Game Screen */
#game-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
}
#game-header {
  background: var(--panel-bg);
  backdrop-filter: blur(5px);
  padding: 15px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 50;
}

/* Header Controls */
.header-left {
  display: flex;
  gap: 10px;
  align-items: center;
}
#btn-leave {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
  padding: 8px 15px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
#btn-leave:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.chat-toggle-btn {
  display: none; 
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold);
  padding: 8px 15px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-toggle-btn:hover {
  background: rgba(255, 215, 0, 0.1);
}

#room-title {
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 1px;
}

#table {
  flex: 1;
  background: var(--table-felt);
  border-radius: 140px;
  margin: 3vh 5vw;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.8),
    0 20px 50px rgba(0, 0, 0, 0.9);
  border: 20px solid var(--table-rail);
  border-bottom-color: #1a0f0a;
  border-top-color: #3b281f;
}
#pot-display {
  font-size: 1.2rem;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 25px;
  border-radius: 30px;
  margin-bottom: 20px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 10;
  color: var(--accent-gold);
}
#announcer {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 15, 20, 0.9);
  border: 2px solid var(--accent-gold);
  padding: 20px 40px;
  border-radius: 15px;
  z-index: 100;
  text-align: center;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.winner-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-gold);
  margin-bottom: 10px;
}
.next-hand {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}
#community-cards {
  display: flex;
  gap: 12px;
  z-index: 10;
}

/* Cards */
@keyframes dealCard {
  0% {
    transform: translateY(-80px) scale(0.1) rotate(-180deg);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1) rotate(0);
    opacity: 1;
  }
}
.card {
  width: 65px;
  height: 95px;
  background: #ffffff;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 2px 5px 15px rgba(0, 0, 0, 0.6);
  border: 1px solid #ddd;
  animation: dealCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
  position: relative;
  font-family: "Arial", sans-serif;
}
.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 5px;
  line-height: 1;
}
.bottom-corner {
  transform: rotate(180deg);
}
.card-rank {
  font-size: 18px;
  font-weight: bold;
}
.card-suit-small {
  font-size: 14px;
}
.card-suit-large {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 45px;
  opacity: 0.15;
}
.card.hidden {
  background: repeating-linear-gradient(
    45deg,
    #1565c0,
    #1565c0 10px,
    #0d47a1 10px,
    #0d47a1 20px
  );
  border: 2px solid #fff;
}
.card.hidden * {
  display: none;
}
.card.red {
  color: var(--accent-red);
}
.card.black {
  color: #222;
}

/* Opponents & Avatars */
#opponents {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
  transition: all 0.5s ease;
}
.avatar-circle {
  width: 65px;
  height: 65px;
  background: linear-gradient(135deg, #3a3f58, #222533);
  border-radius: 50%;
  border: 3px solid #555;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  transition: all 0.3s ease;
}
.avatar-initial {
  font-size: 26px;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
.avatar-circle.is-turn {
  border-color: var(--accent-gold);
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
  transform: scale(1.1);
}
.avatar-circle.is-ready {
  border-color: var(--accent-green);
}
.avatar-circle.is-folded {
  opacity: 0.4;
  filter: grayscale(100%);
}

.seat-timer-container {
  position: absolute;
  bottom: -12px;
  width: 80%;
  height: 6px;
  background: #222;
  border-radius: 4px;
  overflow: hidden;
  display: none;
  border: 1px solid #000;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
}
.seat-timer-bar {
  height: 100%;
  background: var(--accent-green);
  width: 100%;
  transform-origin: left;
  transition: background-color 0.3s;
}
.avatar-circle.is-turn .seat-timer-container {
  display: block;
}

@keyframes winnerPulse {
  0% {
    box-shadow: 0 0 15px var(--accent-gold);
    border-color: var(--accent-gold);
  }
  50% {
    box-shadow:
      0 0 35px var(--accent-gold),
      inset 0 0 15px var(--accent-gold);
    border-color: #fff;
  }
  100% {
    box-shadow: 0 0 15px var(--accent-gold);
    border-color: var(--accent-gold);
  }
}
.is-winner {
  animation: winnerPulse 1.5s infinite;
  border: 3px solid var(--accent-gold) !important;
}
.is-my-turn {
  border: 1px solid var(--accent-gold) !important;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.avatar-status {
  position: absolute;
  bottom: -8px;
  background: #111;
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid #444;
  white-space: nowrap;
}
.seat-info {
  background: rgba(0, 0, 0, 0.75);
  padding: 6px 10px;
  border-radius: 8px;
  margin-top: 15px;
  text-align: center;
  min-width: 70px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.seat-name {
  font-size: 11px;
  font-weight: 700;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}
.seat-chips {
  font-size: 13px;
  color: var(--accent-green);
  font-weight: 800;
  margin-top: 2px;
}
.seat-bet-tag {
  position: absolute;
  top: -25px;
  background: linear-gradient(135deg, var(--accent-gold), #ffaa00);
  color: #000;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 12px;
  display: none;
  z-index: 25;
}

.speech-bubble {
  position: absolute;
  bottom: 115%;
  background: white;
  color: black;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  transition:
    opacity 0.2s,
    transform 0.2s;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  z-index: 20;
}
.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 5px 0;
  border-style: solid;
  border-color: white transparent transparent transparent;
}
.speech-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Chat Panel */
#chat-panel {
  position: absolute;
  top: 80px;
  left: 20px;
  width: 300px;
  height: 350px;
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  font-size: 0.85rem;
  line-height: 1.4;
  color: #ddd;
  word-wrap: break-word;
}
.chat-msg.system-msg {
  color: var(--accent-gold);
  font-style: italic;
}
#chat-form {
  display: flex;
  background: rgba(0, 0, 0, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0 0 12px 12px;
}
#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 15px;
  color: white;
  font-family: "Montserrat", sans-serif;
  outline: none;
}
#chat-send-btn {
  background: transparent;
  border: none;
  color: var(--accent-gold);
  font-size: 1.2rem;
  padding: 0 15px;
  cursor: pointer;
  transition: color 0.2s;
}
#chat-send-btn:hover {
  color: white;
}

/* Dashboard */
#dashboard {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  z-index: 50;
}
.dashboard-left {
  display: flex;
  align-items: center;
  gap: 30px;
}
.dashboard-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}
.my-status-box {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.4);
  padding: 15px 25px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.my-name {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.my-chips {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}
.my-bet {
  color: var(--accent-gold);
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 5px;
}
#my-cards {
  display: flex;
  gap: 15px;
}
#my-cards .card {
  transform: scale(1.1);
  transform-origin: bottom left;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  width: 100%;
  max-width: 600px;
  justify-content: flex-end;
}
.action-btn {
  padding: 15px 20px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  text-transform: uppercase;
  transition:
    transform 0.1s,
    filter 0.2s;
  font-family: "Montserrat", sans-serif;
}
.action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.2);
}
.action-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.btn-fold {
  background: linear-gradient(135deg, var(--accent-red), #9b0000);
  flex: 1;
}
.btn-check {
  background: linear-gradient(135deg, var(--accent-blue), #1565c0);
  flex: 1.5;
}
.btn-raise {
  background: linear-gradient(135deg, var(--accent-green), #009624);
  padding: 15px 30px;
}
.ready-go {
  background: linear-gradient(135deg, var(--accent-green), #009624);
  width: 100%;
  max-width: 400px;
  padding: 20px;
}
.ready-cancel {
  background: linear-gradient(135deg, var(--accent-red), #9b0000);
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

#raise-container {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 5px;
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
}
.raise-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}
.raise-header span:first-child {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 800;
}
#raise-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-gold);
}

input[type="range"] {
  -webkit-appearance: none;
  flex: 1;
  background: transparent;
}
input[type="range"]:focus {
  outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  cursor: pointer;
  background: #333;
  border-radius: 5px;
}
input[type="range"]::-webkit-slider-thumb {
  border: 2px solid #fff;
  height: 24px;
  width: 24px;
  border-radius: 50%;
  background: var(--accent-green);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -9px;
  box-shadow: 0 0 10px rgba(0, 200, 83, 0.8);
}

@media (max-width: 900px) {
  .chat-toggle-btn {
    display: block;
  }
  #chat-panel {
    display: none; 
    position: absolute;
    top: 70px;
    left: 5%;
    width: 90%;
    height: 40vh;
    z-index: 1000;
    box-shadow: 0 10px 50px rgba(0,0,0,0.9);
    pointer-events: auto;
  }
  #chat-panel.show-mobile {
    display: flex;
  }
  #dashboard {
    flex-direction: column;
    padding: 15px;
  }
  .dashboard-left {
    width: 100%;
    justify-content: space-between;
    align-items: flex-end;
  }
  .dashboard-right {
    width: 100%;
    margin-top: 15px;
  }
  #my-cards .card {
    transform: scale(0.8);
    transform-origin: center right;
  }
  #my-cards {
    gap: 5px;
  }
  #table {
    margin: 8vh 2vw 2vh 2vw; 
    border-width: 8px;
  }
  .seat {
    transform: translate(-50%, -50%) scale(0.85); 
  }
  #btn-leave {
    padding: 8px 10px;
    font-size: 12px;
  }
  .chat-toggle-btn {
    padding: 8px 10px;
    font-size: 12px;
  }
  #room-title {
    font-size: 14px;
  }
  .my-status-box {
    padding: 10px 15px;
  }
}