*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

canvas,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
}

p {
  text-wrap: pretty;
}

#root,
#__next {
  isolation: isolate;
}

.button.hidden {
  display: none;
}

@font-face {
  font-family: 'DINMedium';
  src: url(../assets/fonts/DINPro\ Medium.otf) format('opentype');
  font-display: swap;
}

@font-face {
  font-family: 'DINBold';
  src: url(../assets/fonts/DINPro\ Bold.otf) format('opentype');
  font-display: swap;
}

:root {
  --font-medium: DINMedium, sans-serif;
  --font-bold: DINBold, sans-serif;

  --border-radius: 8px;
  --navbar-height: 70px;

  --background-color: oklch(0.16 0.09 268);
  --background-hover-color: oklch(0.26 0.09 268);
  --container-bg-color: oklch(0.1 0.09 268);
  --container-border-color: oklch(0.61 0.08 237);

  --accent-color: oklch(0.83 0.13 87);
  --accent-hover-color: oklch(0.73 0.13 87);
  --container-grid-color: oklch(0.33 0.13 87);

  --text-light-color: oklch(0.95 0.01 255);
  --text-dark-color: oklch(0.25 0.01 255);

  --primary-text-color: var(--text-light-color);
  --secondary-text-color: var(--text-dark-color);
  --piece-hover-color: var(--text-light-color);

  --success-color: #4ade80;
  --error-color: #f87171;
}

html[data-theme='mydei'] {
  --background-color: oklch(0.18 0.06 23);
  --background-hover-color: oklch(0.28 0.06 23);
  --container-bg-color: oklch(0.12 0.06 23);
  --container-border-color: oklch(0.76 0.06 60);

  --accent-color: oklch(0.82 0.08 59);
  --accent-hover-color: oklch(0.72 0.08 59);
  --container-grid-color: oklch(0.32 0.08 59);
}

html[data-theme='dhpt'] {
  --background-color: oklch(0.33 0.01 48);
  --background-hover-color: oklch(0.43 0.01 48);
  --container-bg-color: oklch(0.27 0.01 48);
  --container-border-color: oklch(0.81 0.07 193);

  --accent-color: oklch(0.84 0.11 84);
  --accent-hover-color: oklch(0.74 0.11 84);
  --container-grid-color: oklch(0.34 0.11 84);
}

html[data-theme='anaxa'] {
  --background-color: oklch(0.26 0.05 245);
  --background-hover-color: oklch(0.36 0.05 245);
  --container-bg-color: oklch(0.2 0.05 245);
  --container-border-color: oklch(0.54 0.2 22);

  --accent-color: oklch(0.82 0.06 153);
  --accent-hover-color: oklch(0.72 0.06 153);
  --container-grid-color: oklch(0.32 0.06 153);
}

html[data-theme='cerydra'] {
  --background-color: oklch(0.26 0.12 261);
  --background-hover-color: oklch(0.36 0.12 261);
  --container-bg-color: oklch(0.2 0.12 261);
  --container-border-color: oklch(0.91 0.04 252);

  --accent-color: oklch(0.87 0.11 199);
  --accent-hover-color: oklch(0.77 0.11 199);
  --container-grid-color: oklch(0.37 0.11 199);
}

html[data-theme='hysilens'] {
  --background-color: oklch(0.2 0.05 336);
  --background-hover-color: oklch(0.3 0.05 336);
  --container-bg-color: oklch(0.14 0.05 336);
  --container-border-color: oklch(0.51 0.17 8);

  --accent-color: oklch(0.78 0.13 267);
  --accent-hover-color: oklch(0.68 0.13 267);
  --container-grid-color: oklch(0.28 0.13 267);
}

html[data-theme='cipher'] {
  --background-color: oklch(0.16 0.01 43);
  --background-hover-color: oklch(0.26 0.01 43);
  --container-bg-color: oklch(0.1 0.01 43);
  --container-border-color: oklch(0.83 0.01 295);

  --accent-color: oklch(0.66 0.17 264);
  --accent-hover-color: oklch(0.56 0.17 264);
  --container-grid-color: oklch(0.16 0.17 264);
}

html[data-theme='evernight'] {
  --background-color: oklch(0.18 0.02 312);
  --background-hover-color: oklch(0.28 0.02 312);
  --container-bg-color: oklch(0.12 0.02 312);
  --container-border-color: oklch(0.48 0.19 29);

  --accent-color: oklch(0.82 0.14 342);
  --accent-hover-color: oklch(0.72 0.14 342);
  --container-grid-color: oklch(0.32 0.14 342);
}

html[data-theme='hyacine'] {
  --background-color: oklch(0.25 0.16 7);
  --background-hover-color: oklch(0.35 0.16 7);
  --container-bg-color: oklch(0.19 0.16 7);
  --container-border-color: oklch(0.82 0.1 193);

  --accent-color: oklch(0.82 0.09 14);
  --accent-hover-color: oklch(0.72 0.09 14);
  --container-grid-color: oklch(0.32 0.09 14);
}

html[data-theme='tribbie'] {
  --background-color: oklch(0.93 0 106);
  --background-hover-color: oklch(0.83 0 106);
  --container-bg-color: oklch(0.99 0 106);
  --container-border-color: oklch(0.6 0.06 63);

  --accent-color: oklch(0.48 0.23 29);
  --accent-hover-color: oklch(0.58 0.23 29);
  --container-grid-color: oklch(0.98 0.23 29);
}

html[data-theme='aglaea'] {
  --background-color: oklch(0.93 0.05 96);
  --background-hover-color: oklch(0.83 0.05 96);
  --container-bg-color: oklch(0.99 0.05 96);
  --container-border-color: oklch(0.5 0.05 56);

  --accent-color: oklch(0.49 0.1 84);
  --accent-hover-color: oklch(0.59 0.1 84);
  --container-grid-color: oklch(0.99 0.1 84);
}

html[data-theme='phainon'] {
  --background-color: oklch(0.87 0.01 286);
  --background-hover-color: oklch(0.77 0.01 286);
  --container-bg-color: oklch(0.93 0.01 286);
  --container-border-color: oklch(0.36 0.03 288);

  --accent-color: oklch(0.47 0.16 264);
  --accent-hover-color: oklch(0.57 0.16 264);
  --container-grid-color: oklch(0.97 0.16 264);
}

html[data-theme='castorice'] {
  --background-color: oklch(0.91 0.01 6);
  --background-hover-color: oklch(0.81 0.01 6);
  --container-bg-color: oklch(0.97 0.01 6);
  --container-border-color: oklch(0.35 0.12 296);

  --accent-color: oklch(0.46 0.13 322);
  --accent-hover-color: oklch(0.56 0.13 322);
  --container-grid-color: oklch(0.96 0.13 322);
}

html[data-theme='cyrene'] {
  --background-color: oklch(0.93 0.03 349);
  --background-hover-color: oklch(0.83 0.03 349);
  --container-bg-color: oklch(0.99 0.03 349);
  --container-border-color: oklch(0.72 0.1 241);

  --accent-color: oklch(0.49 0.22 303);
  --accent-hover-color: oklch(0.59 0.22 303);
  --container-grid-color: oklch(0.99 0.22 303);
}

:is(
  html[data-theme='tribbie'],
  html[data-theme='aglaea'],
  html[data-theme='phainon'],
  html[data-theme='castorice'],
  html[data-theme='cyrene']
) {
  --primary-text-color: var(--text-dark-color);
  --secondary-text-color: var(--text-light-color);
  --piece-hover-color: var(--text-dark-color);

  --success-color: #16a34a;
  --error-color: #dc2626;
}

body {
  margin: 0;
  font-family: var(--font-medium);
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 6rem;
  justify-content: center;
  align-items: center;
  background-color: var(--background-color);
  padding-top: var(--navbar-height);
  color: var(--primary-text-color);
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

.top-navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--navbar-height);
  background-color: var(--container-bg-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 100;
}

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

.navbar-brand div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: fit-content;
}

.navbar-logo {
  height: 40px;
  width: 40px;
  color: var(--accent-color);
}

.navbar-title {
  font-family: var(--font-bold);
  font-size: 2rem;
  color: var(--primary-text-color);
  padding-bottom: 3px;
}

.navbar-links {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: 2rem;
  font-size: 1.5rem;
}

.navbar-controls i {
  color: var(--primary-text-color);
}

.theme-selector-container {
  position: relative;
}

.icon-button {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font-size: inherit;
  line-height: 1;
}

.theme-dropdown {
  position: absolute;
  top: var(--navbar-height);
  right: 0;
  background-color: var(--container-bg-color);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  padding: 0 0.5rem 0.5rem 0.5rem;
  z-index: 110;
  display: flex;
  gap: 0.5rem;
  visibility: hidden;
}

.theme-dropdown-column {
  display: flex;
  flex-direction: column;
  min-width: 80px;
}

.theme-column-header {
  font-size: 0.8rem;
  padding: 0.5rem;
  opacity: 0.8;
  font-family: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.theme-dropdown.show {
  visibility: visible;
}

.theme-option {
  background: none;
  border: none;
  color: var(--primary-text-color);
  padding: 0.5rem;
  text-align: left;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 100%;
  cursor: pointer;
  margin: 0;
}

.main-content {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem 6rem;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.canvas-group,
.canvas-container {
  width: min(60vh, 60vw);
  height: min(60vh, 60vw);
}

.canvas-group {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.canvas-container {
  position: relative;
  border-radius: 50%;
  border: min(2vh, 2vw) solid var(--container-border-color);
  overflow: hidden;
  background-color: var(--container-bg-color);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.puzzle-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  user-select: none;
  width: 100%;
  flex-basis: 100%;
}

.puzzle-group-name {
  font-family: var(--font-bold);
  font-size: 1.8rem;
}

.puzzle-counter {
  font-size: 1.3rem;
}

.puzzle-info-buttons {
  margin-top: 0.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  font-size: 1.2rem;
  border: none;
  padding: 0 20px;
  border-radius: var(--border-radius);
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background-color: var(--accent-color);
  color: var(--secondary-text-color);
}

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

.button:disabled {
  filter: brightness(0.4);
}

.reset-button {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--primary-bg-color);
  color: var(--primary-text-color);
  border: transparent;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.reset-button:hover {
  background-color: var(--background-hover-color);
}

.reset-button i {
  font-size: 1.2rem;
}

.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(8px) brightness(0.5);
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--background-color);
  color: var(--primary-text-color);
  padding: 1.5rem 2rem 2rem 2rem;
  border-radius: calc(var(--border-radius) * 2);
  text-align: center;
  position: relative;
  width: fit-content;
  min-width: 280px;
  max-width: 90vw;
}

#info-modal .modal-content {
  max-width: 600px;
}

#level-select-modal .modal-content {
  width: 90vw;
  max-width: 900px;
}

.modal-header {
  font-family: DINBold;
  font-size: 2rem;
  margin-bottom: 1rem;
}

.modal-stats {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-label {
  font-size: 1rem;
  opacity: 0.8;
}

.stat-value {
  font-family: DINBold;
  font-size: 1.8rem;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.next-puzzle-countdown {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.next-label {
  font-size: 0.9rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-buttons button,
.modal-buttons .button {
  flex: 1;
  margin-top: 1rem;
}

.level-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 70vh;
  width: 100%;
  overflow-y: auto;
  text-align: left;
  padding-right: 1rem;
}

.level-group-header {
  color: var(--primary-text-color);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.level-group-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem;
}

.level-group {
  grid-column: 1 / -1;
  margin-bottom: 2rem;
}

.level-group:last-child {
  margin-bottom: 0;
}

.level-select-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background-color: var(--container-bg-color);
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  padding: 1rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.level-number {
  font-size: 2.2rem;
  font-family: var(--font-bold);
  line-height: 1;
  color: var(--primary-text-color);
}

.level-select-preview.active {
  border-color: var(--accent-color);
  background-color: var(--background-hover-color);
}

.level-select-preview.active .level-number {
  color: var(--accent-color);
}

.level-date {
  font-size: 0.9rem;
  opacity: 0.8;
  font-family: var(--font-medium);
}

.level-stats {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 1rem;
  width: 100%;
}

.level-stat i {
  font-size: 0.8rem;
  color: var(--accent-color);
  width: 18px;
  text-align: center;
  opacity: 0.8;
}

.level-stats.unplayed {
  align-items: center;
  opacity: 0.3;
  font-size: 0.8rem;
  font-style: italic;
  border-top: none;
}

#close-level-select-button {
  margin-top: 2rem;
}

.info {
  text-align: left;
  max-width: 100%;
}

.info p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background-color: var(--container-bg-color);
}

::-webkit-scrollbar-thumb {
  background-color: var(--accent-color);
  border-radius: 8px;
}

@media (hover: hover) and (pointer: fine) {
  .navbar-controls i:hover {
    color: var(--accent-color);
  }

  .icon-button:hover i {
    color: var(--accent-color);
  }

  .theme-option:hover {
    background-color: var(--background-hover-color);
  }

  .primary-button:hover:not(:disabled) {
    background-color: var(--accent-hover-color);
  }

  .secondary-button:hover:not(:disabled) {
    background-color: var(--background-hover-color);
    border-color: var(--accent-hover-color);
  }

  .level-select-preview:hover {
    border-color: var(--primary-text-color);
  }
}

/* ===== NAVBAR LINKS ===== */
.mobile-menu-toggle {
  display: none;
  font-size: 1.2rem;
}

.navbar-links {
  display: flex;
  gap: 2rem;
}

.navbar-links a {
  color: var(--primary-text-color);
  text-decoration: none;
  font-size: 1.1rem;
  position: relative;
}

.navbar-links a span {
  position: relative;
  display: inline-block;
}

.navbar-links a span::before {
  content: attr(data-hover);
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  color: var(--accent-color);
}

.navbar-links a.active span,
.navbar-links a:hover span {
  color: var(--accent-color);
}

/* Visibility Helpers */
.mobile-only {
  display: none;
}

/* ===== EDITOR PAGE STYLES ===== */
.editor-layout {
  gap: 3rem;
}

.editor-left-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.editor-right-column {
  display: flex;
  justify-content: center;
  align-items: center;
}

#solution-container-wrapper {
  width: min(75vh, 75vw);
  height: min(75vh, 75vw);
}

#start-container-wrapper {
  width: min(65vh, 65vw);
  height: min(65vh, 65vw);
}

.editor-card {
  width: 30vw;
  background-color: var(--container-bg-color);
  border-radius: var(--border-radius);
  padding: 1rem;
}

.editor-card h2 {
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--primary-text-color);
  margin-bottom: 1rem;
}

#piece-palette {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.palette-item {
  background-color: var(--background-color);
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.palette-item:hover {
  border-color: var(--primary-text-color);
}

.keybind {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--primary-text-color);
  opacity: 0.8;
  z-index: 1;
  pointer-events: none;
}

.palette-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

#controls-panel,
#controls-panel-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

#controls-panel-secondary {
  margin-top: 0.5rem;
}

.editor-button {
  background-color: var(--background-color);
  position: relative;
  color: var(--primary-text-color);
  border: none;
  padding: 0.6rem 0.8rem;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 calc(33.33% - 0.5rem);
  min-width: 0;
}

.button-label {
  font-size: 0.85rem;
  font-weight: 500;
}

.editor-button:hover:not(:disabled) {
  background-color: var(--background-hover-color);
}

#delete-button {
  position: relative;
  overflow: hidden;
}

.delete-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background-color: var(--primary-text-color);
  z-index: 0;
  transition: width 0.9s linear;
}

#delete-button .button-label,
#delete-button .fa-solid {
  z-index: 1;
}

#controls-panel button .fa-solid,
#controls-panel-secondary button .fa-solid {
  font-size: 1rem;
}

#export-button {
  background-color: var(--accent-color);
  color: var(--secondary-text-color);
}

#export-button:disabled {
  filter: brightness(0.5);
}

#export-button:hover:not(:disabled) {
  background-color: var(--accent-hover-color);
}

.queue-card {
  max-height: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.queue-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background-color: var(--background-color);
  border-radius: var(--border-radius);
  font-size: 0.85rem;
}

.queue-item.empty {
  opacity: 0.5;
}

.queue-item.today {
  border-left: 3px solid var(--accent-color);
}

.queue-date {
  font-weight: 500;
  color: var(--primary-text-color);
}

.queue-status {
  color: var(--primary-text-color);
  font-size: 0.8rem;
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-status.scheduled {
  color: var(--accent-color);
}

.queue-loading {
  color: var(--primary-text-color);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
}

/* Queue Previews */
.queue-preview-container {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background-color: var(--card-background-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.queue-preview-empty {
  opacity: 0.3;
}

.queue-preview {
  display: block;
}

.queue-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 0.1rem;
}

.queue-info .queue-status {
  text-align: left;
  max-width: 100%;
}

.publish-modal-layout {
  display: flex;
  gap: 2rem;
  text-align: left;
}

.publish-modal-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.publish-modal-right {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-button {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--primary-text-color);
  border-radius: 4px;
}

/* ===== EXPLORE PAGE STYLES ===== */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.explore-preview-card {
  background-color: var(--container-bg-color);
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  overflow: hidden;
}

.explore-preview-card:hover {
  border-color: var(--primary-text-color);
}

#explore-gameplay-view {
  padding-top: 0;
}

.explore-preview-card canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1 / 1;
  touch-action: pan-y;
}

@media (max-width: 900px) {
  .explore-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== EXPLORE CONTROLS ===== */
.explore-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  position: sticky;
  top: var(--navbar-height);
  background-color: var(--background-color);
  z-index: 80;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--container-bg-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  flex: 1;
  max-width: 200px;
  height: 36px;
  box-sizing: border-box;
}

.search-box i {
  color: var(--primary-text-color);
  opacity: 0.6;
  font-size: 0.8rem;
}

.search-box input {
  background: none;
  border: none;
  color: var(--primary-text-color);
  font-size: 1rem;
  width: 100%;
  outline: none;
}

.search-box input::placeholder {
  color: var(--primary-text-color);
  opacity: 0.5;
}

.filter-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Custom Select Wrapper */
.custom-select {
  position: relative;
  display: inline-block;
}

.custom-select select {
  background-color: var(--container-bg-color);
  color: var(--primary-text-color);
  border: none;
  padding: 0.5rem 2rem 0.5rem 1rem;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  height: 36px;
  min-width: 140px;
  box-sizing: border-box;
}

.custom-select i {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--primary-text-color);
  opacity: 0.6;
  pointer-events: none;
}

/* Puzzle Card with Metadata */
.explore-preview-card {
  display: flex;
  flex-direction: column;
}

.puzzle-card-info {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.puzzle-card-title {
  font-weight: 500;
  font-size: 1.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.puzzle-card-author {
  font-size: 1rem;
  opacity: 0.8;
}

.puzzle-card-date {
  font-size: 1rem;
  opacity: 0.6;
}

/* 2x2 Grid Layout */
.puzzle-card-grid {
  display: flex;
}

.grid-left,
.grid-right {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
}

.grid-right {
  text-align: left;
}

.avg-value {
  font-weight: 600;
  color: var(--primary-text-color);
}

.avg-inline {
  font-size: 1rem;
  color: color-mix(in srgb, var(--primary-text-color) 70%, transparent);
}

/* Stats Row */
.puzzle-card-stats {
  display: flex;
  font-size: 0.85rem;
}

.stats-group {
  display: flex;
  gap: 0.5rem;
}

.stats-group.plays {
  margin-left: 1rem;
}

.stats-group span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.puzzle-card-stats i {
  font-size: 1rem;
}

.share-card-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--primary-text-color);
  padding: 0.25rem;
  transition: all 0.2s ease;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.share-card-btn:hover {
  opacity: 1;
  color: var(--accent-color);
}

.share-btn-text {
  font-size: 0.9rem;
  font-family: var(--font-medium);
}

.star-rating {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.star-rating i {
  font-size: 1.5rem;
  opacity: 0.4;
}

.star-rating i.active {
  color: var(--accent-color);
  opacity: 1;
}

.no-puzzles-message {
  text-align: center;
  font-size: 1.2rem;
  opacity: 0.7;
  padding: 2rem;
}

/* ===== FORM INPUTS ===== */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  opacity: 0.8;
}

.form-group input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background-color: var(--container-bg-color);
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  color: var(--primary-text-color);
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.form-group input::placeholder {
  color: var(--primary-text-color);
  opacity: 0.4;
}

.publish-form h2 {
  margin-bottom: 1rem;
}

.publish-hint {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-top: 1rem;
}

/* Checkbox Styles */
.checkbox-group {
  margin-top: 1rem;
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
  font-size: 1rem;
  opacity: 1;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  height: 0;
  width: 0;
}

.checkmark {
  height: 20px;
  width: 20px;
  background-color: var(--container-bg-color);
  border: 1px solid var(--accent-color);
  border-radius: 4px;
  position: relative;
}

.checkbox-container:hover input ~ .checkmark {
  background-color: var(--background-hover-color);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--accent-color);
}

.checkmark:after {
  content: '';
  position: absolute;
  display: none;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid var(--secondary-text-color);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.6;
  cursor: pointer;
}

html[data-theme='tribbie'] input[type='date']::-webkit-calendar-picker-indicator,
html[data-theme='aglaea'] input[type='date']::-webkit-calendar-picker-indicator,
html[data-theme='phainon'] input[type='date']::-webkit-calendar-picker-indicator,
html[data-theme='castorice'] input[type='date']::-webkit-calendar-picker-indicator,
html[data-theme='cyrene'] input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(0);
}

/* ===== CARD HEADER WITH BUTTON ===== */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.card-header h2 {
  margin: 0;
}

.help-button {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.piece-counter {
  font-size: 0.9rem;
  color: var(--primary-text-color);
  font-weight: 500;
}

.piece-counter.limit-reached {
  color: var(--error-color);
}

/* ===== HELP MODAL ===== */
.help-modal-content {
  max-width: 500px;
}

.help-modal-content h2 {
  margin-bottom: 1rem;
}

.help-content {
  text-align: left;
}

.help-section {
  margin-bottom: 1.25rem;
}

.help-section h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
}

.help-section p,
.help-section ul {
  font-size: 0.9rem;
  opacity: 0.9;
  margin: 0;
}

.help-section ul {
  padding-left: 1.25rem;
}

.help-section li {
  margin-bottom: 0.3rem;
}

kbd {
  background-color: var(--container-bg-color);
  border: 1px solid var(--primary-text-color);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-family: monospace;
  font-size: 0.85rem;
  opacity: 0.8;
}

/* ===== LOADING INDICATOR ===== */
.loading-indicator {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--navbar-height));
  background-color: var(--background-color);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.loading-indicator.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-indicator p {
  opacity: 0.8;
  font-size: 1.1rem;
  font-family: var(--font-medium);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--container-bg-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== COMPLETION VOTE SECTION ===== */
.completion-vote-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1rem 0;
  gap: 0.5rem;
}

.completion-vote-section p {
  font-size: 0.95rem;
  opacity: 0.8;
  margin: 0;
}

/* ===== PERFORMANCE COMPARISON ===== */
.performance-comparison {
  margin: 1rem 0;
  padding: 0.75rem;
  background-color: var(--container-bg-color);
  border-radius: var(--border-radius);
}

.comparison-heading {
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  margin-bottom: 0.5rem;
}

.comparison-items {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.comparison-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.comparison-value {
  font-size: 1rem;
  font-weight: 600;
}

.comparison-value.better {
  color: var(--success-color);
}

.comparison-value.worse {
  color: var(--error-color);
}

.comparison-value.same {
  color: var(--accent-color);
}

.comparison-label {
  font-size: 0.7rem;
  opacity: 0.6;
  text-transform: uppercase;
}

.completed-badge {
  color: #4ade80;
  font-size: 1.2rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.form-error {
  color: #ff5555;
  margin-top: 1rem;
  padding-bottom: 1rem;
  font-size: 0.9rem;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
}

.form-error.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
}

.error-title {
  font-family: var(--font-bold);
  font-size: 4.5rem;
}

.error-message {
  font-size: 2rem;
  opacity: 0.8;
  max-width: 500px;
  margin-bottom: 1rem;
}

.error-actions {
  display: flex;
  gap: 1rem;
}

@media (max-width: 600px) {
  :root {
    --navbar-height: 40px;
    --border-radius: 4px;
  }

  body {
    -webkit-tap-highlight-color: transparent;
  }

  .top-navbar {
    padding: 0 1rem;
    justify-content: space-between;
  }

  .navbar-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
  }

  .navbar-brand div {
    gap: 0.5rem;
  }

  .navbar-logo {
    height: 24px;
    width: 24px;
  }

  .navbar-title {
    font-size: 1rem;
  }

  .navbar-controls {
    gap: 1rem;
    font-size: 1rem;
  }

  .mobile-menu-toggle {
    display: flex;
    margin-right: 0;
  }

  .navbar-links {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--navbar-height));
    background-color: var(--container-bg-color);
    flex-direction: column;
    padding: 2rem 1.5rem;
    gap: 1rem;
    box-sizing: border-box;
    border-bottom: 1px solid var(--container-border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 99;
    overflow-y: auto;
    transform: none;
  }

  .navbar-links.show {
    display: flex;
  }

  .navbar-links a {
    font-size: 1rem;
    padding: 0.75rem 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .main-content {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .canvas-group,
  .canvas-container {
    width: min(75vh, 75vw);
    height: min(75vh, 75vw);
  }

  .puzzle-info {
    margin-top: 0.5rem;
    gap: 2px;
  }

  .puzzle-info-buttons {
    gap: 0.5rem;
  }

  .button {
    font-size: 1rem;
    padding: 4px 8px;
  }

  .puzzle-group-name {
    font-size: 1rem;
    text-align: center;
  }

  .puzzle-counter {
    font-size: 0.8rem;
  }

  .level-grid {
    max-width: 100%;
    padding: 0 0.5rem;
    max-height: 60vh;
  }

  .level-group-header {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .level-group-buttons {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
  }

  .level-select-preview {
    padding: 0.5rem;
    gap: 0.3rem;
  }

  .level-number {
    font-size: 0.8rem;
  }

  .level-date {
    font-size: 0.7rem;
  }

  .theme-dropdown {
    right: 0;
    top: var(--navbar-height);
    padding: 0.5rem;
    gap: 0.5rem;
    width: auto;
    max-width: 95vw;
  }

  .theme-dropdown-column {
    min-width: 80px;
  }

  .theme-column-header {
    font-size: 0.6rem;
    padding: 0 0.4rem 0.4rem 0.4rem;
  }

  .theme-option {
    padding: 0.4rem;
    font-size: 0.8rem;
    margin: 0;
  }

  .info p {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .mobile-only {
    display: block;
  }

  .desktop-only {
    display: none;
  }

  .drawer-brand,
  .drawer-controls {
    display: none;
  }

  .editor-layout {
    flex-direction: column;
  }

  .editor-card {
    width: 90vw;
  }

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

  .explore-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .filter-controls {
    justify-content: center;
  }

  .error-title {
    font-size: 2.5rem;
  }

  .error-image {
    max-width: 280px;
  }

  ::-webkit-scrollbar {
    width: 4px;
  }

  /* Publish Modal Mobile Fix */
  .publish-modal-layout {
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
  }

  .publish-modal-left {
    width: 100%;
  }

  .publish-modal-right {
    width: 100%;
    justify-content: center;
  }

  #start-container-wrapper {
    width: min(40vh, 60vw);
    height: min(40vh, 60vw);
  }
}
