* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  max-width: 440px;
  width: 100%;
  border: 1px solid #e5e7eb;
}

h1 {
  font-size: 22px;
  font-weight: 600;
  color: #111;
  margin-bottom: 0;
}

.subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #6b7280;
  text-align: center;
  margin-bottom: 4px;
}

.info-btn {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.info-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  color: #111;
  transform: scale(1.05);
}

.info-btn:active {
  transform: scale(0.95);
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  position: relative;
  animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.modal-close:hover {
  background: #e5e7eb;
  color: #111;
}

.modal-content h2 {
  font-size: 18px;
  font-weight: 600;
  color: #111;
  margin-bottom: 16px;
  padding-right: 32px;
}

.modal-content p {
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
  margin-bottom: 14px;
}

.modal-content p:last-child {
  margin-bottom: 0;
}

.modal-content strong {
  color: #111;
  font-weight: 600;
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
}

.badge:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.badge-label {
  color: #6b7280;
  font-weight: 500;
}

.badge-value {
  color: #111;
  font-weight: 600;
}

twisty-player {
  width: 100%;
  max-width: 320px;
  height: 320px;
}

.status {
  font-size: 14px;
  font-weight: 500;
  color: #666;
  min-height: 20px;
  text-align: center;
}

.status.solving {
  color: #111;
  font-weight: 600;
}

.status.solved {
  color: #111;
  font-weight: 600;
}

.status.error {
  color: #ef4444;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.button-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  width: 44px;
  height: 44px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #d1d5db;
  background: white;
  color: #111;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 6px;
  user-select: none;
}

button:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
  background: #e5e7eb;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.action-buttons {
  margin-top: 4px;
}

.action-buttons button {
  width: 100px;
  height: 40px;
  font-size: 14px;
}

button.primary {
  background: #111;
  color: white;
  border: 1px solid #111;
}

button.primary:hover:not(:disabled) {
  background: #374151;
  border-color: #374151;
}

button.primary:active:not(:disabled) {
  background: #1f2937;
}

/* Solve group with settings */
.solve-group {
  position: relative;
  display: inline-flex;
}

.solve-btn {
  width: 60px;
  border-radius: 6px 0 0 6px;
}

.settings-btn {
  width: 40px !important;
  border-radius: 0 6px 6px 0;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 16px;
}

.settings-btn:hover:not(:disabled) {
  background: #374151;
}

/* Settings popup */
.settings-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 6px;
  min-width: 200px;
  display: none;
  z-index: 100;
  animation: popupSlideIn 0.15s ease-out;
}

.settings-popup.visible {
  display: block;
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Arrow pointing down */
.settings-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid white;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.05));
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.settings-option:hover {
  background: #f9fafb;
}

.settings-option.active {
  background: #f3f4f6;
}

.option-radio {
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s;
}

.settings-option.active .option-radio {
  border-color: #111;
}

.settings-option.active .option-radio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: #111;
  border-radius: 50%;
}

.option-content {
  flex: 1;
}

.option-title {
  font-size: 14px;
  font-weight: 600;
  color: #111;
  line-height: 1.3;
}

.option-details {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.3;
  margin-top: 2px;
}

.solution {
  width: 100%;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #111;
  text-align: center;
  min-height: 40px;
  display: none;
  word-wrap: break-word;
}

.solution.visible {
  display: block;
}

.solution strong {
  display: block;
  margin-bottom: 6px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #111;
  font-size: 13px;
}

@media (max-width: 600px) {
  .container {
    padding: 20px;
    gap: 14px;
  }

  h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 13px;
    gap: 6px;
  }

  .info-btn {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    font-size: 11px;
  }

  .modal-content {
    padding: 20px;
    max-width: calc(100% - 32px);
  }

  .modal-content h2 {
    font-size: 17px;
    margin-bottom: 14px;
  }

  .modal-content p {
    font-size: 13px;
  }

  .modal-close {
    width: 28px;
    height: 28px;
    font-size: 22px;
    top: 12px;
    right: 12px;
  }

  .badges {
    gap: 6px;
  }

  .badge {
    font-size: 12px;
    padding: 3px 8px;
    gap: 5px;
  }

  twisty-player {
    max-width: 280px;
    height: 280px;
  }

  button {
    width: 40px;
    height: 40px;
    font-size: 13px;
  }

  .action-buttons button {
    width: 90px;
    height: 38px;
  }

  .solve-btn {
    width: 52px;
  }

  .settings-btn {
    width: 38px !important;
  }

  .settings-popup {
    left: auto;
    right: 0;
  }

  .settings-popup::after {
    left: auto;
    right: 24px;
  }
}

@media (max-height: 800px) {
  body {
    padding: 12px;
  }
  
  .container {
    padding: 20px;
    gap: 12px;
  }
  
  h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 13px;
  }

  .modal-content {
    padding: 20px;
  }

  .modal-content h2 {
    font-size: 17px;
  }

  .modal-content p {
    font-size: 13px;
  }
  
  twisty-player {
    max-width: 280px;
    height: 280px;
  }
  
  button {
    width: 40px;
    height: 40px;
  }
  
  .action-buttons button {
    width: 90px;
    height: 36px;
  }

  .solve-btn {
    width: 54px;
  }

  .settings-btn {
    width: 36px;
  }
}