:root {
  --bg-gradient: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
  --panel-glass: rgba(255, 255, 255, 0.25);
  --panel-border: rgba(255, 255, 255, 0.4);

  --text: #2D3748;
  --text-light: #5f6c80;
  --primary: #4D7BF3;
  --primary-text: #ffffff;
  --danger: #FF6B6B;
  --good: #22C55E;

  /* Deep, crisp shadows for glass depth */
  --shadow-glass:
    8px 8px 16px 0 rgba(0, 0, 0, 0.15),
    -4px -4px 12px 0 rgba(255, 255, 255, 0.3);

  --shadow-in:
    inset 4px 4px 8px rgba(0, 0, 0, 0.1),
    inset -4px -4px 8px rgba(255, 255, 255, 0.2);

  --glass-blur: blur(16px);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Nunito', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  /* Keep background still while scrolling */
  min-height: 100vh;
  color: var(--text);
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* Glass Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-weight: 800;
  font-size: 1.4rem;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status {
  margin-left: auto;
  color: #fff;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.1);
  padding: 6px 16px;
  border-radius: 50px;
  backdrop-filter: blur(4px);
}

.container {
  padding: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Glass Panels */
.panel {
  background: var(--panel-glass);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow-glass);
  border: 1px solid var(--panel-border);
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Glass Inputs */
input {
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
  /* Slightly clearer */
  color: #333;
  box-shadow: var(--shadow-in);
  outline: none;
  font-size: 1rem;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

input:focus {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.1);
  border-color: #fff;
}

/* Glass Buttons */
button {
  padding: 12px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.25);
  color: #333;
  cursor: pointer;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow-glass);
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.15), -5px -5px 15px rgba(255, 255, 255, 0.4);
}

button:active {
  transform: translateY(0);
  box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.1);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Primary Gradient Button */
button.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  box-shadow: 6px 6px 15px rgba(118, 75, 162, 0.4);
}

button.primary:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  box-shadow: 8px 8px 18px rgba(118, 75, 162, 0.5);
}

/* Danger Button */
button.danger {
  background: rgba(255, 99, 99, 0.15);
  color: #d32f2f;
  border-color: rgba(255, 99, 99, 0.3);
}

button.danger:hover {
  background: rgba(255, 99, 99, 0.3);
  color: #b71c1c;
}

.actions {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  justify-content: flex-end;
}

.hint {
  color: var(--text-light);
  margin-top: 14px;
  font-size: 14px;
  text-align: center;
  font-weight: 600;
}

/* Lists */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list li {
  padding: 14px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--text);
}

/* Game Layout */
.gameTop {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

@media (max-width: 800px) {
  .gameTop {
    grid-template-columns: 1fr;
  }
}

.cardInfo {
  background: var(--panel-glass);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2), var(--shadow-glass);
  border: 1px solid var(--panel-border);
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  min-height: 440px;
  justify-content: center;
  position: relative;
}

/* Glass Cards */
.card {
  width: 140px;
  height: 200px;
  border-radius: 20px;
  /* Glassy Card Look */
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 8px 32px 0 rgba(31, 38, 135, 0.15);

  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 3rem;
  color: #333;
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

.card.big {
  width: 180px;
  height: 260px;
  font-size: 4rem;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.2);
}

/* Meta info */
.meta {
  position: absolute;
  top: 24px;
  left: 24px;
  text-align: left;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta div {
  background: rgba(255, 255, 255, 0.3);
  padding: 8px 14px;
  border-radius: 12px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Player Sidebar */
.playersInfo {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Hand Area */
.handArea {
  margin-top: 24px;
  padding: 30px;
  background: var(--panel-glass);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-glass);
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  padding: 10px;
}

.card.small {
  width: 100px;
  height: 150px;
  font-size: 2rem;
  cursor: pointer;
}

.card.small:hover {
  transform: translateY(-15px) scale(1.05);
  z-index: 10;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.card.playable {
  border: 2px solid var(--good);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
}

.card.disabled {
  opacity: 0.5;
  filter: grayscale(0.8);
  cursor: default;
  transform: none;
}

/* Color Picker */
.colorPicker {
  background: rgba(255, 255, 255, 0.3);
  padding: 20px;
  border-radius: 20px;
  box-shadow: var(--shadow-glass);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.colors {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
}

.colors button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.2);
}

.cR {
  background: #FF6B6B !important;
}

.cY {
  background: #FFD93D !important;
}

.cG {
  background: #6BCB77 !important;
}

.cB {
  background: #4D96FF !important;
}

/* Log / Chat Bubbles */
.logArea {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.log {
  padding: 16px;
  /* Deep inset for log area */
  background: rgba(0, 0, 0, 0.03);
  border-radius: 16px;
  box-shadow: inset 2px 2px 6px rgba(0, 0, 0, 0.1);
  height: 300px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.log li {
  background: transparent;
  box-shadow: none;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  max-width: 85%;
  line-height: 1.4;
  word-wrap: break-word;
  font-weight: 600;
}

.log-system {
  align-self: center;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
  color: #555;
  font-size: 0.8rem;
  border-radius: 50px;
  padding: 4px 20px !important;
}

.log-me {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 4px 4px 8px rgba(118, 75, 162, 0.3);
}

.log-me .log-time {
  color: rgba(255, 255, 255, 0.8);
}

.log-other {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
}

.log-time {
  display: block;
  font-size: 0.7rem;
  margin-bottom: 2px;
  text-align: right;
  opacity: 0.7;
}

/* Lobby Chat */
.chatSection {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
}

.chatHeader {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chatHint {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
}

.chatLog {
  height: 220px;
  max-height: 220px;
}

.chatComposer {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.chatComposer input {
  flex: 1;
  min-width: 220px;
}

/* Modal */
.modalBackdrop {
  background: rgba(45, 55, 72, 0.6);
  backdrop-filter: blur(8px);
}

.qrWrap {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  padding: 20px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: var(--shadow-in);
}

.qrWrap img {
  width: 250px;
  height: 250px;
  mix-blend-mode: multiply;
  /* Helps blend QR if it has white bg */
  opacity: 0.9;
}

/* Toast */
.toast {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50px;
  padding: 16px 32px;
  backdrop-filter: blur(10px);
}

/* Checkbox Toggle */
input[type="checkbox"] {
  appearance: none;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.1);
  border-radius: 24px;
  position: relative;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
}

input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.3s;
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

input[type="checkbox"]:checked::after {
  left: 22px;
}

/* Global Chat Drawer */
.chat-drawer {
  position: fixed;
  top: 80px;
  /* Below topbar */
  right: 20px;
  bottom: 20px;
  width: 320px;
  background: rgba(255, 255, 255, 0.85);
  /* Slightly more opaque for readability */
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
  padding: 20px;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-drawer.collapsed {
  transform: translateX(120%);
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Chat Bubbles */
.chatLog {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  /* Stack messages top to bottom */
  gap: 12px;
  background: #f5f7fa;
  /* Light grey background for chat area */
  border-radius: 12px;
  margin-top: 10px;
  list-style: none;
  /* Remove default bullets */
}

.chatLog li {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  color: #000;
  /* Default black text */
  list-style: none;
  /* Ensure no bullets on items */
}

/* My messages (Right) */
.chatLog .log-me {
  align-self: flex-end;
  background: #dcf8c6;
  /* WhatsApp style green or custom */
  background: linear-gradient(135deg, #a8ff78 0%, #78ffd6 100%);
  color: #000;
  /* Force black text */
  border-bottom-right-radius: 4px;
}

/* Other messages (Left) */
.chatLog .log-other {
  align-self: flex-start;
  background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
  /* Blue gradient */
  color: #000;
  border-bottom-left-radius: 4px;
}

/* System messages (Center) */
.chatLog .log-system {
  align-self: center;
  background: rgba(0, 0, 0, 0.1);
  color: #333;
  /* Dark grey for system */
  font-size: 0.8rem;
  border-radius: 50px;
  padding: 4px 12px;
  box-shadow: none;
  max-width: 90%;
}

.log-time {
  font-size: 0.7rem;
  color: #000 !important;
  /* Strictly Force black time text */
  margin-bottom: 4px;
  display: block;
  opacity: 0.8;
}

.chatComposer {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}

.chatComposer input {
  flex: 1;
  min-width: 0;
  /* Allow shrinking */
}

@media (max-width: 600px) {
  .chat-drawer {
    width: 90%;
    right: 5%;
  }
}