:root {
  --bg-dark: #13141c;
  --bg-panel: #1e202b;
  --primary: #6c5ce7;
  --msg-me: #6c5ce7;
  --msg-other: #2d3436;
  --accent-green: #00b894;
  --accent-red: #d63031;
  --text-white: #ffffff;
  --font-main: "Poppins", sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-white);
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}
.hidden {
  display: none !important;
}
.fade-in {
  animation: fadeIn 0.4s ease-in-out;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* LOGIN */
#login-screen {
  width: 90%;
  max-width: 400px;
  padding: 20px;
}
.card {
  background: var(--bg-panel);
  padding: 30px;
  border-radius: 20px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.logo i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 10px;
}
.logo h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
}
.login-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 25px;
}
.divider {
  font-size: 0.8rem;
  color: #b2bec3;
  font-weight: bold;
  margin: 5px 0;
}
input {
  width: 100%;
  background: #151720;
  border: 2px solid #2d3436;
  padding: 15px;
  border-radius: 12px;
  color: white;
  outline: none;
  font-family: var(--font-main);
  transition: 0.3s;
  font-size: 16px;
}
input:focus {
  border-color: var(--primary);
}
.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: white;
  font-family: var(--font-main);
}
.btn-primary {
  background: var(--primary);
}
.btn-secondary {
  background: var(--accent-green);
}
.private-room-group {
  display: flex;
  gap: 10px;
}

/* JOGO LAYOUT (PC FIRST) */
#game-screen {
  display: flex;
  width: 95%;
  max-width: 1200px;
  height: 90vh;
  background: var(--bg-panel);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Sidebar (PC) */
.sidebar {
  width: 220px;
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 20px;
  display: flex;
  flex-direction: column;
  z-index: 200;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.sidebar-header h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #b2bec3;
  margin: 0;
}
#room-name-display {
  color: var(--primary);
  font-weight: bold;
  text-transform: uppercase;
}
#mobile-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-family: var(--font-main);
  cursor: pointer;
  font-weight: bold;
}

#player-list {
  list-style: none;
  padding: 0;
  margin-top: 10px;
  overflow-y: auto;
  flex: 1;
}
#player-list li {
  padding: 10px;
  margin-bottom: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#player-list li .p-info {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 110px;
}
#player-list li .p-score {
  font-weight: bold;
  color: var(--accent-green);
  background: rgba(0, 184, 148, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}
#player-list li.is-master {
  border-left: 3px solid #fdcb6e;
  background: rgba(253, 203, 110, 0.1);
}

/* MEMORIA MESTRE */
#master-memory-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #fdcb6e, #fab1a0);
  color: #2d3436;
  padding: 8px;
  text-align: center;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  padding-top: 40px;
  background: radial-gradient(
    circle at top right,
    rgba(108, 92, 231, 0.05),
    transparent
  );
  position: relative;
}
#status-bar {
  text-align: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: #b2bec3;
  font-weight: bold;
}
#status-bar.your-turn {
  background: var(--primary);
  color: white;
}

#chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message {
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 80%;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
  animation: popIn 0.3s;
}
@keyframes popIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.msg-me {
  align-self: flex-end;
  background: var(--msg-me);
  color: white;
  border-bottom-right-radius: 2px;
}
.msg-other {
  align-self: flex-start;
  background: var(--msg-other);
  color: #dfe6e9;
  border-bottom-left-radius: 2px;
}
.msg-other strong {
  display: block;
  font-size: 0.7rem;
  color: #a29bfe;
  margin-bottom: 2px;
}
.msg-master {
  align-self: center;
  background: #fab1a0;
  color: #2d3436;
  font-weight: bold;
  border-radius: 20px;
  padding: 5px 20px;
  text-align: center;
  font-size: 0.9rem;
}
.msg-system {
  align-self: center;
  color: #b2bec3;
  font-size: 0.8rem;
  font-style: italic;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  padding: 5px 15px;
  text-align: center;
}
.msg-win {
  align-self: center;
  background: linear-gradient(45deg, #6c5ce7, #a29bfe);
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  width: 95%;
  text-align: center;
}
.msg-yes,
.msg-no {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 30px;
  border-radius: 50px;
  font-weight: 800;
  font-size: 1rem;
  text-transform: uppercase;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 10px 0;
}
.msg-yes {
  background: rgba(0, 184, 148, 0.15);
  color: #55efc4;
  border-color: #00b894;
}
.msg-no {
  background: rgba(214, 48, 49, 0.15);
  color: #ff7675;
  border-color: #d63031;
}

.control-bar {
  margin-top: 10px;
}
.disabled-area {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(1);
}
.active-area {
  opacity: 1;
  pointer-events: all;
  filter: grayscale(0);
  border: 2px solid var(--primary);
}
.builder-container {
  background: #2d3436;
  padding: 10px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
}
#question-template {
  background: #6c5ce7;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-family: var(--font-main);
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  outline: none;
  text-overflow: ellipsis;
}
.input-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
#variable-input {
  flex: 1;
  background: #151720;
  border: 2px solid #636e72;
  color: white;
  padding: 12px;
  border-radius: 10px;
}
#variable-input:focus {
  border-color: var(--primary);
}
#variable-input.disabled {
  background: #2d3436;
  border-color: transparent;
  color: transparent;
}
.btn-send {
  background: var(--primary);
  color: white;
  width: 50px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
}
.btn-start {
  background: var(--primary);
  color: white;
  padding: 15px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: bold;
  width: 100%;
}
.btn-start:disabled {
  background: #636e72;
  cursor: not-allowed;
  opacity: 0.7;
}
.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  height: 60px;
}
.btn-yes-action {
  background: var(--accent-green);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 1.2rem;
}
.btn-no-action {
  background: var(--accent-red);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 1.2rem;
}
.master-wait {
  text-align: center;
  color: #b2bec3;
  padding: 10px;
  font-style: italic;
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
  body {
    height: 100dvh;
    display: block;
    overflow: hidden;
  }
  #login-screen {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .card {
    border: none;
    box-shadow: none;
    background: transparent;
  }

  #game-screen {
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }

  /* Sidebar Sanfona */
  .sidebar {
    width: 100%;
    height: 60px; /* Altura fechada */
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 15px;
    background: #1e202b;
    position: absolute;
    top: 0;
    left: 0;
    transition: height 0.3s ease;
    overflow: hidden;
  }
  .sidebar.expanded {
    height: 300px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  }
  .sidebar-header {
    height: 60px;
    margin-bottom: 0;
    cursor: pointer;
  }
  #mobile-toggle-btn {
    display: inline-block;
  }

  #player-list {
    margin-top: 10px;
    padding-bottom: 10px;
  }
  .main-content {
    padding: 10px;
    padding-top: 70px;
    height: 100%;
  }

  #master-memory-bar {
    top: 60px;
    padding: 5px;
    font-size: 0.8rem;
  }
  #chat-box {
    font-size: 14px;
  }
  .builder-container {
    padding: 8px;
    border-radius: 12px 12px 0 0;
  }
  #question-template {
    font-size: 1rem;
    padding: 14px;
  }
  .btn-yes-action,
  .btn-no-action {
    height: 50px;
    font-size: 1rem;
  }
}
