@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --bg: #f0f4f8;
  --panel: #ffffff;
  --panel-soft: #f7f8fb;
  --accent: #3b82f6;
  --accent-2: #a78bfa;
  --ink: #1e293b;
  --muted: #64748b;
  --danger: #ef4444;
  --good: #22c55e;
  --shadow: rgba(0, 0, 0, 0.08);
  --border: #cbd5e1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.glow {
  display: none;
}

#app {
  position: relative;
  z-index: 1;
  padding: 24px clamp(16px, 3vw, 40px) 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.logo {
  font-family: 'Bungee', cursive;
  font-size: 32px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ff6b35, #ff3e7a, #a855f7, #3b82f6);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(2px 3px 0px rgba(0, 0, 0, 0.15));
  transition: background-position 0.4s ease;
}

.logo:hover {
  background-position: 100% center;
}

.tag {
  font-family: 'Bungee', cursive;
  font-size: 18px;
  color: #a855f7;
  letter-spacing: 0.5px;
  display: inline-block;
  align-self: baseline;
}

.status {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  background: var(--panel);
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.topbar-tagline {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 4px 16px var(--shadow);
}

/* ---------- Lobby 2-column layout ---------- */

.lobby-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 56px;
  align-items: start;
}

.lobby-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 180px;
}

.lobby-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.identity-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 4px;
}

/* Speech-bubble name input */
.name-bubble {
  position: relative;
  flex: 1;
}

.name-bubble input {
  width: 100%;
  padding: 10px 14px;
  border: 3px solid #333;
  border-radius: 999px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  outline: none;
  box-sizing: border-box;
}

.name-bubble input::placeholder {
  color: #aaa;
}

.name-bubble-tail {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #333;
}

.name-bubble-tail::after {
  content: '';
  position: absolute;
  top: -12px;
  left: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #fff;
}

/* Globe language selector */
.lang-bubble {
  display: flex;
  align-items: center;
  border: 3px solid #333;
  border-radius: 999px;
  background: #fff;
  padding: 0 4px 0 10px;
  gap: 4px;
  flex-shrink: 0;
}

.lang-globe {
  font-size: 18px;
  line-height: 1;
}

.lang-bubble select {
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  padding: 10px 4px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23333'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

/* ---------- Lobby Tabs ---------- */

.lobby-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  padding: 0 8px;
  position: relative;
  z-index: 1;
}

/* bottom border line that tabs sit on */
.lobby-tabs::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
  z-index: -2;
}

.lobby-tab {
  flex: 1;
  padding: 12px 18px;
  border: none;
  background: transparent;
  color: #8b97a8;
  font-size: 16px;
  font-weight: 400;
  font-family: 'Bungee', cursive;
  letter-spacing: 0.5px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.2s ease, transform 0.15s ease;
}

/* trapezoid shape via perspective */
.lobby-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: -6px;
  right: -6px;
  bottom: -1px;
  border-radius: 14px 14px 0 0;
  border: 2px solid transparent;
  border-bottom: none;
  background: transparent;
  transform: perspective(8px) rotateX(1.2deg);
  transform-origin: bottom center;
  z-index: -1;
  transition: all 0.2s ease;
}

.lobby-tab:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.lobby-tab:hover::before {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.15);
}

.lobby-tab.active {
  color: #fff;
  z-index: 2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.lobby-tab.active::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 -3px 14px rgba(59, 130, 246, 0.3);
}

.tab-content.hidden {
  display: none;
}

/* ---------- Settings Panel ---------- */

.settings-panel {
  max-width: 480px;
  padding: 8px 0;
}

.settings-panel h3 {
  margin: 18px 0 10px 0;
  font-size: 16px;
  font-weight: 700;
}

.settings-panel h3:first-child {
  margin-top: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.settings-row label {
  min-width: 120px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.settings-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.settings-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

#volume-value {
  min-width: 38px;
  font-size: 13px;
  color: var(--muted);
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
}

.shortcuts-table td {
  padding: 6px 10px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.shortcuts-table td:first-child {
  width: 70px;
}

.shortcuts-table kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 2px solid #ccc;
  border-radius: 5px;
  background: #f5f5f5;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 0 #999;
}

/* ---------- Lobbies Tab ---------- */

.public-rooms-inner {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rooms-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

#rooms-lang-select {
  min-width: 170px;
}

.no-rooms-msg {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 0;
}

/* ---------- Play button ---------- */

.play-btn {
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 36px;
  border: 3px solid #1e40af;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 0 #1e40af;
  transition: transform 0.1s, box-shadow 0.1s;
  width: auto;
  align-self: center;
}

.play-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1e40af;
}

.play-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1e40af;
}

.quick-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.free-draw-btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 12px 24px;
  border: 3px solid #b45309;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: #f59e0b;
  box-shadow: 0 4px 0 #b45309;
  transition: transform 0.1s, box-shadow 0.1s;
}

.free-draw-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #b45309;
}

.free-draw-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b45309;
}

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

.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card.compact {
  padding: 12px;
  gap: 8px;
}

.card h2 {
  margin: 0;
  font-size: 18px;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin: -4px 0 0;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-row input {
  flex: 1;
  min-width: 0;
}

.join-row .action-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1px 0;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-transform: lowercase;
}

.create-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.create-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.create-field-label {
  font-size: 13px;
  color: var(--muted);
  width: 72px;
  flex-shrink: 0;
}

.create-field select,
.create-field input,
.create-field textarea {
  flex: 1;
  min-width: 0;
}

.create-field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.35;
}

.create-field-top {
  align-items: flex-start;
}

.create-row {
  display: flex;
  gap: 8px;
}

.create-row select {
  flex: 1;
  min-width: 0;
}

.create-btn-style {
  width: 100%;
  background: var(--good);
  border-color: #15803d;
  color: #fff;
  box-shadow: 0 3px 0 #15803d;
}

.create-btn-style:hover {
  box-shadow: 0 5px 0 #15803d;
  transform: translateY(-2px);
}

.advanced-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-align: left;
  font-family: inherit;
  transition: color 0.15s;
}

.advanced-toggle:hover {
  color: var(--ink);
}

.advanced-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.private-create-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.private-create-options .create-field-label {
  padding-top: 9px;
}

.create-inline-check {
  color: var(--ink);
  font-size: 13px;
  gap: 8px;
}

.create-inline-check input {
  margin: 0;
}

.create-help {
  margin-left: 82px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

/* ---------- Avatar Editor ---------- */

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 4px;
}

.avatar-arrows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.arrow-btn {
  width: 32px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 22px;
  color: var(--muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  padding: 0;
}

.arrow-btn:hover {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.avatar-preview-wrap {
  position: relative;
}

.avatar-preview {
  width: 200px;
  height: 200px;
  border-radius: 22px;
  border: 2px solid var(--border);
  background: var(--panel-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: avatar-pulse 2.5s ease-in-out infinite;
}

@keyframes avatar-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }
}

.avatar-preview svg {
  width: 188px;
  height: 188px;
  display: block;
}

.avatar-dice {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.avatar-dice:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

@media (max-width: 640px) {
  .lobby-layout {
    grid-template-columns: 1fr;
  }

  .lobby-left {
    align-items: center;
  }

  .avatar-controls {
    width: auto;
  }

  .avatar-preview {
    width: 100px;
    height: 100px;
  }

  .avatar-preview svg {
    width: 92px;
    height: 92px;
  }

  .create-help {
    margin-left: 0;
  }
}

/* ---------- Public Rooms ---------- */

.public-rooms {
  margin-top: 20px;
}

.public-rooms h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.room-card {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.room-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.room-card-code {
  font-weight: 700;
  font-size: 15px;
}

.room-card-meta {
  font-size: 12px;
  color: var(--muted);
}

.room-card-draw {
  font-size: 12px;
  color: var(--muted);
}

.room-card-players {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

button.small {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

input,
select,
button {
  font-family: inherit;
}

input,
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--ink);
}

button {
  background: var(--accent);
  border: 2px solid #1e40af;
  color: #fff;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 #1e40af;
}

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

button.secondary {
  background: var(--panel-soft);
  color: var(--ink);
  border: 2px solid var(--border);
}

.hidden {
  display: none !important;
}

#game {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) minmax(260px, 280px);
  gap: 12px;
}

.player-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-sidebar .scorecard {
  flex: 1;
}

.center {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-save-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--muted);
  transition: color 0.2s;
}

.hud-save-btn:hover {
  color: var(--accent);
}

.word-banner {
  background: #eef2ff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 2px 16px;
  text-align: center;
  position: relative;
}

.word-hero {
  font-family: 'Bungee', cursive;
  font-size: clamp(18px, 2.4vw, 26px);
  letter-spacing: 4px;
  color: var(--ink);
  text-shadow: none;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.word-hero.free-draw-hint {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: normal;
  color: var(--accent-2);
}

.char-count {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 2px;
  margin-left: 12px;
}

.waiting-word {
  font-family: 'Inter', sans-serif;
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 1px;
  animation: waitPulse 2s ease-in-out infinite;
}

.waiting-dots {
  /* dots animated by JS interval */
}

@keyframes waitPulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

.hud {
  display: flex;
  gap: 6px;
}

.hud-block {
  flex: 1;
  background: var(--panel);
  border-radius: 10px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  max-width: 16px;
  max-height: 16px;
  color: var(--muted);
  flex-shrink: 0;
  overflow: hidden;
}

.hud-block .label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.hud-timer {
  border-color: var(--accent);
}

.hud-timer>div:not(.label) {
  font-weight: 700;
  color: var(--accent);
}

.canvas-shell {
  position: relative;
  background: #f8fafc;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(15, 23, 42, 0.1);
  min-height: 450px;
  flex: 1;
  min-width: 0;
}

.canvas-reactions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 5;
  pointer-events: auto;
}

.canvas-react-btn {
  background: rgba(255, 255, 255, 0.5);
  border: 1.5px dashed rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.15s, background 0.2s, border-color 0.2s;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-react-btn:hover {
  opacity: 0.85;
  transform: scale(1.1);
}

.canvas-react-btn.active {
  opacity: 1;
  border-style: solid;
}

.canvas-react-btn.like.active {
  background: rgba(45, 106, 79, 0.15);
  border-color: #2d6a4f;
}

.canvas-react-btn.dislike.active {
  background: rgba(139, 26, 26, 0.15);
  border-color: #8b1a1a;
}

.canvas-react-btn.bounce {
  animation: reactBounce 0.5s ease;
}

@keyframes reactBounce {
  0% {
    transform: scale(1);
  }

  30% {
    transform: scale(1.5);
  }

  50% {
    transform: scale(0.85);
  }

  70% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
  }
}

.canvas-area {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  align-items: stretch;
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  background: #ffffff;
  cursor: crosshair;
  touch-action: none;
}

#board.pencil-cursor {
  cursor: none;
}

.draw-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 32px;
  height: 32px;
  z-index: 6;
  pointer-events: none;
  will-change: transform;
  transform: translate(-9999px, -9999px);
  background: url('/assets/pencil-cursor.svg?v=20260225-cursor2') center center / contain no-repeat;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
  color: #fff;
  background: rgba(30, 41, 59, 0.88);
  backdrop-filter: blur(6px);
}

.canvas-overlay .title {
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-size: 14px;
  color: rgba(148, 163, 184, 0.95);
  margin-bottom: 10px;
}

.canvas-overlay .body {
  font-size: 16px;
  line-height: 1.35;
}

.canvas-overlay code {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: rgba(242, 246, 255, 0.95);
}

.modal {
  position: absolute;
  inset: 20% 20%;
  background: var(--panel);
  z-index: 10;
  border-radius: 16px;
  border: 2px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 8px 32px var(--shadow);
}

#round-gallery.modal {
  inset: 10% 14%;
  justify-content: flex-start;
}

.mini-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-grid img {
  width: 100%;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--panel-soft);
}

#word-choices.modal {
  inset: 15% 25%;
  background: var(--panel);
  backdrop-filter: none;
  border: 2px solid var(--border);
  padding: 28px 24px;
  gap: 16px;
}

#word-choices h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(148, 163, 184, 0.8);
  margin: 0;
}

#choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

#choices button {
  width: 100%;
  background: var(--panel-soft);
  color: var(--ink);
  border: 2px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: left;
  transition: all 0.2s ease;
}

#choices button:hover {
  background: #eef2ff;
  border-left-color: #1e40af;
  box-shadow: 0 2px 8px var(--shadow);
  transform: translateX(4px);
}

.toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  background: var(--danger);
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  animation: shake 0.4s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }

  20% {
    transform: translateX(calc(-50% - 6px)) rotate(-1deg);
  }

  40% {
    transform: translateX(calc(-50% + 6px)) rotate(1deg);
  }

  60% {
    transform: translateX(calc(-50% - 4px)) rotate(-1deg);
  }

  80% {
    transform: translateX(calc(-50% + 4px)) rotate(1deg);
  }
}

.toolbar {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toolbar-h {
  flex-direction: row;
  align-items: stretch;
  padding: 4px 10px;
  gap: 8px;
}

.toolbar-left {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.toolbar-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.toolbar-right #palette {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.toolbar-right .color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border-width: 1px;
}

.toolbar-right .color-history-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-right .color-history-row .label {
  font-size: 10px;
}

.toolbar-right #history {
  display: flex;
  gap: 3px;
}

.toolbar-right #history .color-swatch {
  width: 14px;
  height: 14px;
}

.tool-divider-v {
  width: 1px;
  align-self: stretch;
  background: rgba(148, 163, 184, 0.2);
}

.toolbar-h .size-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.toolbar-h .size-label input[type="range"] {
  width: 80px;
  height: 20px;
}

.chatcard-bottom {
  margin-top: -6px;
}

.tool-divider {
  width: 1px;
  height: 24px;
  background: rgba(148, 163, 184, 0.2);
  margin: 0 4px;
}

.size-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.size-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.pressure-label {
  gap: 4px;
}

.color-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tool {
  background: var(--panel-soft);
  color: var(--muted);
  border: 2px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.tool:hover {
  background: #e2e8f0;
  color: var(--ink);
  transform: translateY(-1px);
}

.tool.active {
  background: var(--accent);
  color: #fff;
  border-color: #1e40af;
  box-shadow: 0 2px 0 #1e40af;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tool-group.colors {
  flex-direction: column;
  align-items: flex-start;
}

#palette,
#history {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scorecard #players {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--panel-soft);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  position: relative;
  overflow: visible;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

.player-say-bubble {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%) translateX(0);
  max-width: 180px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #e5e7eb;
  color: #111827;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  filter: blur(0);
}

.player-say-bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #e5e7eb;
  border-left: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
}

.player-say-bubble.show {
  opacity: 1;
}

.player-say-bubble.fade-out {
  opacity: 0;
  transform: translateY(-50%) translateX(6px);
  filter: blur(1.2px);
  transition: opacity 1s ease, transform 1s ease, filter 1s ease;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-badge {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.7;
  min-width: 20px;
}

/* ── Player right-click context menu ── */
.player-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  padding: 4px 0;
  min-width: 140px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}

.player-context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  transition: background 0.12s;
}

.player-context-menu button:hover {
  background: rgba(99, 102, 241, 0.1);
}

.player-context-menu button.kick-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.kick-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

.player .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.avatar {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.avatar.avatar-drawing {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.avatar.avatar-drawing::after {
  content: '';
  position: absolute;
  inset: 1px;
  border: 2px dashed var(--accent-2);
  border-radius: 8px;
  opacity: 0.95;
  pointer-events: none;
  animation: avatarDrawingSpin 1.4s linear infinite;
}

@keyframes avatarDrawingSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar.avatar-drawing::after {
    animation: none;
  }
}

.player.drawer {
  border: 1px solid var(--accent-2);
}

.player.guessed {
  border: 1px solid var(--good);
  background: rgba(34, 197, 94, 0.2);
}

.player.reaction {
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

.chatbox {
  background: var(--panel-soft);
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 10px;
  padding: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-system {
  font-style: italic;
  font-size: 12px;
  color: #b58a00;
  padding: 2px 0;
}

.chat-sys-green {
  color: #16a34a;
}

.chat-sys-red {
  color: #dc2626;
}

.chat-player {
  padding: 2px 0;
  word-break: break-word;
}

.chat-player strong {
  font-weight: 600;
  color: var(--accent);
}

.chat-input {
  display: flex;
  gap: 8px;
}

.chat-input input {
  flex: 1;
}

.chat-input input.shake {
  animation: shake 0.4s ease;
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 12px;
}

.actioncard {
  gap: 10px;
  padding: 14px;
}

.action-grid {
  display: flex;
  gap: 6px;
}

.action-icon-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 38px;
  padding: 0;
  background: var(--panel-soft);
  color: var(--muted);
  border: 2px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s ease;
}

.action-icon-btn:hover {
  background: #e2e8f0;
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow);
}

.action-icon-btn svg {
  width: 18px;
  height: 18px;
}

.like-btn-style {
  background: rgba(255, 59, 92, 0.12);
  color: var(--danger);
  border-color: rgba(255, 59, 92, 0.25);
}

.like-btn-style:hover {
  background: rgba(255, 59, 92, 0.25);
  color: #ff6b8a;
  box-shadow: 0 4px 12px rgba(255, 59, 92, 0.25);
}

.actioncard select {
  width: 100%;
}

.grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.gallery-item {
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.gallery-item img {
  width: 100%;
  display: block;
}

.gallery-item .info {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 960px) {
  #game {
    grid-template-columns: 1fr;
  }

  .chatcard .chat-columns {
    grid-template-columns: 1fr;
  }

  #board {
    height: 300px;
  }

  .canvas-shell {
    min-height: unset;
  }

  #round-gallery.modal {
    inset: 8% 8%;
  }

  .mini-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ---- Mobile toolbar overhaul ---- */
  .toolbar-h {
    flex-direction: column;
    padding: 6px 8px;
    gap: 6px;
  }

  .toolbar-left {
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar-left .icon-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .toolbar-left .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .toolbar-h .size-label {
    gap: 4px;
  }

  .toolbar-h .size-label input[type="range"] {
    width: 60px;
    height: 16px;
  }

  .size-icon {
    width: 14px;
    height: 14px;
  }

  .pressure-label {
    display: none !important;
  }

  .tool-divider {
    height: 20px;
    margin: 0 2px;
  }

  .tool-divider-v {
    display: none;
  }

  .toolbar-right {
    gap: 3px;
  }

  .toolbar-right #palette {
    gap: 2px;
  }

  .toolbar-right .color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border-width: 1px;
  }

  .toolbar-right .color-history-row {
    gap: 4px;
  }

  .toolbar-right .color-history-row .label {
    font-size: 9px;
  }

  .toolbar-right #history {
    gap: 2px;
  }

  .toolbar-right #history .color-swatch {
    width: 14px;
    height: 14px;
  }
}

/* ---------- Site Footer ---------- */

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- Invite Overlay ---------- */

.invite-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 40, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: inviteFadeIn 0.3s ease;
}

@keyframes inviteFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.invite-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: inviteSlideUp 0.35s ease;
}

@keyframes inviteSlideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.invite-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.invite-title {
  font-family: 'Lilita One', 'Outfit', sans-serif;
  font-size: 28px;
  color: var(--text);
  margin: 0 0 4px;
}

.invite-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.invite-avatar-editor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-bottom: 18px;
}

.invite-avatar-editor .avatar-arrows {
  gap: 2px;
}

.invite-avatar-editor .arrow-btn {
  width: 28px;
  height: 32px;
  font-size: 18px;
}

.invite-avatar-editor .avatar-preview-wrap {
  flex-shrink: 0;
}

.invite-avatar-editor .avatar-preview {
  width: 100px;
  height: 100px;
  animation: none;
}

.invite-name-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--panel-soft);
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 16px;
}

.invite-name-input:focus {
  border-color: var(--accent);
}

.invite-name-input::placeholder {
  color: var(--muted);
}

.invite-join-btn {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
}
