:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #080d1a;
  --bg-2: #0e1529;
  --panel: #111a30;
  --border: rgb(148 163 184 / 16%);
  --border-strong: rgb(148 163 184 / 32%);
  --text: #eaf0ff;
  --muted: #93a2bd;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 24px 60px rgb(2 6 23 / 55%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(0.75rem, 3vw, 2rem);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 8% -12%, rgb(124 92 255 / 24%), transparent 62%),
    radial-gradient(760px 460px at 100% 0%, rgb(34 211 238 / 16%), transparent 60%),
    linear-gradient(165deg, var(--bg), var(--bg-2));
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, 74rem);
  margin: 0 auto;
  display: grid;
  gap: 1.1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  background: linear-gradient(135deg, var(--accent), #4c8dff);
  box-shadow: 0 8px 20px rgb(124 92 255 / 40%);
  font-size: 1.25rem;
}

.connection {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.connection-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px rgb(251 191 36 / 12%);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.connection[data-state="online"] .connection-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgb(52 211 153 / 12%);
}

.connection[data-state="offline"] .connection-dot,
.connection[data-state="error"] .connection-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgb(251 113 133 / 12%);
}

.screen {
  animation: fade-up 0.35s ease both;
}

.panel {
  padding: clamp(1.1rem, 2.6vw, 2rem);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: linear-gradient(160deg, rgb(17 26 48 / 95%), rgb(11 17 33 / 95%));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.inset {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: rgb(8 13 26 / 55%);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(120deg, #fff 10%, #b9a8ff 55%, var(--accent-2));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
}

h3 {
  margin: 0;
  font-size: 0.85rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.subtitle,
.note,
.hint {
  color: var(--muted);
}

.subtitle {
  max-width: 34rem;
  margin: 0.85rem auto 0;
  line-height: 1.55;
}

.note {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.hint {
  margin: 0;
  font-size: 0.82rem;
}

.muted {
  color: var(--muted);
  font-weight: 500;
}

/* Lobby */

.lobby-panel {
  max-width: 56rem;
  margin: 0 auto;
}

.hero {
  margin-bottom: 2rem;
  text-align: center;
}

.lobby-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.lobby-card {
  display: grid;
  align-content: start;
  gap: 0.7rem;
  padding: 1.3rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgb(148 163 184 / 5%);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

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

.lobby-card h2 {
  font-size: 1.05rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.65rem;
  background: rgb(8 13 26 / 70%);
  color: var(--text);
  font: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input::placeholder {
  color: rgb(147 162 189 / 65%);
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(124 92 255 / 18%);
}

#room-code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-family: ui-monospace, "SFMono-Regular", monospace;
}

.full-width {
  width: 100%;
}

.join-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.button {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.7rem;
  background: rgb(148 163 184 / 8%);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgb(148 163 184 / 55%);
  background: rgb(148 163 184 / 16%);
}

.button:active:not(:disabled) {
  transform: scale(0.98);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-button {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #4c8dff);
  color: #fff;
  box-shadow: 0 10px 24px rgb(124 92 255 / 30%);
}

.primary-button:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, #8b70ff, #5f9aff);
  box-shadow: 0 14px 28px rgb(124 92 255 / 40%);
}

.ghost-button {
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
}

.error {
  min-height: 1.2em;
  margin: 0.9rem 0 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  margin: 1.4rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  counter-reset: step;
  color: var(--muted);
  font-size: 0.8rem;
}

.steps li {
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: rgb(124 92 255 / 18%);
  color: #c4b5fd;
  font-weight: 800;
}

/* Místnost */

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.room-code {
  margin-top: 0.2rem;
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: 0.16em;
}

.room-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgb(148 163 184 / 8%);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status[data-state="online"] {
  border-color: rgb(52 211 153 / 30%);
  background: rgb(52 211 153 / 12%);
  color: var(--success);
}

.status[data-state="offline"],
.status[data-state="error"] {
  border-color: rgb(251 113 133 / 30%);
  background: rgb(251 113 133 / 12%);
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.section-head h3 {
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-title {
  margin: 0.3rem 0 0;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -0.03em;
}

.waiting-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem);
  gap: 1rem;
  margin-top: 1.25rem;
  animation: fade-up 0.3s ease both;
}

.waiting-main {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: radial-gradient(600px 200px at 0% 0%, rgb(124 92 255 / 14%), transparent), rgb(148 163 184 / 4%);
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.player-list {
  display: grid;
  gap: 0.45rem;
  max-height: 24rem;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  background: rgb(148 163 184 / 7%);
  animation: fade-up 0.25s ease both;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.player.is-drawing {
  border-color: rgb(124 92 255 / 60%);
  background: rgb(124 92 255 / 16%);
}

.player.is-guessed {
  border-color: rgb(52 211 153 / 40%);
}

.player-score {
  color: var(--accent-2);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.player-name {
  font-weight: 650;
}

.player-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.3rem;
}

.badge {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgb(148 163 184 / 14%);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-host {
  background: rgb(251 191 36 / 14%);
  color: var(--warning);
}

.badge-ready,
.badge-guessed {
  background: rgb(52 211 153 / 14%);
  color: var(--success);
}

.badge-wait {
  background: rgb(148 163 184 / 12%);
}

.badge-drawing {
  background: rgb(124 92 255 / 20%);
  color: #c4b5fd;
}

/* Hra */

.game-panel {
  margin-top: 1.25rem;
  animation: fade-up 0.3s ease both;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.round-chip {
  padding: 0.4rem 0.85rem;
  border: 1px solid rgb(34 211 238 / 28%);
  border-radius: 999px;
  background: rgb(34 211 238 / 10%);
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 800;
}

.timer {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.timer[data-low="true"] {
  color: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}

.timer-unit {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.word-banner {
  margin: 1rem 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: rgb(124 92 255 / 9%);
  text-align: center;
}

.word-text {
  margin: 0.35rem 0 0;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.word-hint {
  margin: 0.5rem 0 0;
  color: var(--accent-2);
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: clamp(1rem, 3vw, 1.35rem);
  letter-spacing: 0.3em;
}

.word-count {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem);
  gap: 1rem;
  align-items: start;
}

.game-main {
  min-width: 0;
}

.drawing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: rgb(148 163 184 / 7%);
}

.tool-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.swatches {
  display: flex;
  gap: 0.3rem;
}

.swatch {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.swatch:hover {
  transform: scale(1.15);
}

.swatch.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgb(124 92 255 / 75%);
}

input[type="color"] {
  width: 2.4rem;
  height: 1.9rem;
  padding: 0.1rem;
  cursor: pointer;
}

input[type="range"] {
  width: 6rem;
  accent-color: var(--accent);
}

output {
  min-width: 1.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.tool-button {
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
}

.tool-button.active-tool {
  border-color: var(--accent);
  background: rgb(124 92 255 / 20%);
  color: #c4b5fd;
}

#draw-canvas {
  display: block;
  width: 100%;
  height: clamp(15rem, 48vh, 30rem);
  border: 1px solid rgb(148 163 184 / 28%);
  border-radius: 0.9rem;
  background: #fff;
  box-shadow: 0 16px 40px rgb(0 0 0 / 28%);
  cursor: crosshair;
  touch-action: none;
}

.guess-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.guess-form input {
  flex: 1;
  min-width: 0;
}

.game-aside {
  display: grid;
  gap: 0.75rem;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.feed {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: min(22rem, 38vh);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.chat-line {
  padding: 0.4rem 0.55rem;
  border-radius: 0.55rem;
  background: rgb(148 163 184 / 7%);
  font-size: 0.8rem;
  line-height: 1.4;
  animation: fade-up 0.2s ease both;
}

.chat-line--correct {
  background: rgb(52 211 153 / 14%);
  color: #a7f3d0;
}

.chat-line--reveal {
  background: rgb(251 191 36 / 12%);
  color: #fde68a;
}

.chat-line--system {
  color: var(--muted);
  font-style: italic;
}

.chat-name {
  margin-right: 0.35rem;
  color: var(--accent-2);
  font-weight: 800;
}

/* Výsledky */

.result-panel {
  margin-top: 1.25rem;
  animation: fade-up 0.35s ease both;
}

.result-head {
  text-align: center;
}

.winner-banner {
  display: inline-block;
  margin: 1rem 0 0;
  padding: 0.5rem 1rem;
  border: 1px solid rgb(251 191 36 / 35%);
  border-radius: 999px;
  background: linear-gradient(135deg, rgb(251 191 36 / 18%), rgb(124 92 255 / 18%));
  color: #fde68a;
  font-weight: 800;
}

.ranking-list {
  display: grid;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  background: rgb(148 163 184 / 7%);
  animation: fade-up 0.3s ease both;
}

.ranking-row.is-winner {
  border-color: rgb(251 191 36 / 50%);
  background: linear-gradient(120deg, rgb(251 191 36 / 14%), rgb(124 92 255 / 12%));
}

.rank-position {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 0.55rem;
  background: rgb(148 163 184 / 12%);
  font-weight: 800;
}

.ranking-row.is-winner .rank-position {
  background: rgb(251 191 36 / 22%);
  color: #fde68a;
}

.rank-name {
  flex: 1;
  font-weight: 650;
}

.rank-score {
  color: var(--accent-2);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.4rem;
}

/* Animace */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pulse {
  50% {
    opacity: 0.6;
    transform: scale(1.05);
  }
}

@media (max-width: 900px) {
  .lobby-grid,
  .waiting-panel,
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-aside {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-list,
  .feed {
    max-height: 12rem;
  }
}

@media (max-width: 640px) {
  body {
    place-items: start center;
  }

  .panel {
    padding: 1rem;
    border-radius: 1rem;
  }

  .app-shell {
    gap: 0.75rem;
  }

  .room-header {
    align-items: flex-start;
  }

  .room-header-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
  }

  .game-aside {
    grid-template-columns: minmax(0, 1fr);
  }

  #draw-canvas {
    height: 42vh;
    min-height: 13rem;
  }

  .tool-group {
    padding: 0.3rem 0.4rem;
  }

  .hint,
  .steps {
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
