* {
  box-sizing: border-box;
}

:root {
  --blue-bg: #0a61ff;
  --blue-dark: #0a3d99;
  --blue-panel: #114fc7;
  --yellow: #f7c948;
  --yellow-dark: #e0a91d;
  --white: #ffffff;
  --text: #1e2a39;
  --muted: #7a8699;
  --line: #c8d3df;
  --soft-bg: #f3f4f6;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  color: var(--text);
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 20px 20px, rgba(255,255,255,0.08) 2px, transparent 2px),
    radial-gradient(circle at 80px 60px, rgba(255,255,255,0.05) 3px, transparent 3px),
    linear-gradient(180deg, #0f68ff 0%, #0b58ea 100%);
  background-size: 120px 120px, 160px 160px, auto;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

/* Landing */

.landing-card {
  max-width: 460px;
  margin: 60px auto;
  background: #ffffff;
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.landing-card h1 {
  margin: 0 0 8px;
  color: var(--blue-dark);
}

.landing-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
}

.landing-group {
  margin-bottom: 14px;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

.text-input,
.chat-input {
  width: 100%;
  border: 3px solid #97a3b6;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
  background: #fff;
}

.text-input:focus,
.chat-input:focus {
  border-color: var(--blue-bg);
}

.primary-btn,
.small-btn,
.chat-send-btn {
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.15s ease;
}

.primary-btn {
  background: var(--yellow);
  color: var(--blue-dark);
  padding: 14px 18px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);
}

.primary-btn:hover,
.small-btn:hover,
.chat-send-btn:hover {
  transform: translateY(-1px);
}

.full-btn {
  width: 100%;
}

.landing-error {
  min-height: 20px;
  color: #c62828;
  margin: 10px 0 0;
}

/* Main game layout */

.game-ui {
  display: grid;
  grid-template-columns: 370px 1fr;
  gap: 14px;
  align-items: stretch;
}

.sidebar-card,
.board-card,
.chat-card {
  background: #f4f4f4;
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(255,255,255,0.35);
}

.sidebar-card {
  height: calc(100vh - 36px);
  overflow: hidden;
}

.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 6px 10px 10px;
}

.sidebar-scroll::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 10px;
}

.sidebar-scroll::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: #b7c5d3;
  border-radius: 999px;
}

/* leaderboard player */

.player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid #bcc7d4;
  min-height: 92px;
}

.player-rank-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
  border: 3px solid var(--blue-dark);
}

.player-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe57a 0%, #ffca28 100%);
  border: 5px solid var(--blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  flex-shrink: 0;
  overflow: hidden;
}

.player-avatar.you {
  background: linear-gradient(180deg, #fff59d 0%, #fbc02d 100%);
}

.player-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-name {
  font-size: 20px;
  font-weight: 800;
  color: #6c737f;
  line-height: 1.1;
  word-break: break-word;
}

.player-name.active {
  color: #1b63e0;
}

.player-score {
  font-size: 16px;
  font-weight: 800;
  color: var(--blue-dark);
}

.player-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: #68768a;
  font-weight: 700;
}

.status-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c7ccd3;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
}

.status-dot.host {
  background: #ffd54f;
}

.status-dot.guessed {
  background: #f57c00;
}

.status-dot.drawer {
  background: #43a047;
}

/* main area */

.main-area {
  display: grid;
  grid-template-rows: auto 230px;
  gap: 14px;
  min-height: calc(100vh - 36px);
}

.board-card {
  position: relative;
  padding: 12px 12px 10px;
  overflow: hidden;
}

.board-top-icons {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2px 2px 8px;
}

.left-icons,
.right-icons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  background: transparent;
  font-size: 28px;
  cursor: pointer;
  color: #838d9b;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 0 8px 10px;
  color: #4a5668;
  font-size: 14px;
  font-weight: 700;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 8px 10px;
}

.draw-tools,
.action-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.small-btn {
  background: var(--blue-dark);
  color: white;
  padding: 10px 16px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.18);
}

.board-wrap {
  position: relative;
  background: #efefef;
  border-radius: 18px;
  overflow: hidden;
  min-height: 500px;
}

#board {
  width: 100%;
  height: 500px;
  display: block;
  background: #efefef;
  border-radius: 18px;
}

.board-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 800;
  color: rgba(0,0,0,0.04);
  pointer-events: none;
  user-select: none;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.04);
}

.progress-track {
  margin: 12px auto 0;
  width: calc(100% - 80px);
  height: 18px;
  background: #0f3b97;
  border-radius: 999px;
  padding: 3px;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: var(--yellow);
  border-radius: 999px;
  transition: width 0.4s linear;
}

/* chat panels */

.chat-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chat-card {
  position: relative;
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-title-pill {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue-panel);
  color: white;
  padding: 10px 34px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 12px rgba(0,0,0,0.16);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: transparent;
  padding: 4px 6px 10px;
  min-height: 110px;
}

.msg {
  padding: 6px 4px;
  font-size: 18px;
  line-height: 1.35;
  color: #7a808a;
  word-break: break-word;
}

.msg.system {
  color: #1e73e8;
  font-weight: 700;
}

.msg.correct {
  color: #0b57d0;
  font-weight: 800;
}

.msg.talk {
  color: #6d7582;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #cbd5df;
}

.chat-input {
  font-size: 18px;
  font-weight: 700;
  color: #596273;
  background: #f8f8f8;
}

.chat-send-btn {
  background: var(--yellow);
  color: var(--blue-dark);
  padding: 13px 12px;
  font-size: 15px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);
}

/* responsive */

@media (max-width: 1100px) {
  .game-ui {
    grid-template-columns: 1fr;
  }

  .sidebar-card {
    height: auto;
  }

  .main-area {
    min-height: auto;
  }
}

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

  .board-wrap,
  #board {
    min-height: 360px;
    height: 360px;
  }

  .board-watermark {
    font-size: 42px;
  }

  .toolbar-row,
  .room-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}