/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: #e5e7eb;
  background: #0f172a;
  font-size: 14px;
  line-height: 1.5;
}

/* App layout */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 100;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app__header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #f8fafc;
}

.header__actions {
  display: flex;
  gap: 0.75rem;
}

/* Menu toggle button */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

.menu-toggle:hover {
  background: #334155;
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: #e5e7eb;
  border-radius: 1px;
  transition: all 0.3s ease;
}

.hamburger {
  position: relative;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
}

.hamburger::before {
  top: -0.375rem;
}

.hamburger::after {
  top: 0.375rem;
}

/* Hamburger animation */
.menu-toggle.active .hamburger {
  background: transparent;
}

.menu-toggle.active .hamburger::before {
  transform: rotate(45deg);
  top: 0;
}

.menu-toggle.active .hamburger::after {
  transform: rotate(-45deg);
  top: 0;
}

/* Buttons */
button {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #475569;
  background: #334155;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  min-height: 2.25rem;
}

button:hover:not(:disabled) {
  background: #475569;
  border-color: #64748b;
}

button.primary {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

button.primary:hover:not(:disabled) {
  background: #2563eb;
  border-color: #2563eb;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* GitHub link styling */
.github-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #475569;
  background: #334155;
  color: #e5e7eb;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 2.25rem;
  min-width: 2.25rem;
}

.github-link:hover {
  background: #475569;
  border-color: #64748b;
  color: #f8fafc;
}

.github-link:active {
  transform: scale(0.98);
}

.github-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Main content layout */
.app__content {
  display: grid !important;
  grid-template-columns: 320px 1fr !important;
  grid-template-areas: "sidebar main" !important;
  height: 100%;
  overflow: hidden;
  /* Debug border to see grid areas */
  /* border: 2px solid red; */
}

/* Ensure desktop layout overrides mobile at larger screens */
@media (min-width: 769px) {
  .app__content {
    display: grid !important;
    grid-template-columns: 320px 1fr !important;
    grid-template-areas: "sidebar main" !important;
    grid-template-rows: auto !important;
    position: static !important;
  }

  .sidebar {
    grid-area: sidebar !important;
    position: static !important;
    left: auto !important;
    width: auto !important;
    height: 100% !important;
    z-index: auto !important;
    max-width: none !important;
    padding: 1.5rem !important;
    transition: none !important;
    top: auto !important;
  }

  .main {
    grid-area: main !important;
  }
}

/* Sidebar */
.sidebar {
  grid-area: sidebar !important;
  padding: 1.5rem;
  background: #1e293b;
  border-right: 1px solid #334155;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  /* Ensure sidebar stays in normal grid position on desktop */
  position: static !important;
  left: auto !important;
  width: auto !important;
  z-index: auto !important;
  max-width: none !important;
  transition: none !important;
  /* Force visibility for debugging */
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important;
  /* Debug border */
  /* border: 3px solid blue !important; */
}

/* Panels */
.panel {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
}

.field .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  background: #1e293b;
  color: #e5e7eb;
  font-size: 0.875rem;
  transition: border-color 0.2s ease;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="range"] {
  width: 100%;
  margin: 0.5rem 0;
}

.speed-value {
  text-align: right;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
}

/* Palette */
.palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.palette__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  border: 2px dashed #475569;
  border-radius: 0.5rem;
  background: #1e293b;
  cursor: grab;
  user-select: none;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.palette__item:hover {
  border-color: #64748b;
  background: #334155;
}

.palette__item:active {
  cursor: grabbing;
}

.palette__item.dragging {
  opacity: 0.7;
}

.palette__item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #1a1a1a;
  border-color: #333;
}

.palette__item.disabled:hover {
  border-color: #333;
  background: #1a1a1a;
}

.palette__item .label {
  font-weight: 600;
  color: #e5e7eb;
  font-size: 0.75rem;
}

/* Drag cursor preview */
.drag-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.9;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.drag-cursor .piece-mini {
  transform: scale(0.55);
  transform-origin: top left;
}

/* Mini piece previews */
.piece-mini {
  position: relative;
  width: 64px;
  height: 64px;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 0.375rem;
  display: grid;
  place-items: center;
}

.piece-mini__rect {
  border-radius: 0.25rem;
}

.piece-mini--2x2 .piece-mini__rect {
  width: 44px;
  height: 44px;
  background: var(--color-2x2);
}

.piece-mini--2x1 .piece-mini__rect {
  width: 44px;
  height: 20px;
  background: var(--color-2x1);
}

.piece-mini--1x2 .piece-mini__rect {
  width: 20px;
  height: 44px;
  background: var(--color-1x2);
}

.piece-mini--1x1 .piece-mini__rect {
  width: 20px;
  height: 20px;
  background: var(--color-1x1);
}

/* Main content area */
.main {
  grid-area: main !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  overflow: hidden;
  background: #0f172a;
  /* Debug border */
  /* border: 3px solid green !important; */
}

.board-wrapper {
  display: grid;
  place-items: center;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 1rem;
  padding: 1.5rem 1.1875rem; /* 24px top/bottom, 19px left/right */
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  width: 360px; /* 320px canvas + 38px padding + 2px border */
  box-sizing: border-box;
  /* Debug border */
  /* border: 3px solid orange !important; */
}

.board-wrapper canvas {
  background: var(--grid-bg);
  border: 1px solid #475569;
  border-radius: 0.5rem;
  width: 320px;
  height: 400px;
}

.status {
  margin: 1rem 0;
  min-height: 1.5rem;
  font-size: 0.875rem;
  color: #94a3b8;
  font-weight: 500;
  text-align: center;
}

.playback-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem; /* More padding for better spacing */
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  width: 360px; /* Match board wrapper width exactly */
  box-sizing: border-box;
}

.playback-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 260px;
  padding: 0.75rem 1rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.75rem;
}

.speed-control label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
  min-width: fit-content;
}

.speed-control input[type="range"] {
  flex: 1;
  margin: 0;
}

.speed-control .speed-value {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
  min-width: fit-content;
  text-align: right;
}

.progress-control {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0;
  margin: 0.25rem 0;
}

.progress-control input[type="range"] {
  width: 100%;
  margin: 0;
  height: 4px;
  background: #334155;
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

/* WebKit browsers (Chrome, Safari, Edge) */
.progress-control input[type="range"]::-webkit-slider-track {
  width: 100%;
  height: 4px;
  background: #334155;
  border-radius: 2px;
  border: none;
}

.progress-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #1e293b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 2;
}

.progress-control input[type="range"]::-webkit-slider-thumb:hover {
  background: #2563eb;
  transform: scale(1.1);
}

.progress-control input[type="range"]:disabled {
  opacity: 0.5;
}

.progress-control input[type="range"]:disabled::-webkit-slider-thumb {
  cursor: not-allowed;
  transform: none;
}

.progress-control input[type="range"]:disabled::-webkit-slider-thumb:hover {
  background: #3b82f6;
  transform: none;
}

/* Progress fill using a pseudo-element for WebKit */
.progress-control input[type="range"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  background: #3b82f6;
  border-radius: 2px;
  width: var(--progress-width, 0%);
  z-index: 1;
}

/* Firefox */
.progress-control input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: #334155;
  border-radius: 2px;
  border: none;
}

.progress-control input[type="range"]::-moz-range-progress {
  height: 4px;
  background: #3b82f6;
  border-radius: 2px;
  border: none;
}

.progress-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #1e293b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-control input[type="range"]::-moz-range-thumb:hover {
  background: #2563eb;
  transform: scale(1.1);
}

.playback-controls button {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  padding: 0;
  min-height: auto;
  transition: all 0.2s ease;
}

.playback-controls button:hover:not(:disabled) {
  background: #475569;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.playback-controls button:active:not(:disabled) {
  transform: scale(0.95);
}

.playback-controls button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: #1e293b;
  border-color: #475569;
  color: #64748b;
  transform: none;
  box-shadow: none;
}

.playback-controls button:disabled:hover {
  transform: none;
  box-shadow: none;
  background: #1e293b;
}

/* Blue styling for play button when puzzle not solved */
.playback-controls button.solve-mode {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.playback-controls button.solve-mode:hover:not(:disabled) {
  background: #2563eb;
  border-color: #2563eb;
}

/* Help section */
.help {
  margin: 0;
  padding-left: 1.25rem;
  list-style-type: none;
}

.help li {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
  position: relative;
}

.help li::before {
  content: "•";
  color: #64748b;
  font-weight: bold;
  position: absolute;
  left: -1rem;
}

.help code {
  background: #334155;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  color: #e5e7eb;
}

/* Import label styling */
.import-label {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #475569;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  background: #334155;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  min-height: 2.25rem;
  width: 100%;
  color: #e5e7eb;
}

.import-label:hover {
  background: #475569;
  border-color: #64748b;
}

.import-label input[type="file"] {
  display: none;
}

/* Puzzle panel organization */
.puzzle-saved,
.puzzle-io {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #1e293b;
  border-radius: 0.5rem;
  border: 1px solid #334155;
}

.puzzle-saved:last-child,
.puzzle-io:last-child {
  margin-bottom: 0;
}

.puzzle-saved label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 0.5rem;
}

.puzzle-saved select {
  margin-bottom: 0.75rem;
}

.puzzle-saved-actions,
.puzzle-default-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.puzzle-default-actions {
  margin-top: 0.75rem;
}

.puzzle-io-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

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

.modal-content {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid #334155;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #f8fafc;
}

.modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #334155;
  color: #e5e7eb;
}

.modal-body {
  padding: 1.25rem;
}

.save-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Star indicator for default puzzle */
.puzzle-star {
  color: #fbbf24;
  margin-right: 0.5rem;
}

.puzzle-star::before {
  content: "★";
}

/* Canvas rendering theme */
:root {
  --grid-color: #475569; /* slate-600 */
  --grid-bg: #0f172a;   /* dark panel bg */
  --piece-border: #0f172a; /* keeps borders dark against light pieces */
  --selected: #10b981;
  --goal: #f59e0b;

  /* Piece colors by type (light for readability) */
  --color-2x2: #fbbf24; /* amber-400 */
  --color-2x1: #7dd3fc; /* sky-300 */
  --color-1x2: #86efac; /* green-300 */
  --color-1x1: #fda4af; /* rose-300 */
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .app__content {
    grid-template-columns: 300px 1fr;
  }

  .sidebar {
    padding: 1rem;
  }

  .panel {
    padding: 1rem;
  }
}

/* Tablet styles */
@media (max-width: 1024px) {
  .app__content {
    grid-template-columns: 280px 1fr;
  }

  .sidebar {
    padding: 0.75rem;
  }

  .palette {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .palette__item {
    padding: 0.75rem;
  }
}

/* Mobile styles */
@media (max-width: 768px) {
  /* Show hamburger menu */
  .menu-toggle {
    display: flex;
  }

  /* Disable desktop drag behavior on mobile */
  .palette__item {
    cursor: pointer;
  }

  .palette__item:active {
    cursor: pointer;
  }

  .palette__item.disabled {
    cursor: not-allowed;
  }

  .palette__item.disabled:active {
    cursor: not-allowed;
    transform: none;
    background: #1a1a1a;
  }

  /* Header improvements for mobile */
  .app__header {
    padding: 0.75rem 1rem;
  }

  .app__header h1 {
    font-size: 1.125rem;
  }

  .header__actions {
    gap: 0.5rem;
  }

  .header__actions button {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    min-height: 2rem;
  }

  .github-link {
    padding: 0.375rem 0.75rem;
    min-height: 2rem;
    min-width: 2rem;
  }

  .github-icon {
    width: 18px;
    height: 18px;
  }

  /* Mobile layout - sidebar overlay */
  .app__content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
    position: relative;
    /* Debug border */
    /* border: 3px solid red !important; */
  }

  .sidebar {
    grid-area: none !important;
    position: fixed !important;
    top: 0;
    left: -100% !important;
    width: 85vw !important;
    max-width: 320px !important;
    height: 100vh !important;
    z-index: 50 !important;
    border-right: 1px solid #334155;
    border-bottom: none;
    padding: 5rem 1rem 1rem !important;
    transition: left 0.3s ease !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Override desktop styles */
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
    background: #1e293b !important;
  }

  .sidebar.open {
    left: 0 !important;
  }

  /* Mobile overlay */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
  }

  /* Main content adjustments */
  .main {
    grid-area: none !important;
    padding: 1rem;
    justify-content: center !important;
    align-items: center !important;
    gap: 1rem;
    /* Force full width and height for proper centering */
    width: 100% !important;
    height: 100% !important;
    /* Debug border */
    /* border: 3px solid yellow !important; */
  }

  /* Board sizing for mobile */
  .board-wrapper {
    width: auto !important;
    max-width: 100%;
    padding: 1rem;
    margin-bottom: 0.75rem;
    margin-left: auto !important;
    margin-right: auto !important;
    /* Debug border */
    /* border: 3px solid orange !important; */
  }

  .board-wrapper canvas {
    width: min(280px, 90vw);
    height: min(350px, calc(90vw * 1.25));
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    display: block;
  }

  .board-wrapper canvas.mobile-placement-mode {
    cursor: copy;
  }

  .board-wrapper canvas.drag-delete-mode {
    cursor: not-allowed;
  }

  /* Apply delete cursor to entire body when dragging to delete */
  body.drag-delete-active {
    cursor: not-allowed !important;
  }

  body.drag-delete-active * {
    cursor: not-allowed !important;
  }

  /* Playback controls mobile optimization */
  .playback-controls {
    width: auto;
    max-width: 100%;
    padding: 1rem;
    gap: 1rem;
    margin-left: auto !important;
    margin-right: auto !important;
    /* Debug border */
    /* border: 3px solid purple !important; */
  }

  .playback-buttons {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .playback-controls button {
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
  }

  .speed-control {
    max-width: none;
    width: 100%;
  }

  /* Panel optimizations for mobile */
  .panel {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .panel h2 {
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
  }

    /* Palette mobile layout */
  .palette {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

    .palette__item {
    padding: 0.5rem 0.25rem;
    gap: 0.25rem;
    position: relative;
    transition: all 0.2s ease;
    min-height: 4.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .palette__item:active {
    transform: scale(0.95);
    background: #475569;
  }

  .palette__item .label {
    font-size: 0.6875rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .piece-mini {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .piece-mini--2x2 .piece-mini__rect {
    width: 24px;
    height: 24px;
  }

  .piece-mini--2x1 .piece-mini__rect {
    width: 24px;
    height: 12px;
  }

  .piece-mini--1x2 .piece-mini__rect {
    width: 12px;
    height: 24px;
  }

  .piece-mini--1x1 .piece-mini__rect {
    width: 12px;
    height: 12px;
  }

  /* Button improvements for touch */
  button {
    min-height: 2.75rem;
    font-size: 0.875rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Form field improvements */
  input[type="number"],
  input[type="text"],
  select {
    min-height: 2.75rem;
    font-size: 1rem; /* Prevent zoom on iOS */
  }

  /* Puzzle management mobile optimization */
  .puzzle-saved select {
    font-size: 1rem;
    min-height: 6rem;
  }

  .puzzle-saved-actions,
  .puzzle-default-actions,
  .puzzle-io-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  /* Help section mobile */
  .help li {
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
  }

  /* Modal mobile improvements */
  .modal-content {
    width: 95%;
    margin: 1rem;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .save-options {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}
