:root {
  --bg: #100e1a;
  --bg-2: #150f24;
  --bg-card: #1e1830;
  --bg-card-hi: #251c3d;
  --ink: #f3f0fa;
  --ink-soft: #a79bcf;
  --accent: #a855f7;
  --accent-2: #c4b5fd;
  --purple: #a855f7;
  --purple-deep: #5b21b6;
  --green: #22c55e;
  --border: #34294f;
  --accent-ink: #2e1065; /* text on the light-purple gradient buttons */
  --field-bg: #0b0913;
  --timer-ink: #d7b6ff;
  --canvas-bg: #fdfdf7; /* must match CANVAS_BG in app.js */
  --warn: #fb923c; /* "yaklaştın", timer under 20 s */
  --danger: #e8384f; /* timer under 10 s, errors */
  --danger-ink: #ff9aa8;
  --danger-soft: #ffc2ca;
  --gold: #fbbf24;
  --silver: #cbd5e1;
  --bronze: #d97706;
  --bronze-deep: #92400e;
  --silver-deep: #94a3b8;
  --dock-bg: rgba(21, 15, 36, 0.92);
  --banner-bg-1: #3a2f0d;
  --banner-bg-2: #241d08;
  --banner-ink: #ffdf8a;
  --on-avatar: #fff;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius: 16px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image: radial-gradient(ellipse 900px 600px at 50% -10%, rgba(168, 85, 247, 0.1), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 20%, rgba(168, 85, 247, 0.12), transparent 60%),
    url("/doodles-bg.svg"), linear-gradient(180deg, var(--bg-2), var(--bg) 320px);
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
  background-size: auto, auto, 640px 640px, auto;
  background-attachment: fixed;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  /* Bottom room for the fixed help button, so it never sits on the chat input. */
  padding: 20px 16px calc(88px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.center {
  text-align: center;
}

.screen-title {
  margin: 6px 0 20px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-shadow: 0 2px 16px rgba(168, 85, 247, 0.25);
}

.screen-title .brand-text {
  background: linear-gradient(135deg, var(--accent-2), var(--purple) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  margin: -12px 0 20px;
}

.card {
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.field {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--ink);
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  background: var(--bg-card-hi);
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn:not(:disabled):hover {
  filter: brightness(1.12);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  width: 100%;
  border: none;
  box-shadow: 0 8px 22px -8px rgba(168, 85, 247, 0.55);
  font-size: 16px;
}

.btn-outline-small {
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  border: 1px solid rgba(167, 155, 207, 0.4);
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.6);
}

.btn-danger-outline {
  border-color: rgba(232, 56, 79, 0.55);
  color: var(--danger-ink);
}

.footer-note {
  color: var(--ink-soft);
  font-size: 13px;
  margin: 6px 0 0;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.mode-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}

.role-choice {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.role-choice-btn {
  flex: 1;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.role-choice-btn.selected {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: var(--accent-ink);
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
}

.room-code {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 10px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 8px 0;
}

.error-banner {
  background: linear-gradient(180deg, rgba(232, 56, 79, 0.18), rgba(232, 56, 79, 0.08));
  border: 1px solid var(--danger);
  color: var(--danger-soft);
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

.open-rooms-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.open-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

.open-room-row span {
  color: var(--ink-soft);
  font-size: 12px;
}

/* ---------- Lobby ---------- */

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.player-row:last-child {
  border-bottom: none;
}

.player-avatar {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  /* per-player colour from app.js (avatarColor) */
  background: var(--av, var(--purple));
  background: linear-gradient(135deg, var(--av, var(--purple)), color-mix(in srgb, var(--av, var(--purple)) 62%, #000));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--on-avatar);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.player-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.player-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-2);
  white-space: nowrap;
}

.player-tag.spectator-tag {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-soft);
}

.player-score {
  font-weight: 800;
  color: var(--accent-2);
  font-size: 14px;
  white-space: nowrap;
}

.player-order {
  width: 20px;
  min-width: 20px;
  text-align: center;
  font-weight: 800;
  color: var(--ink-soft);
  font-size: 12px;
}

.reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reorder-btn {
  width: 22px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card-hi);
  color: var(--ink);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.reorder-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---------- Drawing screen ---------- */

.topbar-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.topbar-row .btn {
  flex: 1;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  box-shadow: var(--shadow);
}

/* Round pill with an SVG ring that drains (stroke-dashoffset 0 → 100). */
.timer-pill {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(168, 85, 247, 0.18);
  color: var(--timer-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  --ring: var(--accent);
}

.timer-pill[data-urgency="mid"] {
  --ring: var(--warn);
  color: var(--warn);
  background: rgba(251, 146, 60, 0.16);
}

.timer-pill[data-urgency="high"] {
  --ring: var(--danger);
  color: var(--danger-ink);
  background: rgba(232, 56, 79, 0.18);
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
}

.timer-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring circle {
  fill: none;
  stroke-width: 4;
}

.timer-ring-track {
  stroke: rgba(255, 255, 255, 0.1);
}

.timer-ring-fill {
  stroke: var(--ring);
  stroke-linecap: round;
  stroke-dasharray: 100;
  transition: stroke-dashoffset 0.3s linear, stroke 0.3s ease;
}

.timer-num {
  position: relative;
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- Word tiles ---------- */

.status-word {
  flex: 1 1 auto;
  min-width: 0;
  container-type: inline-size;
  display: flex;
  justify-content: center;
}

.word-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
  perspective: 400px;
  --tile: 24px; /* no container units: fixed size, long words wrap */
}

/* Fit the whole word on one row in the space the status bar leaves
   ("kaplumbağa" at 375px gets ~17px tiles). */
@supports (width: 1cqi) {
  .word-tiles {
    --tile: clamp(15px, calc((100cqi - (var(--n) - 1) * 3px) / var(--n)), 32px);
  }
}

.tile,
.tile-gap {
  width: var(--tile);
  height: calc(var(--tile) * 1.25);
  flex: 0 0 auto;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 3px solid var(--ink-soft);
  font-size: calc(var(--tile) * 0.62);
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}

.tile.open {
  background: rgba(168, 85, 247, 0.22);
  border-bottom-color: var(--accent-2);
}

.tile.flip {
  animation: tile-flip 0.55s var(--ease-pop) both;
}

@keyframes tile-flip {
  from {
    transform: rotateY(90deg);
    background: var(--accent);
  }
  to {
    transform: rotateY(0);
  }
}

/* Drawer: the whole word; letters guessers can already see are marked. */
.drawer-tiles .tile.open {
  background: rgba(255, 255, 255, 0.07);
  border-bottom-color: rgba(167, 155, 207, 0.4);
}

.drawer-tiles .tile.shown {
  background: rgba(34, 197, 94, 0.2);
  border-bottom-color: var(--green);
}

.word-hint {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--ink);
  text-align: center;
}

.status-message {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ink);
  text-align: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.16);
}

.word-for-drawer {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}

.guess-progress {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.score-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 4px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.score-strip-target {
  color: var(--accent-2);
  white-space: nowrap;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.score-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  padding: 3px 7px 6px 3px;
  border-radius: 999px;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.score-chip.me {
  color: var(--ink);
}

.score-chip.drawing .score-chip-avatar {
  box-shadow: 0 0 0 2px var(--accent-2);
}

.score-chip.guessed {
  background: rgba(34, 197, 94, 0.14);
  color: var(--green);
}

.score-chip.just-guessed {
  animation: chip-glow 1.4s ease-out;
}

@keyframes chip-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.75);
  }
  40% {
    box-shadow: 0 0 14px 4px rgba(34, 197, 94, 0.55);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* progress toward the target score */
.score-chip-bar {
  position: absolute;
  left: 26px;
  right: 7px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.score-chip-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.6s ease;
}

.score-chip-avatar {
  width: 20px;
  height: 20px;
  min-width: 20px;
  font-size: 9px;
}

.word-choice-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.word-choice-btn {
  padding: 26px;
  border-radius: 18px;
  border: 2px solid var(--border);
  background: linear-gradient(160deg, var(--bg-card-hi), var(--bg-card));
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: scale(0.7) translateY(24px);
  animation: word-choice-pop 0.5s var(--ease-pop) forwards;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.word-choice-btn:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}

.word-choice-btn:active {
  transform: scale(0.96);
}

@keyframes word-choice-pop {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Top of the screen by default; app.js moves it just above the chat input
   when that is visible, so it never covers what you're typing. */
.close-hint-toast {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 22px -6px rgba(168, 85, 247, 0.6);
  z-index: 93;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: close-hint-pop 0.3s ease;
}

.close-hint-toast.fade-out {
  opacity: 0;
  transform: translate(-50%, 10px);
}

@keyframes close-hint-pop {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* The canvas keeps its 500:350 shape but never takes more than ~45% of the
   visible height (52% for the drawer, whose tools sit right below), so the
   chat/toolbar stay on screen — --vvh follows the phone keyboard. */
.canvas-wrap {
  position: relative;
  background: var(--canvas-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 0 auto 10px;
  touch-action: none;
  line-height: 0;
  width: min(100%, calc(var(--vvh, 100vh) * 0.45 * 500 / 350));
}

.is-drawer .canvas-wrap {
  width: min(100%, calc(var(--vvh, 100vh) * 0.52 * 500 / 350));
}

#draw-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  margin-bottom: 12px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-row .color-swatch {
  margin: 0 -3px; /* bigger hit area, same visual spacing between dots */
}

.toolbar .btn-outline-small {
  min-height: 44px;
}

/* Toolbar tap targets are at least 40-44px, even where the visible dot is smaller. */
.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card-hi);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-btn.active {
  outline: 2px solid var(--accent);
  background: rgba(168, 85, 247, 0.16);
}

.custom-color-input {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
}

.custom-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swatch-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-sizing: border-box;
}

.color-swatch.active .swatch-dot {
  border-color: var(--accent);
  transform: scale(1.15);
}

.size-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card-hi);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-btn.active {
  outline: 2px solid var(--accent);
}

.size-dot {
  border-radius: 50%;
  background: currentColor;
}

.chat-card {
  padding: 0;
  overflow: hidden;
}

.chat-log {
  list-style: none;
  margin: 0;
  padding: 10px 14px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 14px;
}

.chat-log li {
  padding: 4px 0;
  color: var(--ink);
}

.chat-log li.correct {
  color: var(--green);
  font-weight: 700;
}

.chat-log .chat-name {
  color: var(--ink-soft);
  font-weight: 700;
  margin-right: 6px;
}

.chat-log li.chat-empty {
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
  padding: 10px 0;
}

.chat-log li.chat-hint {
  color: var(--warn);
  font-style: italic;
  text-align: center;
  font-weight: 700;
}

.drawer-label {
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.chat-input-row .field {
  flex: 1;
}

.drawer-waiting {
  text-align: center;
  padding: 30px 16px;
  color: var(--ink-soft);
}

/* ---------- Round end / game over ---------- */

.reveal-banner {
  text-align: center;
  padding: 20px 18px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(168, 85, 247, 0.28), var(--bg-card));
  box-shadow: var(--shadow);
}

.reveal-word {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 4px 0;
}

.points-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  text-align: left;
}

.points-list li {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}

.points-list .pts {
  color: var(--accent-2);
  font-weight: 800;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  width: 26px;
  font-weight: 800;
  color: var(--ink-soft);
  text-align: center;
}

.leaderboard-row:first-child .leaderboard-rank {
  color: var(--accent);
  font-size: 18px;
}

.howto-fab {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px -6px rgba(168, 85, 247, 0.6);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

.howto-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 10, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 95;
  padding: 20px;
}

.howto-card {
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.howto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  position: sticky;
  top: 0;
  background: var(--bg-card-hi);
  border-radius: var(--radius) var(--radius) 0 0;
}

.howto-header h2 {
  margin: 0;
  font-size: 19px;
}

.howto-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--ink);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}

.howto-body {
  padding: 4px 18px 20px;
  font-size: 14px;
  line-height: 1.55;
}

.howto-body ul {
  margin: 6px 0;
  padding-left: 20px;
}

.howto-body li {
  margin: 6px 0;
}

.inapp-banner {
  background: linear-gradient(180deg, var(--banner-bg-1), var(--banner-bg-2));
  color: var(--banner-ink);
  font-size: 13px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.inapp-banner button {
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
}

/* ---------- Intro / splash animation ---------- */

.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse 900px 600px at 50% 20%, rgba(168, 85, 247, 0.14), transparent 60%),
    radial-gradient(ellipse 700px 500px at 50% 90%, rgba(168, 85, 247, 0.16), transparent 60%), var(--bg);
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.intro-screen.intro-out {
  opacity: 0;
}

.intro-doodle {
  overflow: visible;
}

.intro-doodle-path {
  stroke-dasharray: 420;
  stroke-dashoffset: 420;
  animation: intro-draw-line 1.3s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes intro-draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

.intro-pencil {
  font-size: 34px;
  transform-origin: 70% 70%;
  opacity: 0;
  animation: intro-pencil-in 0.4s ease 0.1s forwards, intro-pencil-wiggle 0.5s ease-in-out 0.5s 2;
}

@keyframes intro-pencil-in {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes intro-pencil-wiggle {
  0%,
  100% {
    transform: rotate(-8deg);
  }
  50% {
    transform: rotate(10deg);
  }
}

.intro-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  animation: intro-title-pop 0.55s var(--ease-pop) 1.25s forwards;
}

.intro-title .brand-text {
  background: linear-gradient(135deg, var(--accent-2), var(--purple) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@keyframes intro-title-pop {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.intro-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  opacity: 0;
  animation: intro-fade-in 0.5s ease 1.55s forwards;
}

@keyframes intro-fade-in {
  to {
    opacity: 1;
  }
}

.intro-skip-hint {
  position: absolute;
  bottom: 26px;
  font-size: 12px;
  color: var(--ink-soft);
  opacity: 0;
  animation: intro-fade-in 0.5s ease 1.8s forwards;
}

/* ---------- Toast shake ("Yaklaştın") ---------- */

.close-hint-toast.shake {
  animation: close-hint-pop 0.3s ease, toast-shake 0.5s ease 0.3s;
}

@keyframes toast-shake {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  20% {
    transform: translate(calc(-50% - 7px), 0);
  }
  40% {
    transform: translate(calc(-50% + 6px), 0);
  }
  60% {
    transform: translate(calc(-50% - 4px), 0);
  }
  80% {
    transform: translate(calc(-50% + 2px), 0);
  }
}

/* ---------- Lobby: categories ---------- */

.cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cat-all-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
}

.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-chip {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.cat-chip:active:not(:disabled) {
  transform: scale(0.96);
}

.cat-chip.on {
  background: rgba(168, 85, 247, 0.22);
  border-color: var(--accent);
  color: var(--ink);
}

.cat-chip:disabled {
  cursor: default;
}

.cat-chip:disabled:not(.on) {
  opacity: 0.45;
}

/* ---------- Difficulty badges / word choice ---------- */

.diff-badge {
  display: inline-block;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.diff-kolay {
  background: rgba(34, 197, 94, 0.18);
  color: var(--green);
}

.diff-orta {
  background: rgba(234, 179, 8, 0.18);
  color: var(--gold);
}

.diff-zor {
  background: rgba(232, 56, 79, 0.2);
  color: var(--danger-ink);
}

.word-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
}

.word-choice-btn.diff-kolay,
.word-choice-btn.diff-orta,
.word-choice-btn.diff-zor {
  background: linear-gradient(160deg, var(--bg-card-hi), var(--bg-card));
  color: var(--ink);
}

.word-choice-btn.diff-zor {
  border-color: rgba(232, 56, 79, 0.45);
}

.wc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink-soft);
}

.waiting-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.waiting-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  font-size: 18px;
}

/* ---------- Drawer change card ---------- */

.turn-card-overlay {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 10, 0.55);
  pointer-events: none;
  animation: intro-fade-in 0.2s ease;
  transition: opacity 0.3s ease;
}

.turn-card-overlay.out {
  opacity: 0;
}

.turn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 34px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, var(--bg-card-hi), var(--bg-card));
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(168, 85, 247, 0.25);
  opacity: 0;
  transform: scale(0.7) translateY(24px);
  animation: word-choice-pop 0.5s var(--ease-pop) forwards;
  max-width: calc(100vw - 40px);
  text-align: center;
}

.turn-card-avatar {
  width: 64px;
  height: 64px;
  min-width: 64px;
  font-size: 28px;
}

.turn-card-title {
  font-size: 24px;
  font-weight: 800;
}

.turn-card-sub {
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Drawing screen extras ---------- */

.drawer-label-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 4px 0 6px;
}

.drawer-label-row .drawer-label {
  margin: 0;
}

.buy-hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.12);
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.buy-hint-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.buy-hint-cost {
  color: var(--danger-ink);
}

.buy-hint-left {
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--gold);
  color: var(--accent-ink);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.points-pop {
  position: absolute;
  left: 50%;
  top: 45%;
  line-height: 1;
  font-size: 46px;
  font-weight: 800;
  color: var(--green);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25), 0 0 18px rgba(34, 197, 94, 0.5);
  pointer-events: none;
  animation: points-pop 1.4s var(--ease-pop) forwards;
}

@keyframes points-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -70%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -110%) scale(0.95);
  }
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 97;
}

/* Guessers: the chat log shrinks with the visible height and the input is
   docked at the bottom, so the keyboard never pushes the canvas away. */
.is-guesser .chat-log {
  max-height: clamp(72px, calc(var(--vvh, 100vh) * 0.22), 180px);
}

.chat-card-docked {
  margin-bottom: 10px;
}

.chat-input-row.chat-dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 0 -16px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--dock-bg), var(--bg));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

body.has-chat-dock #app {
  padding-bottom: 0;
}

/* the help button moves above the docked input */
body.has-chat-dock .howto-fab {
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 40px;
  height: 40px;
  font-size: 17px;
  opacity: 0.85;
}

/* ---------- Round end ---------- */

.reveal-word {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  font-size: clamp(22px, 8vw, 30px);
}

.reveal-letter {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: letter-up 0.45s var(--ease-pop) both;
  animation-delay: calc(var(--i) * 60ms);
}

.reveal-gap {
  width: 0.4em;
}

@keyframes letter-up {
  from {
    opacity: 0;
    transform: translateY(0.7em);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.round-thumb {
  width: min(100%, 300px);
  margin: 10px auto 8px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--canvas-bg);
  box-shadow: var(--shadow);
  line-height: 0;
}

.round-thumb canvas,
.gallery-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 500 / 350;
  display: block;
  background: var(--canvas-bg);
}

.react-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 6px;
}

.react-btn {
  min-height: 40px;
  min-width: 64px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.react-btn b {
  display: inline-block;
  font-size: 14px;
  margin-left: 2px;
}

.react-btn.on {
  background: rgba(168, 85, 247, 0.25);
  border-color: var(--accent);
}

.react-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.react-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.react-btn.bump b {
  animation: count-bump 0.4s var(--ease-pop);
}

@keyframes count-bump {
  50% {
    transform: scale(1.5);
  }
}

.react-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.points-list li {
  align-items: center;
  gap: 8px;
}

.points-avatar {
  width: 22px;
  height: 22px;
  min-width: 22px;
  font-size: 10px;
}

.points-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint-penalty {
  color: var(--danger-ink);
  font-weight: 700;
}

/* ---------- Game over: podium + gallery ---------- */

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 16px;
}

.podium-col {
  flex: 1 1 0;
  max-width: 120px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.podium-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  font-size: 17px;
}

.place-1 .podium-avatar {
  width: 54px;
  height: 54px;
  min-width: 54px;
  font-size: 22px;
  box-shadow: 0 0 0 3px var(--gold);
}

.podium-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.podium-score {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-2);
}

.podium-block {
  width: 100%;
  border-radius: 12px 12px 4px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-ink);
  box-shadow: var(--shadow);
  transform-origin: bottom;
}

.place-1 .podium-block {
  height: 110px;
  background: linear-gradient(180deg, var(--gold), var(--bronze));
}

.place-2 .podium-block {
  height: 80px;
  background: linear-gradient(180deg, var(--silver), var(--silver-deep));
}

.place-3 .podium-block {
  height: 60px;
  background: linear-gradient(180deg, var(--bronze), var(--bronze-deep));
}

.podium-trophy {
  font-size: 34px;
  line-height: 1;
}

.podium.animate .podium-block {
  animation: podium-rise 0.6s var(--ease-pop) both;
}

.podium.animate .place-2 .podium-block {
  animation-delay: 0.1s;
}

.podium.animate .place-3 .podium-block {
  animation-delay: 0.2s;
}

.podium.animate .podium-trophy {
  animation: trophy-drop 0.7s var(--ease-pop) 0.45s both;
}

@keyframes podium-rise {
  from {
    transform: scaleY(0.1);
    opacity: 0;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes trophy-drop {
  from {
    transform: translateY(-120px) rotate(-20deg);
    opacity: 0;
  }
  to {
    transform: translateY(0) rotate(0);
    opacity: 1;
  }
}

.gallery-title {
  margin: 6px 0 10px;
  font-size: 18px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.gallery-card {
  position: relative;
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-card-hi), var(--bg-card));
  box-shadow: var(--shadow);
}

.gallery-card.best {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow);
}

.gallery-best {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 800;
}

.gallery-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 10px;
  font-size: 12px;
}

.gallery-word {
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.gallery-by {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.gallery-avatar {
  width: 18px;
  height: 18px;
  min-width: 18px;
  font-size: 9px;
}

.gallery-react {
  color: var(--ink-soft);
}

/* ---------- Reduced motion ---------- */
/* Animations jump straight to their end state (JS effects like confetti and
   count-ups check the same media query and skip themselves). */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
}

/* The letters carry their own gradient; the word's own clipped background
   would otherwise ghost behind them while they slide in. */
.reveal-banner .reveal-word {
  background: none;
  color: var(--accent-2);
}

/* Phones: 9 swatches per row instead of 7, so the drawer's palette is two
   rows and the size/undo controls stay near the canvas. */
@media (max-width: 420px) {
  .toolbar {
    gap: 8px;
    padding: 8px 10px;
  }

  .toolbar-row {
    gap: 5px;
  }

  .color-swatch {
    width: 34px;
    height: 36px;
  }

  .swatch-dot {
    width: 24px;
    height: 24px;
  }

  .custom-color-input {
    width: 34px;
    height: 34px;
  }

  .size-btn {
    width: 38px;
    height: 38px;
  }
}

/* ---------- 📺 Sunum ekranı ---------- */

/* Nothing on the shared screen is clickable: no buttons, no help, no top bar. */
body.tv-mode .top-bar,
body.tv-mode .howto-fab,
body.tv-mode #app button,
body.tv-mode .action-bar {
  display: none !important;
}

body.tv-mode #app {
  max-width: 1500px;
  padding-bottom: 60px;
}

/* A laptop shared on Zoom is wide but seen small: scale everything up. */
@media (min-width: 1000px) {
  body.tv-mode #app {
    zoom: 1.25;
  }
}

.tv-link-btn {
  width: 100%;
  margin-top: 8px;
}

.tv-lobby {
  text-align: center;
  padding-top: 2vh;
}

.tv-title {
  font-size: clamp(30px, 5vw, 60px);
  margin: 0 0 3vh;
}

.tv-lobby-grid {
  display: flex;
  gap: 5vw;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3vh;
}

.tv-qr {
  width: min(40vh, 340px);
  aspect-ratio: 1;
  background: #fff;
  border-radius: 20px;
  padding: 12px;
  box-sizing: border-box;
  animation: tv-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.tv-qr .qr-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.tv-sub {
  color: var(--ink-soft);
  font-size: clamp(15px, 1.8vw, 22px);
  margin: 6px 0;
}

.tv-code-label {
  margin-top: 3vh;
}

.tv-code {
  font-size: clamp(60px, 10vw, 160px);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
}

.tv-names {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 1.5vh;
}

.tv-names span {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: clamp(15px, 1.7vw, 22px);
  animation: tv-pop 0.35s ease both;
}

.tv-names span.off {
  opacity: 0.45;
}

.tv-teams {
  text-align: left;
  max-width: 900px;
  margin: 0 auto;
}

.tv-corner {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 50;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  pointer-events: none;
}

.tv-corner strong {
  letter-spacing: 2px;
}

.tv-round-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .tv-round-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tv-landing-card {
  max-width: 420px;
  margin: 0 auto;
}

.tv-go {
  display: flex;
  margin-top: 10px;
  text-decoration: none;
}

@keyframes tv-pop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
}

/* No typing on the shared screen either. */
body.tv-mode #app input:not(#tv-code-input),
body.tv-mode #app textarea,
body.tv-mode .chat-input-row,
body.tv-mode .reaction-bar,
body.tv-mode .react-bar {
  display: none !important;
}

/* No typing on the shared screen either. */
body.tv-mode #app input:not(#tv-code-input),
body.tv-mode #app textarea,
body.tv-mode .chat-input-row,
body.tv-mode .react-bar {
  display: none !important;
}
