/* =========================
   Svoya Igra Online - UI Theme
   (No game logic changes)
   ========================= */

:root {
  /* Base theme (Dark / Neon) */
  --bg-color: #061326;
  --bg-grad-1: #041022;
  --bg-grad-2: #0b2b4d;

  --text-color: #eef5ff;
  --muted-color: rgba(238, 245, 255, 0.72);

  --card-bg: rgba(14, 28, 56, 0.86);
  --card-bg-solid: #0f1f3b;

  --primary-color: #3aa0ff;
  --primary-color-2: #0e4a6f;
  --accent-color: #ff4d6d;

  --border-color: rgba(255, 77, 109, 0.38);

  --shadow-color: rgba(0, 0, 0, 0.35);
  --shadow: 0 10px 30px var(--shadow-color);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --focus-ring: 0 0 0 3px rgba(58, 160, 255, 0.35);

  --spacing-sm: 6px;
  --spacing-md: 12px;
  --spacing-lg: 20px;

  /* Festive accents */
  --festive-1: #ff4d6d;
  --festive-2: #ffd166;
  --festive-3: #2ec4b6;
  --question-points-color: #ffd166;



  --answering-color: #ffd166;
  --answering-bg: rgba(0, 0, 0, 0);
  --answering-border: rgba(255, 255, 255, 0.14);
  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  /* Light theme */
  --bg-color: #f6fbff;
  --bg-grad-1: #f6fbff;
  --bg-grad-2: #e8f1ff;

  --text-color: #0b1526;
  --muted-color: rgba(11, 21, 38, 0.68);

  --card-bg: rgba(255, 255, 255, 0.93);
  --card-bg-solid: #ffffff;

  --primary-color: #2b83f6;
  --primary-color-2: #124b7a;
  --accent-color: #e63946;

  --border-color: rgba(43, 131, 246, 0.20);

  --shadow-color: rgba(0, 0, 0, 0.12);
  --shadow: 0 10px 30px var(--shadow-color);
  /* Festive accents */
  --festive-1: #e63946;
  --festive-2: #ffd166;
  --festive-3: #2a9d8f;
  --question-points-color: #b77900;




  --answering-color: #2b83f6;
  --answering-bg: rgba(0, 0, 0, 0);
  --answering-border: rgba(0, 0, 0, 0);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  background: radial-gradient(1200px 600px at 30% 10%, var(--bg-grad-2), var(--bg-grad-1)) fixed;
  color: var(--text-color);
  font-family: var(--font-sans);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* =========================
   Snowfall Background (DISABLED FOR PERFORMANCE)
   ========================= */

/* Put content above snow layers */
body>* {
  position: relative;
  z-index: 1;
}

/*
   Heavy snowfall animation removed to save GPU memory.
   Previously used multiple radial-gradients and blur filters.
*/
body::before,
body::after {
  content: none;
  display: none;
}

/* Light theme: keep subtle festive background (restored) */
:root[data-theme="light"] body {
  background:
    url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22420%22%20height%3D%22260%22%20viewBox%3D%220%200%20420%20260%22%3E%0A%20%20%3Cg%20fill%3D%22none%22%20stroke%3D%22%232a9d8f%22%20stroke-opacity%3D%220.12%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%0A%20%20%20%20%3Cpath%20d%3D%22M40%20230%20L55%20205%20L25%20205%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M40%20205%20L58%20180%20L22%20180%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M40%20180%20L60%20155%20L20%20155%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M40%20155%20L40%20140%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M150%20240%20L170%20205%20L130%20205%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M150%20205%20L175%20170%20L125%20170%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M150%20170%20L180%20135%20L120%20135%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M150%20135%20L150%20120%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M300%20235%20L318%20205%20L282%20205%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M300%20205%20L323%20175%20L277%20175%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M300%20175%20L328%20145%20L272%20145%20Z%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M300%20145%20L300%20130%22%2F%3E%0A%20%20%20%20%3C%21--%20branch%20contours%20--%3E%0A%20%20%20%20%3Cpath%20d%3D%22M10%2060%20C70%2030%2C%20120%2040%2C%20190%2018%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M230%2070%20C300%2040%2C%20350%2050%2C%20410%2028%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M35%2070%20L20%2055%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M55%2063%20L40%2048%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M75%2056%20L60%2041%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M260%2077%20L245%2062%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M280%2071%20L265%2056%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M300%2065%20L285%2050%22%2F%3E%0A%20%20%3C%2Fg%3E%0A%20%20%3Cg%20fill%3D%22none%22%20stroke%3D%22%232b83f6%22%20stroke-opacity%3D%220.08%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%0A%20%20%20%20%3Cpath%20d%3D%22M80%20120%20C140%2090%2C%20190%20100%2C%20260%2078%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M270%20120%20C320%2092%2C%20360%20102%2C%20410%2084%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M95%20126%20L80%20111%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M115%20120%20L100%20105%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M290%20126%20L275%20111%22%2F%3E%0A%20%20%20%20%3Cpath%20d%3D%22M310%20120%20L295%20105%22%2F%3E%0A%20%20%3C%2Fg%3E%0A%3C%2Fsvg%3E") repeat,
    radial-gradient(1000px 520px at 22% 6%, rgba(46, 196, 182, 0.18), transparent 62%),
    radial-gradient(900px 480px at 84% 10%, rgba(255, 209, 102, 0.14), transparent 60%),
    radial-gradient(1200px 600px at 30% 10%, var(--bg-grad-2), var(--bg-grad-1)) fixed;
  background-size: 520px 320px, auto, auto, auto;
  background-position: 0 0, 0 0, 0 0, 0 0;
  background-attachment: scroll, scroll, scroll, fixed;
}


a {
  color: inherit;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  text-align: center;
}

.page-title {
  margin: 0 0 1.25rem 0;
  letter-spacing: 0.5px;
  font-weight: 900;
  font-size: clamp(1.6rem, 3.2vw, 2.3rem);
}

/* =========================
   Top Header / Brand
   ========================= */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  row-gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 14, 28, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

:root[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid rgba(16, 19, 34, 0.10);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 0.4px;
  user-select: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  box-shadow: 0 8px 18px rgba(58, 160, 255, 0.22);
  color: #fff;
  font-size: 18px;
}

.brand-name {
  font-size: 1.05rem;
}

.room-info {
  color: var(--muted-color);
  font-weight: 700;
  margin-left: 6px;
}

.header-spacer {
  flex: 1;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}


.user-info {
  margin-left: auto;
  color: var(--muted-color);
  font-weight: 700;
}

/* =========================
   Cards / Inputs / Buttons
   ========================= */

.card {
  background: var(--card-bg);
  padding: 1.6rem;
  margin: 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

:root[data-theme="light"] .card {
  border: 1px solid rgba(16, 19, 34, 0.08);
}

input,
textarea,
select {
  width: min(420px, 100%);
  padding: 12px 12px;
  margin: 6px 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-color);
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
  font: inherit;
}

select {
  appearance: none;
}

:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(16, 19, 34, 0.15);
}

input:focus,
textarea:focus,
select:focus {
  box-shadow: var(--focus-ring);
  border-color: rgba(58, 160, 255, 0.55);
}

.btn,
.icon-btn {
  border: none;
  cursor: pointer;
  color: #fff;
  border-radius: 12px;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  outline: none;
}

.btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-color-2));
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 18px rgba(58, 160, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
}

.btn.danger {
  background: linear-gradient(135deg, #ff3358, #b90d2f);
  box-shadow: 0 10px 18px rgba(233, 69, 96, 0.18);
}

.btn.compact {
  padding: 8px 11px;
  font-size: 0.9rem;
}

.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.btn:active,
.icon-btn:active {
  transform: translateY(0px) scale(0.99);
}

.btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.btn:focus-visible,
.icon-btn:focus-visible {
  box-shadow: var(--focus-ring);
}

#player-list li {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  white-space: nowrap;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Space out name and score */
}

.score-input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 4px;
  font-size: 1rem;
}

:root[data-theme="light"] .score-input {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(16, 19, 34, 0.22);
  color: var(--text-color);
  caret-color: var(--text-color);
}

#controls-area {
  padding: 10px 12px;
  display: flex !important;
  /* Force flex */
  justify-content: center;
  align-items: center;
  min-height: 86px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-color);
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] .icon-btn {
  background: rgba(16, 19, 34, 0.06);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.hidden {
  display: none !important;
}

.lobby-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pack-editor-entry {
  display: grid;
  align-content: start;
  justify-items: center;
}

.pack-editor-entry p {
  max-width: 280px;
  margin: 0 0 14px;
  color: var(--muted-color);
  font-weight: 700;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pack-editor-page {
  min-height: 100dvh;
}

.pack-editor-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.editor-start {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding-top: clamp(38px, 8dvh, 90px);
}

.editor-start-actions,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-file-btn {
  margin: 0;
}

.editor-setup {
  width: min(620px, 100%);
  margin: 42px auto;
  text-align: left;
}

.editor-setup h2 {
  margin: 0 0 14px;
}

.editor-form-row,
.editor-field {
  display: grid;
  gap: 4px;
  text-align: left;
  color: var(--muted-color);
  font-weight: 800;
}

.editor-field input,
.editor-field textarea,
.editor-field select,
.editor-form-row input {
  width: 100%;
}

.editor-workspace {
  display: grid;
  gap: 16px;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: rgba(10, 14, 28, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 12px;
  z-index: 5;
}

:root[data-theme="light"] .editor-toolbar {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(16, 19, 34, 0.10);
}

.editor-title-group {
  display: grid;
  gap: 4px;
  text-align: left;
  color: var(--muted-color);
  font-weight: 800;
}

.editor-title-group input {
  width: 100%;
  max-width: 620px;
}

.editor-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted-color);
  font-weight: 800;
}

.editor-status.error {
  color: var(--accent-color);
}

.rounds-container,
.themes-container,
.questions-container {
  display: grid;
  gap: 14px;
}

.round-editor {
  margin: 0;
  text-align: left;
}

.round-editor-header,
.theme-editor-header,
.question-editor-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.theme-editor,
.question-editor {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

:root[data-theme="light"] .theme-editor,
:root[data-theme="light"] .question-editor {
  border-color: rgba(16, 19, 34, 0.10);
  background: rgba(16, 19, 34, 0.035);
}

.question-editor {
  display: grid;
  gap: 10px;
}

.question-editor-header h4 {
  margin: 0;
  color: var(--text-color);
}

.editor-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-order-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.editor-order-btn {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 7px 0;
  font-size: 1rem;
  line-height: 1;
}

.editor-move-select-field {
  display: grid;
  grid-template-columns: auto minmax(120px, 170px);
  align-items: center;
  gap: 7px;
  color: var(--muted-color);
  font-size: 0.85rem;
  font-weight: 800;
}

.editor-move-select-field select {
  width: 100%;
  min-height: 36px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.editor-media-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: stretch;
  gap: 12px;
}

.editor-image-preview {
  display: grid;
  place-items: center;
  min-height: 112px;
  margin-top: 27px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted-color);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

:root[data-theme="light"] .editor-image-preview {
  border-color: rgba(16, 19, 34, 0.12);
  background: rgba(255, 255, 255, 0.62);
}

.editor-image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 160px;
  object-fit: contain;
}

.editor-media-preview video,
.editor-media-preview audio {
  display: none;
  width: 100%;
  max-height: 160px;
}

.editor-media-preview:not([data-media-type="photo"]) img {
  display: none;
}

.editor-media-preview[data-media-type="photo"] img {
  display: block;
}

.editor-media-preview[data-media-type="video"] video,
.editor-media-preview[data-media-type="audio"] audio {
  display: block;
}

.editor-media-preview[data-media-type="audio"] {
  padding: 10px;
}

.editor-image-preview span {
  display: none;
  padding: 10px;
}

.editor-image-preview.is-empty img,
.editor-image-preview.is-empty video,
.editor-image-preview.is-empty audio,
.editor-image-preview.is-broken img,
.editor-image-preview.is-broken video,
.editor-image-preview.is-broken audio {
  display: none;
}

.editor-image-preview.is-empty span,
.editor-image-preview.is-broken span {
  display: block;
}

.editor-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--muted-color);
  font-weight: 800;
  text-align: center;
}

.invite-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.invite-link-btn {
  padding: 8px 12px;
  font-size: 0.9rem;
}

#host-controls {
  display: grid;
  justify-items: center;
  gap: 12px;
}

body.join-page {
  min-height: 100dvh;
  overflow-x: hidden;
}

.join-container {
  display: grid;
  place-items: center;
  min-height: calc(100dvh - 66px);
}

.join-card {
  display: grid;
  gap: 14px;
  width: min(460px, 100%);
  text-align: left;
}

.join-card h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.15;
}

.join-room-code {
  margin: 0;
  color: var(--muted-color);
  font-weight: 800;
}

.join-error {
  margin: 0;
  color: var(--accent-color);
  font-weight: 800;
}

.join-back-link {
  justify-self: center;
  color: var(--muted-color);
  font-weight: 800;
  text-decoration: none;
}

.join-back-link:hover {
  color: var(--text-color);
}

.join-qr-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: min(360px, 100%);
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.join-qr-image {
  display: block;
  width: min(220px, 52dvh, 72vw);
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}

.join-qr-panel p {
  max-width: 280px;
  margin: 0;
  color: var(--muted-color);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

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

  .editor-toolbar,
  .round-editor-header,
  .theme-editor-header,
  .question-editor-header {
    grid-template-columns: 1fr;
  }

  .editor-toolbar {
    position: static;
  }

  .question-grid {
    grid-template-columns: 1fr;
  }

  .editor-heading-actions {
    align-items: flex-start;
  }

  .editor-move-select-field {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .editor-move-select-field select {
    max-width: none;
  }

  .editor-media-field {
    grid-template-columns: 1fr;
  }

  .editor-image-preview {
    min-height: 180px;
    margin-top: 0;
  }
}

/* Big BUZZ button */
.big-button {
  width: min(680px, 96vw);
  height: 96px;
  background: linear-gradient(135deg, var(--festive-1), var(--festive-2));
  color: #101322;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.6px;
  box-shadow: 0 18px 40px rgba(255, 209, 102, 0.18);
}

.big-button:disabled {
  background: rgba(120, 120, 120, 0.5);
  cursor: not-allowed;
  box-shadow: none;
}

/* Views */
.view {
  width: 100%;
  height: 100%;
}

/* =========================
   Question View Overlay
   ========================= */

#question-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 160px;
  /* Leave space for footer */
  background: rgba(10, 14, 28, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

:root[data-theme="light"] #question-view {
  background: rgba(247, 249, 255, 0.92);
}

/* Light theme: make question text readable (JS sets white inline) */
:root[data-theme="light"] #question-content h1 {
  color: var(--text-color) !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

/* Preserve answer-reveal green heading */
:root[data-theme="light"] #question-content h1[style*="00ff00"] {
  color: #0fa958 !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* Host hint (JS sets #ccc inline) */
:root[data-theme="light"] #question-content p[style*="#ccc"],
:root[data-theme="light"] #question-content p[style*="rgb(204, 204, 204)"] {
  color: rgba(11, 21, 38, 0.72) !important;
}

/* Give the question card a subtle surface so white areas don't blend */
:root[data-theme="light"] .question-card-content {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(11, 21, 38, 0.10);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(8px);
}

.question-card-content {
  padding: 2rem;
  text-align: center;
  max-width: min(1100px, 92vw);
}

/* =========================
   Game Board
   ========================= */

.board-grid-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  width: 100%;
  height: 100%;
  justify-content: center;
}

.board-row {
  display: grid;
  grid-template-columns: minmax(150px, 20%) repeat(var(--board-cols, 5), 1fr);
  gap: var(--spacing-md);
  flex: 1;
  min-height: 0;
}

.theme-cell {
  background: linear-gradient(135deg, var(--primary-color-2), var(--primary-color));
  padding: 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  text-transform: none;
  text-align: center;
  font-size: clamp(0.8rem, 2vw, 1.1rem);
  overflow: hidden;
  word-break: break-word;
}

.question-cell {
  background: var(--card-bg-solid);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 4vw, 2.8rem);
  color: var(--question-points-color);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
  font-weight: 900;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

:root[data-theme="light"] .question-cell {
  border: 1px solid rgba(16, 19, 34, 0.08);
}

.question-cell.filler {
  background: transparent;
  cursor: default;
  pointer-events: none;
  border: none;
}

.question-cell:hover:not(.filler):not(.answered) {
  transform: scale(1.04);
  background-color: rgba(58, 160, 255, 0.12);
  z-index: 10;
}

.question-cell.answered {
  background-color: transparent;
  color: transparent;
  cursor: default;
  pointer-events: none;
  border: none;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .board-row {
    gap: var(--spacing-sm);
    grid-template-columns: minmax(70px, 15%) repeat(var(--board-cols, 5), 1fr);
  }

  .theme-cell {
    font-size: 0.72rem;
    padding: 6px;
  }

  .question-cell {
    font-size: 1.2rem;
  }

  #player-bar li {
    padding: 2px 10px;
    font-size: 0.85rem;
  }
}

/* =========================
   Intro Animation
   ========================= */
.intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

@keyframes intro-scroll {
  0% {
    transform: translateY(100vh);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translateY(-120%);
    /* Scroll completely off screen */
    opacity: 1;
  }
}

.intro-scroll-container {
  /* Duration set by JS */
  width: min(900px, 92vw);
  text-align: center;
  animation: intro-scroll var(--intro-duration, 5s) linear forwards;
}


/* Intro theme list (ROUND_INTRO) */
#intro-round-title {
  margin: 0 0 18px 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.4px;
  text-align: center;
}

#intro-theme-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
  width: min(900px, 92vw);
}

.intro-theme-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.25);
}

:root[data-theme="light"] .intro-theme-item {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(43, 131, 246, 0.18);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.10);
  backdrop-filter: blur(12px);
}

:root[data-theme="light"] .intro-theme-name {
  color: #0b1526;
}

:root[data-theme="light"] .intro-theme-meta {
  color: rgba(11, 21, 38, 0.78);
}

:root[data-theme="light"] #intro-round-title {
  color: #0b1526;
  text-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(43, 131, 246, 0.18);
  border-radius: 22px;
  padding: 10px 18px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  backdrop-filter: blur(12px);
}


.intro-theme-index {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
  color: #fff;
}

.intro-theme-name {
  font-size: clamp(1.05rem, 2.2vw, 1.5rem);
  font-weight: 900;
  letter-spacing: 0.2px;
  text-align: left;
  word-break: break-word;
}

.intro-theme-meta {
  color: var(--muted-color);
  font-weight: 800;
  white-space: nowrap;
}

/* =========================
   Score Animations
   ========================= */

@keyframes score-positive {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }

  20% {
    opacity: 1;
    transform: translateY(-20px) scale(1.2);
  }

  100% {
    opacity: 0;
    transform: translateY(-100px) scale(1);
  }
}

@keyframes score-negative {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }

  20% {
    opacity: 1;
    transform: translateY(20px) scale(1.2);
  }

  100% {
    opacity: 0;
    transform: translateY(60px) rotate(10deg) scale(0.8);
  }
}

.anim-positive {
  color: #00ff00;
  animation: score-positive 1s forwards ease-out;
}

.anim-negative {
  color: #ff0000;
  animation: score-negative 1s forwards ease-in;
}

.anim-funny {
  color: orange;
  animation: score-positive 1s forwards ease-out;
}


.question-text-btn {
  cursor: pointer;
  transition: transform 0.1s ease;
}

.question-text-btn:active {
  transform: scale(0.98);
  opacity: 0.8;
}

/* =========================
   Footer Styling
   ========================= */

#main-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 28, 0.80);
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

:root[data-theme="light"] #main-footer {
  background: rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(16, 19, 34, 0.10);
}

#player-bar {
  padding: 10px;
  background: rgba(58, 160, 255, 0.12);
  overflow-x: auto;
}

#player-bar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

#player-bar li {
  font-size: 1.05rem;
  padding: 6px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  white-space: nowrap;
  color: var(--text-color);
}

#controls-area {
  padding: 10px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 86px;
}

/* =========================
   Answering Player Label (Отвечает: ...)
   - Inline color in room.html is overridden for readability in light theme.
   ========================= */

/* =========================
   Answering Player Label (Отвечает: ...)
   - room.html sets inline `color: yellow;` so we override with CSS.
   - No "pill" background in any theme.
   ========================= */

#answering-player {
  color: var(--answering-color) !important;
  font-weight: 900;
  letter-spacing: 0.2px;
  display: block;
  text-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] #answering-player {
  text-shadow: none;
}

/* =========================
   Global no-select (apply .no-select behavior everywhere)
   - Keeps inputs/textarea selectable for typing/copying.
   ========================= */

body,
body * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* =========================
   Responsive Room Layout
   ========================= */

body.room-page {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: 0;
}

body.lobby-page {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
.btn,
.icon-btn,
.question-cell,
.question-text-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.16);
}

body.room-page #app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.room-page .app-header {
  position: relative;
  z-index: 20;
  flex-wrap: nowrap;
  min-height: 52px;
  padding: 8px 10px;
  gap: 8px;
}

body.room-page .brand {
  min-width: 0;
  flex: 0 1 auto;
}

body.room-page .brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.room-page .room-info {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

body.room-page .header-actions {
  flex: 0 0 auto;
  margin-left: 0;
  gap: 6px;
}

body.room-page .user-info {
  display: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: min(1.6dvh, 14px);
}

#lobby-view {
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
}

#board-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: min(1.4dvh, 12px);
}

#game-board {
  width: 100%;
  height: 100%;
  min-height: 0;
}

#next-round-container {
  flex: 0 0 auto;
  margin: 0;
  text-align: center;
}

.board-grid-container {
  min-height: 0;
}

.board-row {
  min-height: 0;
}

body.room-page #main-footer {
  position: relative;
  inset: auto;
  z-index: 20;
  flex: 0 0 auto;
  max-height: 42dvh;
  overflow: hidden;
}

body.room-page #player-bar {
  padding: min(1dvh, 8px) 8px;
  overflow: hidden;
}

body.room-page #player-bar ul {
  gap: 6px;
  max-height: min(15dvh, 88px);
  overflow: hidden;
}

body.room-page #player-bar li {
  min-height: 28px;
  max-width: min(48vw, 220px);
  padding: 4px 8px;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  line-height: 1.1;
}

body.room-page #host-score-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 0;
  padding: 6px 8px 0;
}

body.room-page #host-score-controls.hidden {
  display: none !important;
}

body.room-page #host-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

body.room-page #host-actions.hidden {
  display: none !important;
}

body.room-page #controls-area {
  min-height: min(11dvh, 78px);
  padding: min(1.2dvh, 8px) 8px;
}

body.room-page .big-button {
  width: min(680px, 100%);
  height: min(12dvh, 84px);
  min-height: 52px;
  font-size: 1.4rem;
}

body.room-page .score-input {
  width: 70px !important;
  min-height: 30px;
  margin-left: 6px !important;
  padding: 3px 6px !important;
  font-size: 0.9rem;
}

body.room-page #question-view {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: min(1.2dvh, 10px);
  padding: min(2dvh, 16px);
  overflow: hidden;
}

body.room-page #question-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.room-page .question-card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(2dvh, 16px);
  width: min(1100px, 100%);
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  padding: min(3dvh, 24px);
  overflow: hidden;
}

.question-text,
.answer-text {
  max-width: 100%;
  margin: 0;
  color: #fff;
  font-size: clamp(1.5rem, 7dvh, 4rem);
  font-weight: 900;
  line-height: 1.16;
  letter-spacing: 0;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.answer-text {
  color: #00ff00;
}

:root[data-theme="light"] .question-text {
  color: var(--text-color);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

:root[data-theme="light"] .answer-text {
  color: #0fa958;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.question-image {
  display: block;
  flex: 0 1 auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  min-height: 0;
  object-fit: contain;
  border-radius: 8px;
}

.question-media-card {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(900px, 100%);
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  padding: clamp(14px, 3dvh, 28px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 209, 102, 0.2), transparent 36%),
    linear-gradient(135deg, rgba(16, 26, 48, 0.82), rgba(7, 13, 28, 0.74));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

:root[data-theme="light"] .question-media-card {
  border-color: rgba(11, 21, 38, 0.12);
  background:
    radial-gradient(circle at 30% 20%, rgba(183, 121, 0, 0.16), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(236, 243, 255, 0.78));
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

.question-video-card {
  padding: 0;
  background: #050914;
}

.question-media-label {
  color: var(--text-color);
  font-size: clamp(1.5rem, 6dvh, 4rem);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
}

.question-media {
  display: block;
  max-width: 100%;
}

.question-video {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px;
}

.question-audio {
  width: min(620px, 100%);
}

.question-media-replay {
  width: min(260px, 100%);
  min-height: 40px;
}

.question-media-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--muted-color);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.host-answer-hint {
  max-width: 100%;
  max-height: 18dvh;
  margin: 0;
  overflow: hidden;
  color: rgba(238, 245, 255, 0.76);
  font-size: clamp(0.85rem, 2dvh, 1.05rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: pre-line;
}

:root[data-theme="light"] .host-answer-hint {
  color: rgba(11, 21, 38, 0.72);
}

body.room-page .question-card-content .continue-game-btn {
  width: min(420px, 100%);
  height: auto;
  min-height: 44px;
  margin-top: 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-color-2));
  font-size: 1rem;
  white-space: normal;
}

body.room-page #grading-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 0;
}

body.room-page #grading-controls.hidden {
  display: none !important;
}

.grade-correct {
  background: linear-gradient(135deg, #1aa45f, #0c6f3d);
}

.grade-incorrect {
  background: linear-gradient(135deg, #f04444, #a71326);
}

.grade-funny {
  background: linear-gradient(135deg, #ffb347, #d66a00);
}

.grade-pass {
  background: linear-gradient(135deg, #64748b, #334155);
}

body.room-page #answering-player {
  max-width: 100%;
  margin-top: 0;
  overflow: hidden;
  font-size: clamp(1rem, 3dvh, 2rem);
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.room-page #special-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: min(3dvh, 24px);
  overflow: hidden;
  text-align: center;
}

body.room-page #special-title {
  margin: 0 0 min(2.5dvh, 20px);
  color: var(--accent-color);
  font-size: clamp(2rem, 8dvh, 4rem);
  line-height: 1;
}

body.room-page #special-description {
  max-width: 800px;
  margin: 0 0 min(2.5dvh, 20px);
  font-size: clamp(1rem, 3dvh, 1.5rem);
  line-height: 1.25;
}

body.room-page #special-timer {
  color: var(--festive-2);
  font-size: clamp(1.2rem, 4dvh, 2rem);
  font-weight: 900;
}

body.room-page #winner-view {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 0;
  padding: min(3dvh, 24px) !important;
  overflow: hidden;
}

body.room-page #winner-view h1 {
  margin: 0 0 min(3dvh, 24px) !important;
  font-size: clamp(1.8rem, 6dvh, 3rem) !important;
  line-height: 1;
}

body.room-page #winner-view div {
  margin: 0 0 min(2.4dvh, 18px) !important;
  font-size: clamp(1.05rem, 4dvh, 2rem) !important;
  line-height: 1.15;
}

body.room-page #winner-view .btn {
  margin-top: min(3dvh, 24px) !important;
}

@media (max-width: 768px) {
  body.room-page .app-header {
    min-height: 44px;
    padding: 6px 8px;
  }

  body.room-page .brand-name {
    display: none;
  }

  body.room-page .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 16px;
  }

  body.room-page .room-info {
    font-size: 0.8rem;
  }

  body.room-page .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 16px;
  }

  body.room-page .header-actions .btn {
    min-height: 36px;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 0.86rem;
  }

  #game-container {
    padding: 6px;
  }

  .board-grid-container {
    gap: 4px;
  }

  .board-row {
    gap: 4px;
    grid-template-columns: minmax(54px, 0.8fr) repeat(var(--board-cols, 5), minmax(34px, 1fr));
  }

  .theme-cell {
    padding: 4px;
    border-radius: 8px;
    font-size: 0.68rem;
    line-height: 1.05;
  }

  .question-cell {
    min-height: 34px;
    border-radius: 8px;
    font-size: 1.05rem;
  }

  body.room-page #main-footer {
    max-height: 34dvh;
  }

  body.room-page #player-bar {
    padding: 4px 6px;
  }

  body.room-page #player-bar ul {
    justify-content: center;
    gap: 4px;
    max-height: 13dvh;
  }

  body.room-page #player-bar li {
    min-height: 24px;
    max-width: 46vw;
    padding: 3px 6px;
    font-size: 0.78rem;
  }

  body.room-page #host-score-controls {
    gap: 6px;
    padding: 4px 6px 0;
  }

  body.room-page #controls-area {
    min-height: 56px;
    padding: 4px 6px;
  }

  body.room-page .big-button {
    height: 56px;
    min-height: 48px;
    border-radius: 14px;
    font-size: 1.25rem;
  }

  body.room-page #host-score-controls .btn,
  body.room-page #host-actions .btn,
  body.room-page #grading-controls .btn {
    min-height: 42px;
    max-width: 100%;
    padding: 7px 10px;
    font-size: 0.86rem;
    line-height: 1.1;
    white-space: normal;
  }

  body.room-page .score-input {
    width: 58px !important;
    min-height: 28px;
    font-size: 0.8rem;
  }

  body.room-page #question-view {
    gap: 6px;
    padding: 6px;
  }

  body.room-page .question-card-content {
    gap: 8px;
    padding: 10px;
  }

  .question-text,
  .answer-text {
    font-size: clamp(1.25rem, 6dvh, 2.4rem);
    line-height: 1.12;
  }

  .host-answer-hint {
    max-height: 14dvh;
    font-size: 0.78rem;
  }

  body.room-page #answering-player {
    font-size: clamp(0.9rem, 2.5dvh, 1.3rem);
  }

  body.room-page #winner-view .btn {
    min-height: 42px;
    padding: 7px 10px;
    font-size: 0.86rem;
    line-height: 1.1;
  }
}
