:root {
  --bg: #171717;
  --bg-veil-1: rgba(23, 23, 23, 0.88);
  --bg-veil-2: rgba(23, 23, 23, 0.94);
  --bg-grid-line: rgba(255, 255, 255, 0.045);
  --bg-glow: rgba(116, 211, 145, 0.12);
  --panel: #222222;
  --panel-strong: #2a2a2a;
  --surface: #262626;
  --surface-hover: #303030;
  --surface-soft: #282828;
  --input-bg: #181818;
  --card: #eceff1;
  --card-text: #2c3034;
  --muted: #aeb4bd;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --green: #74d391;
  --cyan: #61d7e6;
  --pink: #e86f91;
  --orange: #f0a35e;
  --purple: #a871e8;
  --focus: #f7d674;
  --near-match: #f4d35e;
  --near-match-bg: #fff6d1;
  --row-1: #a871e8;
  --row-2: #61d7e6;
  --row-3: #e86f91;
  --row-4: #f0a35e;
  --linked-movie-color: #74d391;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="pink"] {
  --bg: #f4dce7;
  --bg-veil-1: rgba(244, 220, 231, 0.88);
  --bg-veil-2: rgba(244, 220, 231, 0.96);
  --bg-grid-line: rgba(121, 43, 78, 0.1);
  --bg-glow: rgba(210, 87, 141, 0.22);
  --panel: #fff4f9;
  --panel-strong: #edc7d8;
  --surface: #fff0f6;
  --surface-hover: #f4d3e2;
  --surface-soft: #fff9fc;
  --input-bg: #ffffff;
  --card: #fff7fa;
  --card-text: #3b2631;
  --muted: #765161;
  --line: rgba(121, 43, 78, 0.23);
  --shadow: 0 16px 40px rgba(126, 49, 83, 0.2);
  --green: #d2578d;
  --cyan: #bf4f9e;
  --pink: #dc6295;
  --orange: #d98272;
  --purple: #a95daf;
  --focus: #b7477a;
  --near-match: #d9aa31;
  --near-match-bg: #fff0bd;
  --row-1: #a95daf;
  --row-2: #bf4f9e;
  --row-3: #dc6295;
  --row-4: #d98272;
  --linked-movie-color: #b7477a;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(var(--bg-veil-1), var(--bg-veil-2)),
    repeating-linear-gradient(90deg, transparent 0 35px, var(--bg-grid-line) 35px 37px),
    radial-gradient(circle at 20% 0%, var(--bg-glow), transparent 36rem),
    var(--bg);
  color: #f5f5f5;
}

html[data-theme="pink"] body {
  color: #301c27;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.credits {
  width: min(1120px, calc(100% - 32px));
  margin: -34px auto 28px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.credits a {
  color: inherit;
  font-weight: 800;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 23, 23, 0.92);
  backdrop-filter: blur(14px);
}

html[data-theme="pink"] .topbar {
  background: rgba(255, 247, 251, 0.92);
}

.brand,
.top-actions,
.title-row,
.board-tools,
.answer-header,
.guess-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

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

.nav-link {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #f4f4f4;
  font-size: 0.9rem;
  font-weight: 800;
}

html[data-theme="pink"] .nav-link {
  color: #3b2430;
}

.nav-link:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--surface-hover);
}

html[data-theme="pink"] .nav-link:hover {
  border-color: rgba(151, 66, 103, 0.34);
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #f4f4f4;
  font-size: 0.82rem;
  font-weight: 800;
  user-select: none;
}

html[data-theme="pink"] .theme-switch {
  color: #3b2430;
}

.theme-switch-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.theme-switch-track {
  position: relative;
  width: 42px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #171717;
  transition: background 150ms ease, border-color 150ms ease;
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 21px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  transition: left 150ms ease, background 150ms ease;
}

.theme-toggle-input:not(:checked) + .theme-switch-track {
  background: #f5c6d8;
}

.theme-toggle-input:not(:checked) + .theme-switch-track .theme-switch-thumb {
  left: 5px;
  background: #b7477a;
}

.theme-toggle-input:focus-visible + .theme-switch-track {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 2px;
  flex: 0 0 auto;
}

.brand-mark span:nth-child(1) {
  background: var(--cyan);
}

.brand-mark span:nth-child(2) {
  background: var(--orange);
}

.brand-mark span:nth-child(3) {
  background: var(--pink);
}

.brand-mark span:nth-child(4) {
  background: var(--green);
}

.brand-text {
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.text-button,
.guess-row button {
  border: 1px solid var(--line);
  color: #f8f8f8;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

html[data-theme="pink"] .icon-button,
html[data-theme="pink"] .text-button,
html[data-theme="pink"] .guess-row button {
  color: #3b2430;
  box-shadow: 0 6px 16px rgba(116, 58, 84, 0.14);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button:hover,
.text-button:hover,
.guess-row button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: var(--surface-hover);
}

html[data-theme="pink"] .icon-button:hover,
html[data-theme="pink"] .text-button:hover,
html[data-theme="pink"] .guess-row button:hover {
  border-color: rgba(151, 66, 103, 0.34);
}

.icon-button:focus-visible,
.text-button:focus-visible,
.guess-row button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  grid-template-areas:
    "hero hero"
    "board answers";
  gap: 30px 56px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 46px 0 64px;
}

.library-layout {
  display: grid;
  gap: 28px;
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 46px 0 64px;
}

.hero-panel {
  grid-area: hero;
}

.puzzle-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html[data-theme="pink"] .puzzle-kicker {
  color: #301c27;
}

.puzzle-number {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
  color: #f4f4f4;
  letter-spacing: 0;
}

html[data-theme="pink"] .puzzle-number {
  color: #3b2430;
  box-shadow: 0 6px 16px rgba(116, 58, 84, 0.14);
}

.title-row {
  gap: 14px;
}

.grid-icon {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  grid-template-rows: repeat(3, 8px);
  gap: 4px;
  width: 52px;
  height: 52px;
  place-content: center;
  border-radius: 12px;
  background: var(--green);
}

.grid-icon span {
  border-radius: 2px;
  background: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #ffffff;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-transform: uppercase;
}

html[data-theme="pink"] h1,
html[data-theme="pink"] h2,
html[data-theme="pink"] .slot-title,
html[data-theme="pink"] .movie-title {
  color: #301c27;
}

h2 {
  font-size: 1.15rem;
  letter-spacing: 0;
}

#puzzleMeta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.board-section {
  grid-area: board;
}

.board-tools {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-label {
  margin-bottom: 5px;
  color: #d8dde3;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

html[data-theme="pink"] .section-label {
  color: #674254;
}

.tool-copy {
  max-width: 46rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.switch {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  color: #d4d9df;
  font-size: 0.86rem;
  font-weight: 700;
  user-select: none;
}

html[data-theme="pink"] .switch {
  color: #674254;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 10px;
}

.clue-card {
  appearance: none;
  position: relative;
  display: grid;
  grid-template-rows: 1fr;
  width: 100%;
  min-height: 116px;
  place-items: center;
  align-content: center;
  gap: 7px;
  overflow: hidden;
  border: 1px solid #d8dde1;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.65), transparent 40%),
    var(--card);
  box-shadow: inset 0 -5px 0 rgba(20, 25, 30, 0.08);
  color: var(--card-text);
  cursor: grab;
  font: inherit;
  text-align: center;
  touch-action: manipulation;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.clue-card.has-image {
  grid-template-rows: auto auto;
  padding: 13px 10px 12px;
}

.clue-card:active {
  cursor: grabbing;
}

.clue-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--row-color);
  content: "";
  opacity: 0;
}

.clue-card.is-row-solved {
  border-color: var(--row-color);
}

.clue-card.is-row-solved::before {
  opacity: 1;
}

.clue-card.is-near-match {
  border-color: var(--near-match);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 40%),
    var(--near-match-bg);
}

.clue-card.is-near-match::before {
  background: var(--near-match);
  opacity: 1;
}

.clue-card.is-selected {
  transform: translateY(-2px);
  box-shadow:
    inset 0 -5px 0 rgba(20, 25, 30, 0.08),
    0 0 0 3px color-mix(in srgb, var(--focus) 62%, transparent);
}

.clue-card.is-dragging {
  opacity: 0.55;
}

.clue-image {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
  box-shadow: 0 5px 12px rgba(20, 25, 30, 0.18);
  object-fit: cover;
  object-position: center top;
}

.clue-text {
  position: relative;
  z-index: 1;
  padding: 18px 14px;
  font-size: clamp(0.76rem, 1.8vw, 0.94rem);
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.clue-card.has-image .clue-text {
  display: grid;
  justify-items: center;
  padding: 0 6px;
}

.clue-card.has-image .clue-text span {
  display: block;
}

.answer-panel {
  grid-area: answers;
  align-self: start;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 34, 34, 0.92);
  box-shadow: var(--shadow);
}

html[data-theme="pink"] .answer-panel {
  background: rgba(255, 248, 251, 0.92);
}

.library-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 34, 34, 0.92);
  box-shadow: var(--shadow);
}

html[data-theme="pink"] .library-panel {
  background: rgba(255, 248, 251, 0.92);
}

.answer-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.text-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 800;
}

.guess-form {
  margin-bottom: 18px;
}

.board-status {
  min-height: 42px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 750;
}

.guess-form label,
.import-form label {
  display: block;
  margin-bottom: 8px;
  color: #d8dde3;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html[data-theme="pink"] .guess-form label,
html[data-theme="pink"] .import-form label {
  color: #674254;
}

.import-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.import-form textarea,
.import-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--input-bg);
  color: #ffffff;
  resize: vertical;
}

html[data-theme="pink"] .import-form textarea,
html[data-theme="pink"] .import-form input {
  color: #301c27;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.guess-row {
  gap: 8px;
}

.guess-row input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--input-bg);
  color: #ffffff;
}

html[data-theme="pink"] .guess-row input {
  color: #301c27;
}

.guess-row button {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 850;
}

.guess-feedback {
  min-height: 22px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.guess-feedback.is-success {
  color: var(--green);
}

.guess-feedback.is-error {
  color: #ffb0b0;
}

html[data-theme="pink"] .guess-feedback.is-error {
  color: #ad315f;
}

.answer-list {
  display: grid;
  gap: 9px;
}

.movie-table {
  display: grid;
  gap: 8px;
}

.movie-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.movie-title {
  color: #ffffff;
  font-weight: 800;
}

.movie-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.answer-slot {
  position: relative;
  display: grid;
  min-height: 56px;
  align-items: center;
  padding: 9px 12px 9px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

html[data-theme="pink"] .answer-slot {
  box-shadow: 0 8px 18px rgba(116, 58, 84, 0.12);
}

.answer-slot::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--slot-color);
  content: "";
}

.answer-slot.is-solved {
  border-color: rgba(116, 211, 145, 0.45);
}

.slot-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.slot-title {
  margin-top: 3px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.slot-title.is-hidden {
  color: #8e949b;
}

@media (max-width: 880px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "hero"
      "board"
      "answers";
    gap: 28px;
    padding-top: 34px;
  }

  .library-layout {
    width: min(100% - 20px, 960px);
    padding-top: 34px;
  }

  .answer-panel {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 10px 14px;
  }

  .brand-text {
    font-size: 0.9rem;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .theme-switch {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .game-layout {
    width: min(100% - 20px, 1120px);
  }

  .board-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .clue-card {
    min-height: 88px;
  }

  .clue-card.has-image {
    min-height: 104px;
    padding: 9px 5px 8px;
    gap: 5px;
  }

  .clue-image {
    width: 34px;
    height: 43px;
    border-width: 1px;
  }

  .clue-text {
    padding: 15px 8px;
    font-size: 0.68rem;
  }

  .clue-card.has-image .clue-text {
    padding: 0 3px;
    font-size: 0.63rem;
  }

  .answer-panel {
    padding: 16px;
  }
}
