@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&family=Newsreader:opsz,wght@6..72,300;400;500;600;700&display=swap");

/* Base styles */

/* Hidden class */
.hidden {
  display: none;
}

/* Screen reader only class - visually hidden but accessible to screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
:root {
  /* Typography */
  --font-primary: "Manrope", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-display: "Newsreader", "Times New Roman", serif;
  --font-rtl: "Rabar", "Noto Kufi Arabic", "Manrope", sans-serif;
  --font-timer: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;

  /* Light mode colors */
  --bg-color: #f6f4f1;
  --text-color: #2b2623;
  --text-color-muted: #706864;
  --text-secondary: #615a56;
  --container-bg: #f6f4f1;
  --header-bg: #a57865;
  --header-text: #1f1b18;
  --btn-bg: #a57865;
  --btn-hover: #8a6553;
  --timer-color: #8a6553;
  --card-bg: #fbfaf8;
  --border-color: rgba(27, 24, 22, 0.08);
  --shadow-color: rgba(17, 12, 9, 0.1);
  --ready-color: #4caf50;
  --running-color: #e74c3c;
  --inspection-color: #f39c12;
  --hover-bg: #ffffff;
  --hover-color: rgba(0, 0, 0, 0.04);
  --toggle-off: var(--surface-2);
  --toggle-on: var(--accent-color);
  --toggle-knob: var(--hover-bg);
  --accent-color: #a57865;
  --accent-color-hover: #8a6553;

  /* Surfaces & depth */
  --surface-1: #ffffff;
  --surface-2: #f8f6f3;
  --surface-3: #f1ece7;
  --bg-gradient:
    radial-gradient(
      900px circle at 20% 0%,
      rgba(165, 120, 101, 0.12),
      transparent 55%
    ),
    radial-gradient(
      700px circle at 80% 10%,
      rgba(0, 0, 0, 0.04),
      transparent 60%
    );
  --header-surface: rgba(255, 255, 255, 0.72);
  --shadow-soft: 0 16px 40px rgba(17, 12, 9, 0.08);
  --shadow-lift: 0 8px 20px rgba(17, 12, 9, 0.12);
  --shadow-press: 0 3px 8px rgba(17, 12, 9, 0.18);
  --focus-ring: rgba(165, 120, 101, 0.25);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* RTL Support */
[dir="rtl"] {
  text-align: right;
  font-family: var(--font-rtl) !important;
}

/* Apply Rabar font to all text elements in RTL mode */
[dir="rtl"] body,
[dir="rtl"] .header-title,
[dir="rtl"] .header-center,
[dir="rtl"] .event-option,
[dir="rtl"] .settings-title,
[dir="rtl"] .settings-section-title,
[dir="rtl"] .checkbox-label,
[dir="rtl"] .stats-title,
[dir="rtl"] .stat-label,
[dir="rtl"] .times-panel-title,
[dir="rtl"] .solve-details-title,
[dir="rtl"] .solve-details-section-title,
[dir="rtl"] .radio-label,
[dir="rtl"] button,
[dir="rtl"] .action-button,
[dir="rtl"] #new-scramble,
[dir="rtl"] #settings-save,
[dir="rtl"] #solve-details-save,
[dir="rtl"] #clear-times,
[dir="rtl"] label,
[dir="rtl"]
  span:not(.cubing-icon):not(.puzzle-icon):not(.fas):not(.far):not(.fal):not(
    .fab
  ),
[dir="rtl"] .fmc-start-prompt {
  font-family: var(--font-rtl) !important;
}

/* Keep timer font as monospace for all languages */
.timer {
  font-family: monospace !important;
}

[dir="rtl"] .header-left {
  justify-self: end;
}

[dir="rtl"] .header-right {
  justify-self: start;
}

[dir="rtl"] .cubing-icon,
[dir="rtl"] .puzzle-icon {
  margin-right: 0;
  margin-left: 10px;
}

/* RTL: Flip new scramble button icon 180 degrees */
[dir="rtl"] #new-scramble .fa-random {
  transform: rotate(180deg);
}

/* RTL: Settings section title icons spacing */
[dir="rtl"] .settings-section-title i {
  margin-right: 0;
  margin-left: 8px;
}

/* RTL: Responsive settings section title icons spacing */
@media (max-width: 768px) {
  [dir="rtl"] .settings-section-title i {
    margin-left: 6px;
  }
}

@media (max-width: 480px) {
  [dir="rtl"] .settings-section-title i {
    margin-left: 5px;
  }
}

[dir="rtl"] .times-panel {
  left: auto;
  right: -350px;
  transition:
    right 0.3s ease,
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

[dir="rtl"] .times-panel.show {
  left: auto;
  right: 0;
}

/* RTL button positioning */
[dir="rtl"] .times-toggle {
  right: auto;
  left: 15px;
}

/* In LTR, settings button is on the right */
.header-right {
  justify-self: end;
}

.header-left {
  justify-self: start;
}

/* In RTL, settings button is on the left */
[dir="rtl"] header {
  grid-template-columns: 1fr auto 1fr;
  direction: rtl;
}

/* Swap header elements for RTL */
[dir="rtl"] .header-right {
  grid-column: 1;
  justify-self: start;
}

[dir="rtl"] .header-center {
  grid-column: 2;
  justify-self: center;
}

[dir="rtl"] .header-left {
  grid-column: 3;
  justify-self: end;
}

[dir="rtl"] .container {
  transition:
    margin-right 0.3s ease,
    width 0.3s ease,
    transform 0.3s ease;
}

[dir="rtl"] .times-panel-close {
  margin-right: 0;
  margin-left: 20px;
}

[dir="rtl"] .times-panel-header {
  padding-left: 0;
  padding-right: 25px;
}

[dir="rtl"] body.panel-open .container {
  margin-left: 0;
  margin-right: 350px;
}

/* Dropdown selectors (language, timer mode, decimal places, microphone, inspection sound, and smart cube brand) */
.language-selector,
.timer-mode-selector,
.decimal-places-selector,
.microphone-selector,
.inspection-sound-selector {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--surface-1);
  color: var(--text-color);
  font-size: 0.9rem;
  transition:
    border-color 0.3s ease,
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

.language-selector:focus,
.timer-mode-selector:focus,
.decimal-places-selector:focus,
.inspection-sound-selector:focus {
  outline: none;
  border-color: var(--header-bg);
}

/* Disabled state for decimal places and inspection sound selectors */
.decimal-places-selector:disabled,
.inspection-sound-selector:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--card-bg);
  color: var(--text-color-muted);
}

.settings-option.disabled {
  opacity: 0.6;
}

.settings-option.disabled .dropdown-label span {
  color: var(--text-color-muted);
}

/* Dropdown label */
.dropdown-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

/* Disabled option styling */
select option:disabled {
  color: #888;
  font-style: italic;
  background-color: #f0f0f0;
}

.dark-mode select option:disabled {
  background-color: #444;
  color: #aaa;
}

/* Dark mode colors */
.dark-mode {
  --bg-color: #141210;
  --text-color: #f2ece7;
  --text-color-muted: #b5aaa2;
  --text-secondary: #cbbeb6;
  --container-bg: #141210;
  --header-bg: #7b5c4a;
  --header-text: #f7f1ed;
  --btn-bg: #8a6553;
  --btn-hover: #7b5c4a;
  --timer-color: #d4b29e;
  --card-bg: #1f1b18;
  --border-color: rgba(242, 236, 231, 0.08);
  --shadow-color: rgba(0, 0, 0, 0.4);
  --ready-color: #66bb6a;
  --running-color: #ef5350;
  --inspection-color: #ffb74d;
  --hover-bg: #26211d;
  --hover-color: rgba(255, 255, 255, 0.06);
  --toggle-off: var(--surface-3);
  --toggle-on: var(--accent-color);
  --toggle-knob: var(--hover-bg);
  --accent-color: #d4b29e;
  --accent-color-hover: #c09a84;

  --surface-1: #1f1b18;
  --surface-2: #221e1a;
  --surface-3: #2a2521;
  --bg-gradient:
    radial-gradient(
      900px circle at 20% 0%,
      rgba(212, 178, 158, 0.08),
      transparent 55%
    ),
    radial-gradient(
      700px circle at 80% 10%,
      rgba(0, 0, 0, 0.25),
      transparent 60%
    );
  --header-surface: rgba(20, 18, 16, 0.72);
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.35);
  --shadow-lift: 0 8px 20px rgba(0, 0, 0, 0.45);
  --shadow-press: 0 3px 8px rgba(0, 0, 0, 0.6);
  --focus-ring: rgba(212, 178, 158, 0.3);
}

body {
  font-family: var(--font-primary);
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
  letter-spacing: 0.01em;
  line-height: 1.6;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  /* Disable pull-to-refresh on mobile devices to prevent conflicts with swipe gestures */
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  -webkit-overflow-scrolling: touch;
}

.container {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  width: 100%;
  background-color: transparent;
  overflow: hidden;
  transition: background-color 0.3s ease;
  /* Additional overscroll prevention for container */
  overscroll-behavior: none;
  overscroll-behavior-y: none;
}

/* Header styles */
header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 52.8px;
  background-color: var(--header-surface);
  color: var(--header-text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.header-title,
.settings-title,
.solve-details-title,
.stats-title,
.times-panel-title {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.header-left {
  position: absolute;
  left: 15px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.header-right {
  position: absolute;
  right: 15px;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.privacy-link {
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 8px;
  border-radius: 10px;
  border: 2px dotted var(--text-color);
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.privacy-link:hover {
  background-color: var(--hover-color);
  opacity: 1;
  text-decoration: none;
}

/* Hide privacy text on mobile, show only icon */
@media (max-width: 768px) {
  .privacy-link .privacy-text {
    display: none;
  }

  .privacy-link {
    padding: 6px;
  }
}

.privacy-policy-note {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.8;
  padding: 8px 12px;
  margin-top: 10px;
  background-color: var(--card-bg);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  width: 100%;
}

.privacy-policy-note i {
  color: var(--accent-color);
  font-size: 0.85rem;
}

.privacy-policy-link {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

.privacy-policy-link:hover {
  text-decoration: underline;
}

/* RTL header adjustments */
[dir="rtl"] .header-right {
  right: auto;
  left: 15px;
}

[dir="rtl"] .header-left {
  left: auto;
  right: 15px;
}

h1 {
  color: white;
  margin: 0;
  font-size: 1.2rem;
}

.event-selector {
  position: relative;
  display: inline-block;
  min-width: 150px;
}

.event-selector-btn {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background-color: transparent;
  color: var(--header-text);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
  text-align: left;
  transition: background-color 0.3s ease;
}

.event-selector-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Light mode support for event selector */
body:not(.dark-mode) .event-selector-btn {
  color: var(--text-color);
}

body:not(.dark-mode) .event-selector-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.event-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background-color: var(--container-bg);
  border: none;
  border-radius: 4px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  margin-top: 5px;
  transition: background-color 0.3s ease;
}

.event-dropdown.show {
  display: block;
}

.event-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.3s ease;
}

.event-option:hover {
  background-color: var(--card-bg);
}

/* Event option with sub-dropdown indicator */
.event-option.has-variants {
  justify-content: space-between;
  position: relative;
}

.event-option.has-variants::after {
  content: "\f054";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 10px;
  opacity: 0.6;
  margin-left: 8px;
}

/* Sub-dropdown container */
.event-sub-dropdown {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 200px;
  background-color: var(--container-bg);
  border-radius: 4px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 101;
  max-height: 350px;
  overflow-y: auto;
  display: none;
  margin-left: 2px;
}

.event-option:hover > .event-sub-dropdown,
.event-sub-dropdown:hover {
  display: block;
}

/* Sub-dropdown option */
.sub-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.3s ease;
  white-space: nowrap;
}

.sub-option:hover {
  background-color: var(--card-bg);
}

.sub-option.selected {
  background-color: var(--accent-color);
  color: white;
}

/* Sub-group header */
.sub-group-header {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--container-bg);
  border-bottom: 1px solid var(--border-color);
}

/* Sub-dropdown divider */
.sub-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* Non-WCA section header */
.event-section-header {
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  background-color: var(--card-bg);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

/* Current variant indicator */
.current-variant-indicator {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: normal;
}

/* RTL support for sub-dropdown */
[dir="rtl"] .event-option.has-variants::after {
  content: "\f053";
  margin-left: 0;
  margin-right: 8px;
}

[dir="rtl"] .event-sub-dropdown {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: 2px;
}

/* Mobile-friendly sub-dropdown */
@media (max-width: 768px) {
  .event-sub-dropdown {
    position: fixed;
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 300px;
    max-height: 60vh;
    margin: 0;
  }

  .event-option.has-variants::after {
    content: "\f078";
  }
}

/* Event divider */
.event-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 8px 0;
}

.sessions-divider {
  margin-top: 12px;
  margin-bottom: 12px;
  background-color: var(--accent-color);
  opacity: 0.5;
}

/* New Session option */
.new-session-option {
  font-weight: bold;
  color: var(--accent-color);
}

.new-session-option:hover {
  background-color: rgba(165, 120, 101, 0.1);
}

.new-session-option .fas {
  color: var(--accent-color);
  margin-right: 10px;
}

/* Cubing icons styles */
.cubing-icon,
.puzzle-icon {
  vertical-align: middle;
  margin-right: 10px;
}

/* Main content layout */
.main-content {
  display: grid;
  grid-template-areas:
    "scramble scramble"
    "timer timer"
    "stats visualization";
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 1fr;
  height: calc(100% - 20px); /* Leave space at bottom */
  padding: 10px;
  gap: 15px;
  position: relative;
  margin-bottom: 20px; /* Add space at bottom */
}

@media (min-width: 1400px) {
  .main-content {
    grid-template-areas:
      "scramble scramble scramble"
      "timer timer timer"
      "stats . visualization";
    grid-template-columns: minmax(260px, 420px) 1fr minmax(260px, 420px);
  }
}

/* Scramble section */
.scramble-section {
  grid-area: scramble;
  text-align: center;
}

/* Ensure scramble section stays centered even in RTL mode */
[dir="rtl"] .scramble-section {
  text-align: center !important;
}

/* Lottie Loader Styles */
.lottie-loader {
  display: inline-block;
  margin: 0 auto;
  vertical-align: middle;
}

/* Scramble loader - now uses Lottie */
.scramble-loader {
  display: inline-block;
  width: 50px;
  height: 50px;
  margin: 0 auto;
  vertical-align: middle;
}

/* Fallback for when Lottie fails to load */
.scramble-loader.fallback {
  border: 3px solid rgba(165, 120, 101, 0.3);
  border-radius: 50%;
  border-top-color: #a57865;
  animation: spin 1s ease-in-out infinite;
}

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

/* Dark mode fallback loader */
.dark-mode .scramble-loader.fallback {
  border: 3px solid rgba(165, 120, 101, 0.2);
  border-top-color: #a57865;
}

/* Footer Styles */
.app-footer {
  background-color: var(--card-bg);
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
  padding: 2rem 0 1rem;
  color: var(--text-color);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.footer-section h4 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.footer-section p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--primary-color);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
  padding-top: 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-bottom a {
  color: var(--primary-color);
  text-decoration: none;
}

.footer-bottom a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

/* Contact Info Styles */
.contact-info {
  margin: 1rem 0;
}

.contact-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.8rem;
  padding: 0.5rem;
  background-color: var(--bg-color);
  border-radius: 6px;
  border-left: 3px solid var(--primary-color);
}

.contact-item i {
  color: var(--primary-color);
  margin-right: 0.8rem;
  width: 20px;
  text-align: center;
}

.contact-item strong {
  margin-right: 0.5rem;
}

.scramble {
  font-family: monospace;
  font-size: 1.6rem; /* Base font size - dynamically controlled by JS */
  padding: 12px;
  background-color: var(--card-bg);
  border-radius: 8px;
  min-height: 50px;
  max-height: 15vh; /* Limit height to ~15% of viewport */
  overflow-y: auto;
  overflow-x: hidden;
  display: block; /* Changed from flex for proper scrolling */
  text-align: center;
  direction: ltr;
  word-wrap: break-word;
  line-height: 1.7; /* Increased line height */
  letter-spacing: 0.1em; /* Added letter spacing */
  box-shadow: 0 2px 5px var(--shadow-color);
  color: var(--text-color);
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease,
    font-size 0.2s ease;
  position: relative;
}

/* Custom scrollbar for scramble box */
.scramble::-webkit-scrollbar {
  width: 8px;
}

.scramble::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 8px;
  margin: 4px 0; /* Add margin to keep track away from edges */
}

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

.scramble::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* Firefox scrollbar styling */
.scramble {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* Scramble section wrapper */
.scramble-section {
  display: flex;
  flex-direction: column;
}

/* Scramble box wrapper for gradient positioning */
.scramble-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Gradient overlay to indicate scrollable content */
.scramble-scroll-gradient-bottom,
.scramble-scroll-gradient-top {
  position: absolute;
  left: 0;
  right: 12px; /* Offset to avoid covering scrollbar */
  height: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1; /* Low z-index to stay below dropdowns */
}

.scramble-scroll-gradient-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--card-bg) 0%, transparent 100%);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.scramble-scroll-gradient-top {
  top: 0;
  background: linear-gradient(to bottom, var(--card-bg) 0%, transparent 100%);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.scramble-scroll-gradient-bottom.visible,
.scramble-scroll-gradient-top.visible {
  opacity: 1;
}

/* Puzzle-specific font sizes */
.scramble.event-222 {
  font-size: calc(2.1rem * var(--font-scale)); /* 2x2 has short scrambles */
}

.scramble.event-333,
.scramble.event-333oh,
.scramble.event-333fm,
.scramble.event-333bf {
  font-size: calc(1.9rem * var(--font-scale)); /* 3x3 and variants */
}

.scramble.event-444,
.scramble.event-444bf {
  font-size: calc(1.8rem * var(--font-scale)); /* 4x4 */
}

.scramble.event-555,
.scramble.event-555bf {
  font-size: calc(1.7rem * var(--font-scale)); /* 5x5 */
}

.scramble.event-666,
.scramble.event-777 {
  font-size: calc(
    1.4rem * var(--font-scale)
  ); /* 6x6 and 7x7 have long scrambles */
  letter-spacing: 0.08em; /* Slightly reduced letter spacing for long scrambles */
}

.scramble.event-skewb,
.scramble.event-pyram {
  font-size: calc(
    2rem * var(--font-scale)
  ); /* Skewb and Pyraminx have short scrambles */
}

.scramble.event-sq1 {
  font-size: calc(1.8rem * var(--font-scale)); /* Square-1 */
}

.scramble.event-clock {
  font-size: calc(1.9rem * var(--font-scale)); /* Clock */
}

.scramble.event-minx {
  font-size: calc(
    1.5rem * var(--font-scale)
  ); /* Megaminx has very long scrambles */
}

/* Timer */
.timer-container {
  grid-area: timer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px; /* Add more space below timer */
  position: relative;
}

/* Hide UI elements during timing and inspection */
body.timing-active header,
body.timing-active .scramble-section,
body.timing-active .stats-container,
body.timing-active .numeric-keyboard-container,
body.timing-active .visualization,
body.timing-active .times-panel,
body.timing-active .times-toggle,
body.timing-active .stackmat-status,
body.timing-active .smartphone-link-status,
body.inspection-active header,
body.inspection-active .scramble-section,
body.inspection-active .stats-container,
body.inspection-active .numeric-keyboard-container,
body.inspection-active .visualization,
body.inspection-active .times-panel,
body.inspection-active .stackmat-status,
body.inspection-active .smartphone-link-status {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

/* Keep times toggle visible during inspection but hide during timing */
body.inspection-active .times-toggle {
  opacity: 1;
  visibility: visible;
}

/* Keep numeric keyboard container visible during inspection in typing mode */
body.inspection-active .numeric-keyboard-container {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Center timer during timing and inspection */
body.timing-active .timer-container,
body.inspection-active .timer-container {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 100;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  grid-column: unset !important;
  grid-row: unset !important;
}

/* Stackmat status styles */
.stackmat-status {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 5;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.stackmat-status.show {
  display: block;
}

.stackmat-connection {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.stackmat-connection i {
  font-size: 1.1rem;
}

.stackmat-connection.connected {
  color: #28a745;
}

.stackmat-connection.disconnected {
  color: #dc3545;
}

.stackmat-timer-state {
  font-weight: 500;
  text-align: center;
  color: var(--text-color);
}

.stackmat-timer-state.ready {
  color: #ffc107;
}

.stackmat-timer-state.running {
  color: #28a745;
}

.stackmat-timer-state.stopped {
  color: #17a2b8;
}

/* Mobile responsive Stackmat status */
@media (max-width: 768px) {
  .stackmat-status {
    top: 5px;
    right: 5px;
    padding: 8px;
    font-size: 0.8rem;
  }

  .stackmat-connection {
    gap: 6px;
    margin-bottom: 6px;
  }

  .stackmat-connection i {
    font-size: 1rem;
  }
}

/* Manual Input Timer */
.manual-input-container {
  display: none; /* Hidden by default */
  width: 100%;
  max-width: 400px;
  margin-top: 20px;
}

.manual-input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  /* Ensure the wrapper doesn't interfere with absolute positioning */
  isolation: isolate;
}

.manual-time-input {
  width: 100%;
  max-width: 300px; /* Limit width for better centering */
  padding: 20px 60px 20px 20px; /* Add extra padding on the right for the inspection timer */
  font-size: 2rem;
  font-family: var(--font-timer);
  text-align: center;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--container-bg);
  color: var(--text-color);
  transition:
    border-color 0.3s ease,
    background-color 0.3s ease,
    color 0.3s ease;
  box-sizing: border-box; /* Include padding in width calculation */
  position: relative; /* Ensure proper stacking context */
  direction: ltr; /* Always use LTR direction for time input */
}

.manual-time-input:focus {
  outline: none;
  border-color: #a57865;
}

.input-container {
  position: relative;
  width: 100%;
  max-width: 300px;
  display: inline-block;
}

.backspace-button {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%) translateX(100%);
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 3; /* Higher than inspection timer */
}

.backspace-button.visible {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.backspace-button:hover {
  background-color: var(--hover-bg);
  color: var(--accent-color);
}

/* Ensure icon inside backspace button doesn't interfere with click events */
.backspace-button i,
.backspace-button .fa-backspace {
  pointer-events: none;
}

/* Ensure icons inside numeric keyboard buttons don't interfere with click events */
.numeric-key i,
.numeric-key .fa-check {
  pointer-events: none;
}

/* Hide inspection timer when backspace is visible */
.input-container:has(.backspace-button.visible) .manual-inspection {
  opacity: 0;
  visibility: hidden;
}

.manual-inspection {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  font-size: 1.5rem;
  font-family: var(--font-timer);
  color: var(--text-color);
  opacity: 0.4;
  transition:
    color 0.3s ease,
    opacity 0.3s ease;
  pointer-events: none; /* Allow clicks to pass through to the input */
  z-index: 2; /* Higher z-index to ensure it appears above the input */
  margin: 0; /* Ensure no margin affects positioning */
  padding: 0; /* Ensure no padding affects positioning */
  width: auto; /* Don't take up extra width */
}

/* Red color for inspection time when it's running out */
.manual-inspection.warning {
  color: #ff5252;
  opacity: 0.6;
}

/* Touch indicator removed */

.timer {
  font-size: 6rem;
  font-family: monospace;
  -webkit-user-select: none;
  user-select: none;
  font-weight: bold;
  color: var(--timer-color);
  transition: color 0.2s;
  text-align: center;
  cursor: pointer; /* Show pointer cursor */
  touch-action: manipulation; /* Optimize for touch */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* Visualization */
.visualization {
  grid-area: visualization;
  display: flex !important;
  justify-content: center;
  align-items: center;
  height: auto;
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 2px 5px var(--shadow-color);
  overflow: hidden; /* Keep content inside the box */
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Make sure twisty player stays within bounds */
.visualization > * {
  max-width: 100%;
  max-height: 100%;
}

.visualization > svg {
  height: 200px !important;
}

/* MBLD Visualization */
.visualization.clickable {
  cursor: pointer;
}

.mbld-visualization-container {
  width: 100%;
  height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: var(--bg-color-secondary);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: pointer;
  border: 2px dashed var(--accent-color);
  position: relative;
  z-index: 100; /* Ensure it's above other elements */
  -webkit-tap-highlight-color: rgba(
    0,
    0,
    0,
    0
  ); /* Remove tap highlight on mobile */
  touch-action: manipulation; /* Improve touch handling */
}

.mbld-visualization-container:hover {
  background-color: var(--accent-color);
  transform: scale(1.02);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.mbld-visualization-container:active {
  transform: scale(0.98);
  background-color: var(--accent-color);
}

/* No tap icon needed */

.mbld-visualization-text {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text-color);
  text-align: center;
  padding: 10px;
}

/* Set minimum heights for containers */
.stats-container,
.numeric-keyboard-container {
  min-height: 180px;
}

.visualization {
  min-height: 180px;
}

.instructions {
  margin: 10px 0;
  color: #7f8c8d;
  font-size: 0.85rem;
  text-align: center;
}

/* Buttons */
button {
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--btn-bg), var(--btn-hover));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-lift);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-press);
}

button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--focus-ring),
    var(--shadow-lift);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
textarea,
select {
  border-radius: var(--radius-sm);
  background-color: var(--surface-1);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Header action buttons (like next scramble button) */
header .action-button {
  background: transparent;
  color: var(--header-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

header .action-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Light mode support for header action buttons */
body:not(.dark-mode) header .action-button {
  color: var(--text-color);
}

body:not(.dark-mode) header .action-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Share button - minimal, integrated style */
#stat-detail-share {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

#stat-detail-share:hover {
  background-color: var(--card-bg);
  color: var(--text-color);
  border-color: var(--accent-color);
  transform: none;
  box-shadow: none;
}

#stat-detail-share i {
  font-size: 0.9rem;
}

/* Settings button */
.settings-button {
  background: transparent;
  color: white;
  padding: 8px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.settings-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Light mode support for header buttons */
body:not(.dark-mode) .settings-button,
body:not(.dark-mode) .learning-button,
body:not(.dark-mode) .apps-menu-button {
  color: var(--text-color);
}

body:not(.dark-mode) .settings-button:hover,
body:not(.dark-mode) .learning-button:hover,
body:not(.dark-mode) .apps-menu-button:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Dark mode support for both buttons */
.dark-mode .settings-button,
.dark-mode .learning-button,
.dark-mode .apps-menu-button {
  color: var(--text-color);
}

.dark-mode .settings-button:hover,
.dark-mode .learning-button:hover,
.dark-mode .apps-menu-button:hover {
  background-color: var(--hover-bg);
}

#solve-details-save {
  margin: 0 auto;
}

/* Timer states */
.ready {
  color: var(--ready-color) !important;
}

.running {
  color: var(--running-color) !important;
}

.inspection {
  color: var(--inspection-color) !important;
  font-size: 6rem; /* Match timer font size */
}

/* When both inspection and ready classes are applied, ready takes precedence for color */
.inspection.ready {
  color: var(--ready-color) !important;
  font-size: 6rem; /* Match timer font size */
}

/* Stackmat timer running animation */
.timer.running {
  animation: stackmat-pulse 1.5s ease-in-out infinite;
}

@keyframes stackmat-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

/* Stats section */
.stats-container {
  grid-area: stats;
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 5px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Allow scrolling if needed */
  height: auto;
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
  cursor: pointer;
}

.stats-container:hover {
  box-shadow: 0 4px 8px var(--shadow-color);
}

/* Numeric Keyboard Container */
.numeric-keyboard-container {
  grid-area: stats;
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 5px var(--shadow-color);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: auto;
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
  min-height: 180px;
}

.numeric-keyboard-container:hover {
  box-shadow: 0 4px 8px var(--shadow-color);
}

/* Stats title removed */

.stats {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 8px;
}

/* Numeric Keyboard for Typing Mode */
.numeric-keyboard {
  width: 100%;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
  pointer-events: auto; /* Ensure keyboard is always clickable */
}

.numeric-keyboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
}

/* Keep numeric keyboard LTR in RTL languages for consistent number order */
[dir="rtl"] .numeric-keyboard,
[dir="rtl"] .numeric-keyboard-grid,
[dir="rtl"] .numeric-keyboard-grid button {
  direction: ltr;
  unicode-bidi: plaintext;
}

.numeric-keyboard-grid button {
  border-radius: 0;
}

.numeric-key {
  padding: 15px;
  font-size: 1.2rem;
  font-weight: bold;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: auto; /* Ensure buttons are always clickable */
}

.numeric-key:hover {
  background-color: var(--header-bg);
  border-color: var(--header-bg);
  color: white;
}

.numeric-key:active {
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.numeric-key.enter-key {
  color: #4caf50;
}

.numeric-key.enter-key:hover {
  background-color: #45a049;
  border-color: #45a049;
  color: white;
}

/* MBLD and FMC Stats specific styling */
.mbld-stats-content,
.fmc-stats-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mbld-stats-content .stats-row,
.fmc-stats-content .stats-row {
  padding: 6px 0;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(165, 120, 101, 0.2);
}

.mbld-stats-content .stats-label,
.fmc-stats-content .stats-label {
  font-size: 0.9rem;
}

.mbld-stats-content .stats-value,
.fmc-stats-content .stats-value {
  font-size: 0.95rem;
  font-weight: bold;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.stat-item:last-child {
  border-bottom: none;
}

/* ao1000 hidden by default, shown only in mobile landscape */
.stat-item-ao1000 {
  display: none;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.7;
  transition: color 0.3s ease;
}

.stat-value {
  font-weight: bold;
  font-family: monospace;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

/* Statistics Details Panel */
.stats-details-panel {
  position: fixed;
  top: 100%;
  left: 0;
  width: 100%;
  height: 100vh; /* Full screen height */
  background-color: var(--container-bg);
  transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1600; /* Higher than times panel (z-index: 1500) */
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 20px var(--shadow-color);
}

.stats-details-panel.show {
  top: 0; /* Full screen, hide header */
}

/* Stats Row Layout for bigger screens */
.stats-row {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stats-row .stats-section {
  flex: 1;
  min-width: 0; /* Allow sections to shrink */
}

.stats-row .stats-import-export-section {
  flex: 1;
  min-width: 0;
}

.stats-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 2px solid var(--border-color);
  background-color: var(--card-bg);
  min-height: 60px;
  gap: 15px;
}

.stats-details-close {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.stats-details-close:hover {
  background-color: var(--hover-bg);
  color: var(--accent-color);
}

.stats-details-title-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.stats-details-title-text {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--text-color);
  transition: color 0.3s ease;
  white-space: nowrap;
}

.stats-event-selector {
  position: relative;
  display: inline-block;
}

.stats-event-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 150px;
  max-width: 220px;
}

.stats-event-selector-btn:hover {
  border-color: var(--accent-color);
  background-color: var(--hover-bg);
}

.stats-event-selector-btn:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(165, 120, 101, 0.2);
}

.stats-event-text {
  flex: 1;
  text-align: left;
}

.stats-event-icon {
  margin-right: 10px;
  vertical-align: middle;
}

.stats-event-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background-color: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  margin-top: 5px;
}

.stats-event-dropdown.show {
  display: block;
}

.stats-event-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.3s ease;
}

.stats-event-option:hover {
  background-color: var(--hover-bg);
}

.stats-event-option .cubing-icon,
.stats-event-option .puzzle-icon {
  margin-right: 10px;
  vertical-align: middle;
}

.stats-event-option span:not(.cubing-icon):not(.puzzle-icon) {
  flex: 1;
}

.stats-event-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 8px 0;
}

.stats-sessions-divider {
  margin-top: 12px;
  margin-bottom: 12px;
  background-color: var(--accent-color);
  opacity: 0.5;
}

.stats-details-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 25px;
  background-color: var(--bg-color);
}

/* Stats Sections */
.stats-section {
  margin-bottom: 30px;
  background-color: var(--container-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow-color);
  transition: all 0.3s ease;
}

.stats-section:hover {
  box-shadow: 0 4px 12px var(--shadow-color);
}

.stats-section-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent-color);
  margin: 0 0 15px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-color);
  transition: color 0.3s ease;
}

/* Stats Subsection Title (e.g., "Average", "Best") */
.stats-subsection-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 12px 0 10px 0;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}

.stat-card {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.stat-card-label {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.8;
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-card-value {
  font-size: 1.3rem;
  font-weight: bold;
  font-family: monospace;
  color: var(--accent-color);
  transition: color 0.3s ease;
}

/* Records List */
.records-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  border-left: 4px solid var(--accent-color);
  transition: all 0.3s ease;
}

.record-item:hover {
  background-color: var(--hover-bg);
  transform: translateX(5px);
}

.record-label {
  font-size: 1rem;
  color: var(--text-color);
  font-weight: 500;
}

.record-value {
  font-size: 1.1rem;
  font-weight: bold;
  font-family: monospace;
  color: var(--accent-color);
}

/* Chart Container */
.chart-container {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 250px;
}

.chart-container canvas {
  max-width: 100%;
  height: auto;
}

/* Analysis Grid */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.analysis-item {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.analysis-item:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.analysis-label {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.8;
  margin-bottom: 8px;
  font-weight: 500;
}

.analysis-value {
  font-size: 1.2rem;
  font-weight: bold;
  font-family: monospace;
  color: var(--accent-color);
}

/* Predictions Grid */
.predictions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.prediction-item {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background: linear-gradient(135deg, var(--card-bg) 0%, var(--hover-bg) 100%);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.prediction-item:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.prediction-label {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.8;
  margin-bottom: 8px;
  font-weight: 500;
}

.prediction-value {
  font-size: 1.2rem;
  font-weight: bold;
  font-family: monospace;
  color: var(--accent-color);
}

/* Learning Button - Match settings button exactly */
.learning-button,
.apps-menu-button {
  background: transparent;
  color: white;
  padding: 8px;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.learning-button:hover,
.apps-menu-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Apps Menu Modal */
.apps-menu-modal {
  position: fixed;
  top: -125%;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: var(--container-bg);
  transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 2005;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px var(--shadow-color);
}

.apps-menu-modal.show {
  top: 0;
}

.apps-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 2px solid var(--border-color);
  background-color: var(--card-bg);
  min-height: 60px;
  gap: 15px;
}

.apps-menu-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-color);
}

.apps-menu-close {
  background: var(--hover-bg);
  color: var(--text-color);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 1.1rem;
}

.apps-menu-close:hover {
  background: var(--accent-color);
  color: white;
  transform: scale(1.05);
}

.apps-menu-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 25px 10px;
}

.apps-menu-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.apps-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 14px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 0.95rem;
  min-height: 130px;
  text-align: center;
}

.apps-menu-item:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

.apps-menu-item-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  color: var(--accent-color);
  flex-shrink: 0;
}

.dark-mode .apps-menu-item-icon {
  background: rgba(255, 255, 255, 0.08);
}

.apps-menu-item-label {
  font-weight: 600;
  line-height: 1.2;
}

.apps-menu-item-status {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--hover-bg);
  padding: 4px 8px;
  border-radius: 12px;
}

@media (max-width: 980px) {
  .apps-menu-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .apps-menu-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .apps-menu-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .apps-menu-item {
    min-height: 120px;
    padding: 16px 10px;
  }

  .apps-menu-item-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
}

.apps-menu-item.is-coming-soon {
  opacity: 0.6;
  cursor: default;
}

.apps-menu-item.is-coming-soon:hover {
  background-color: var(--card-bg);
  border-color: var(--border-color);
  transform: none;
}

.apps-menu-item.is-coming-soon .apps-menu-item-icon {
  color: var(--text-secondary);
}

.apps-menu-footer {
  padding: 12px 25px 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--card-bg);
}

.apps-menu-version {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Learning Modal */
.learning-modal {
  position: fixed;
  top: -125%;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: var(--container-bg);
  transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px var(--shadow-color);
}

.learning-modal.show {
  top: 0;
}

.learning-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 2px solid var(--border-color);
  background-color: var(--card-bg);
  min-height: 60px;
  gap: 15px;
}

.learning-modal-title-container {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
}

.learning-modal-title-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-color);
}

.learning-selectors {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
}

.learning-puzzle-selector,
.learning-method-selector {
  position: relative;
}

.learning-puzzle-selector-btn,
.learning-method-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  min-width: 120px;
  justify-content: space-between;
}

.learning-puzzle-selector-btn:hover,
.learning-method-selector-btn:hover {
  background-color: var(--accent-color);
  color: white;
}

.learning-puzzle-dropdown,
.learning-method-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 120px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 1000;
  display: none;
  margin-top: 4px;
}

.learning-puzzle-dropdown.show,
.learning-method-dropdown.show {
  display: block;
}

.learning-puzzle-option,
.learning-method-option,
.learning-visualization-option {
  padding: 10px 15px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.learning-puzzle-option:hover,
.learning-method-option:hover,
.learning-visualization-option:hover {
  background-color: var(--hover-bg);
}

.learning-puzzle-option:first-child,
.learning-method-option:first-child,
.learning-visualization-option:first-child {
  border-radius: 6px 6px 0 0;
}

.learning-puzzle-option:last-child,
.learning-method-option:last-child,
.learning-visualization-option:last-child {
  border-radius: 0 0 6px 6px;
}

/* Hierarchical Algorithm Selector */
.learning-algorithm-selector {
  position: relative;
}

.learning-algorithm-selector-btn {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-color);
  transition: all 0.3s ease;
  min-width: 200px;
  justify-content: space-between;
}

.learning-algorithm-selector-btn:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
}

.learning-algorithm-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 1000;
  min-width: 250px;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.learning-algorithm-dropdown.show {
  display: block;
}

.learning-algorithm-group {
  padding: 8px 0;
}

.learning-algorithm-group:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.learning-algorithm-parent {
  padding: 10px 16px;
  font-weight: 600;
  color: var(--text-color);
  font-size: 0.95rem;
  background-color: var(--bg-color-secondary);
}

.learning-algorithm-child {
  padding: 10px 16px 10px 32px;
  cursor: pointer;
  color: var(--text-color);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.learning-algorithm-child:hover {
  background-color: var(--hover-bg);
  color: var(--accent-color);
}

.learning-algorithm-child.active {
  background-color: var(--accent-color);
  color: white;
}

/* Visualization selector specific styles */
.learning-visualization-selector {
  position: relative;
}

.learning-visualization-selector-btn {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-color);
  transition: all 0.3s ease;
  min-width: 140px;
  justify-content: space-between;
}

.learning-visualization-selector-btn:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
}

/* Old visualization dropdown styles removed */

.learning-visualization-option i {
  color: var(--accent-color);
  width: 16px;
  text-align: center;
}

.learning-modal-close {
  background: none;
  border: none;
  color: var(--text-color);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.learning-modal-close:hover {
  background-color: var(--hover-bg);
  color: var(--accent-color);
}

.learning-modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 25px;
}

/* Visualization control box */
.learning-visualization-controls {
  margin-bottom: 20px;
  padding: 15px 20px;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.learning-viz-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.learning-visualization-controls label {
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.95rem;
}

.learning-visualization-dropdown {
  position: relative;
}

.learning-visualization-dropdown select,
.learning-filter-dropdown select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--container-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 150px;
}

.learning-visualization-dropdown select:focus,
.learning-filter-dropdown select:focus {
  outline: none;
  border-color: var(--accent-color);
}

.learning-arrows-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.learning-arrows-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.learning-arrows-checkbox label {
  cursor: pointer;
  font-size: 0.9rem;
}

.learning-filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.learning-filter-dropdown {
  position: relative;
}

.learn-button-inline {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.learn-button-inline:hover {
  background-color: var(--btn-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow-color);
}

.learn-button-inline i {
  font-size: 1rem;
}

.learning-tabs-container {
  margin-bottom: 20px;
}

.learning-tabs {
  display: flex;
  gap: 2px;
  background-color: var(--hover-bg);
  border-radius: 8px;
  padding: 4px;
}

.learning-tab {
  flex: 1;
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-weight: 500;
  font-size: 0.95rem;
}

.learning-tab:hover {
  background-color: var(--card-bg);
}

.learning-tab.active {
  background-color: var(--accent-color);
  color: white;
}

.learning-content-area {
  margin-top: 10px;
}

/* Removed learning-algset-info styles */

.learning-algorithms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.algorithm-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  transition: all 0.3s ease;
}

.algorithm-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.algorithm-card-header {
  margin-bottom: 15px;
  position: relative;
}

.algorithm-header-content {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.algorithm-header-text {
  flex: 1;
}

.algorithm-toggle-icons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.algorithm-toggle-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.3s ease;
  color: var(--text-color);
  opacity: 0.6;
}

.algorithm-toggle-icon:hover {
  opacity: 1;
  background-color: var(--hover-bg);
}

.algorithm-toggle-icon.active {
  opacity: 1;
  color: var(--accent-color);
}

.algorithm-toggle-icon.favorite.active {
  color: #f39c12;
}

.algorithm-toggle-icon.learnt.active {
  color: #27ae60;
}

.algorithm-toggle-icon.add-custom {
  color: var(--accent-color);
  opacity: 0.8;
}

.algorithm-toggle-icon.add-custom:hover {
  opacity: 1;
  background-color: var(--hover-bg);
  transform: scale(1.1);
}

/* Custom Algorithm Modal Styles */
#add-custom-algorithm-modal .modal-content {
  max-width: 500px;
  width: 90%;
}

#add-custom-algorithm-modal .form-group {
  margin-bottom: 20px;
}

#add-custom-algorithm-modal .form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-color);
}

#add-custom-algorithm-modal .form-group input,
#add-custom-algorithm-modal .form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--card-bg);
  color: var(--text-color);
  font-size: 1rem;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

#add-custom-algorithm-modal .form-group input:focus,
#add-custom-algorithm-modal .form-group select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(165, 120, 101, 0.1);
}

#add-custom-algorithm-modal .modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

#add-custom-algorithm-modal .btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

#add-custom-algorithm-modal .btn-primary {
  background-color: var(--accent-color);
  color: white;
}

#add-custom-algorithm-modal .btn-primary:hover {
  background-color: var(--accent-color-hover);
}

#add-custom-algorithm-modal .btn-secondary {
  background-color: var(--bg-color-secondary);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

#add-custom-algorithm-modal .btn-secondary:hover {
  background-color: var(--hover-bg);
}

.algorithm-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0 0 5px 0;
  text-align: left;
}

/* Algorithm name in cards - larger and left-aligned */
.algorithm-card .algorithm-name {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: left;
}

/* Algorithm name in learning mode algorithm box */
.algorithm-box .algorithm-name {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

/* Hide algorithm name in advanced practice mode */
.learning-mode[data-practice-mode="advanced"] .algorithm-box .algorithm-name {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.algorithm-description {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.7;
  margin: 0;
  line-height: 1.3;
}

.algorithm-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Slot tabs for F2L algorithms */
.algorithm-slot-tabs {
  display: flex;
  gap: 2px;
  background-color: var(--hover-bg);
  border-radius: 6px;
  padding: 2px;
  margin-bottom: 12px;
}

.algorithm-slot-tab {
  flex: 1;
  padding: 6px 8px;
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
}

.algorithm-slot-tab:hover {
  background-color: var(--card-bg);
}

.algorithm-slot-tab.active {
  background-color: var(--accent-color);
  color: white;
}

.algorithm-slot-content {
  display: none;
}

.algorithm-slot-content.active {
  display: block;
}

.algorithm-sequence {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-color);
  background-color: var(--hover-bg);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  text-align: center;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.algorithm-sequence:hover {
  border-color: var(--accent-color);
  background-color: var(--container-bg);
}

.algorithm-sequence.active-algorithm {
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 0 1px var(--accent-color);
}

.algorithm-setup {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.8;
  background-color: var(--container-bg);
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.algorithm-setup::before {
  content: "Setup: ";
  font-weight: 600;
  color: var(--accent-color);
}

/* Custom Algorithm Modal Styles */
.custom-algorithms-list {
  margin: 15px 0;
}

.custom-algorithm-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin: 8px 0;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.custom-algorithm-item .algorithm-text {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--accent-color);
  flex: 1;
}

.custom-algorithm-item .remove-algorithm-btn {
  margin-left: 12px;
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Algorithm Action Icons */
.algorithm-action-icons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.algorithm-action-icons .algorithm-toggle-icon {
  background: none;
  border: none;
  padding: 6px;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.algorithm-action-icons .algorithm-toggle-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

.algorithm-action-icons .algorithm-toggle-icon.add-custom {
  color: var(--text-color);
}

.algorithm-action-icons .algorithm-toggle-icon.add-custom:hover {
  color: var(--accent-color);
}

.algorithm-action-icons .algorithm-toggle-icon.remove-custom {
  color: var(--text-color);
}

.algorithm-action-icons .algorithm-toggle-icon.remove-custom:hover {
  color: var(--accent-color);
}

/* Algorithm Navigation */
.algorithm-sequence.hidden {
  display: none;
}

.algorithm-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
}

.algorithm-nav-arrow {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  opacity: 0.7;
  font-size: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.algorithm-nav-arrow:hover {
  opacity: 1;
  background-color: var(--hover-bg);
  transform: scale(1.1);
}

.algorithm-nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.algorithm-nav-arrow:disabled:hover {
  transform: none;
  background: none;
}

.algorithm-nav-indicator {
  color: var(--text-color);
  font-size: 12px;
  opacity: 0.7;
  min-width: 40px;
  text-align: center;
}

/* Algorithm Interaction Styles */
.main-algorithm,
.alternative-algorithm {
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
  padding: 8px 12px;
  margin: 4px 0;
  border: 1px solid transparent;
}

.main-algorithm:hover,
.alternative-algorithm:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
  transform: translateX(2px);
}

.main-algorithm.active-algorithm,
.alternative-algorithm.active-algorithm {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.main-algorithm {
  font-weight: 600;
  border-color: var(--border-color);
}

/* Algorithm Header Layout */
.algorithm-header-content {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.algorithm-header-text {
  flex: 1;
  min-width: 0; /* Prevent overflow */
}

.algorithm-3d-container.header-visualization {
  flex: 0 0 180px; /* Smaller fixed width for header visualization */
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.algorithm-3d-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.algorithm-3d-container canvas {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Loading state for 3D visualizations */
.algorithm-3d-container:empty::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.algorithm-3d-container:empty::after {
  content: "Loading 3D Visualization...";
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.7;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Mobile responsive for learning modal */
@media (max-width: 768px) {
  .learning-modal-header {
    padding: 15px 20px;
    min-height: 50px;
  }

  .learning-modal-title-container {
    flex-direction: row;
    gap: 10px;
    align-items: flex-start;
  }

  .learning-selectors {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .learning-puzzle-selector-btn,
  .learning-method-selector-btn,
  .learning-visualization-selector-btn {
    width: 100%;
  }

  .learning-modal-content {
    padding: 15px 20px;
  }

  .learning-visualization-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .learning-viz-left {
    /* Keep visualization label and dropdown on same line */
    flex-direction: row;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 10px;
  }

  .learning-viz-left > label {
    /* Label stays inline with dropdown */
    flex-shrink: 0;
  }

  .learning-visualization-dropdown {
    /* Dropdown takes remaining space */
    flex: 1;
    min-width: 150px;
  }

  .learning-arrows-checkbox {
    /* Checkbox goes to new line below */
    width: 100%;
    margin-left: 0;
  }

  .learning-filter-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .learning-visualization-dropdown select,
  .learning-filter-dropdown select {
    width: 100%;
  }

  .learn-button-inline {
    width: 100%;
    justify-content: center;
  }

  .learning-algorithms-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .algorithm-card {
    padding: 15px;
  }

  .learning-tabs {
    flex-direction: row;
    gap: 2px;
  }

  .learning-tab {
    padding: 10px 15px;
  }

  /* Mobile responsive for algorithm header */
  .algorithm-header-content {
    gap: 10px;
  }

  .algorithm-3d-container.header-visualization {
    flex: none;
    width: 50%;
    height: 120px; /* Smaller height on mobile */
  }
}

/* Times panel (slide-in from left) */
.times-panel {
  position: fixed;
  top: 0;
  left: -350px; /* Start off-screen on the left */
  width: 350px;
  height: 100vh;
  background-color: var(--card-bg);
  transition:
    left 0.3s ease,
    background-color 0.3s ease,
    box-shadow 0.3s ease;
  z-index: 1500;
  display: flex;
  flex-direction: column;
}

.times-panel.show {
  left: 0;
}

/* Prevent horizontal scrollbar */
body {
  overflow-x: hidden;
}

/* Smooth transition for container */
.container {
  transition:
    margin-left 0.3s ease,
    width 0.3s ease,
    transform 0.3s ease;
  width: 100%;
}

.times-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 25px;
  background-color: transparent;
  color: var(--text-color);
  height: 52.8px;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.times-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 16px;
}

.times-panel-title {
  font-size: 1.1rem;
  font-weight: bold;
}

.times-panel-action {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-color);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.times-panel-action:hover {
  background: rgba(0, 0, 0, 0.16);
  transform: translateY(-1px);
}

.times-panel.selection-mode #times-select-toggle {
  background: var(--accent-color);
  color: white;
}

.times-panel.filters-collapsed .times-panel-controls,
.times-panel.filters-collapsed .times-list-meta {
  display: none;
}

.times-panel.filters-collapsed.selection-mode .times-panel-controls {
  display: flex;
}

.times-panel.filters-collapsed.selection-mode
  .times-panel-controls
  > :not(.times-selection-bar) {
  display: none;
}

.times-panel-close {
  background: transparent;
  color: white;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  margin-right: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.times-panel-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.times-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.times-panel-controls {
  padding: 12px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
}

.times-search-row {
  display: flex;
  align-items: center;
}

.times-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 10px;
  width: 100%;
  box-shadow: 0 6px 16px var(--shadow-color);
}

.times-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-color);
  font-size: 0.9rem;
}

.times-search-clear {
  background: transparent;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  opacity: 0.6;
}

.times-search-clear:hover {
  opacity: 1;
}

.times-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.times-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.times-chip {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.times-chip.active {
  background: var(--accent-color);
  color: white;
  border-color: transparent;
}

.times-view-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  min-width: 40px;
}

.times-view-square {
  width: 5px;
  border-radius: 2px;
  border: 4px solid currentColor;
  opacity: 0.8;
}

.times-chip.active .times-view-square {
  border-color: white;
  opacity: 1;
}

.times-date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-color);
}

.times-date-range input {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.times-reset {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.times-selection-bar {
  display: none;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-color);
}

.times-panel.selection-mode .times-selection-bar {
  display: flex;
}

.times-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.times-selection-actions button {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.times-selection-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.times-selection-actions .danger {
  background: #e74c3c;
  border-color: #e74c3c;
  color: white;
}

.times-list-meta {
  padding: 6px 16px 0;
  font-size: 0.78rem;
  color: var(--text-color);
  opacity: 0.7;
}

.times-list ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.times-list-view-2 ul,
.times-list-view-3 ul {
  display: grid;
  gap: 8px;
}

.times-list-view-2 ul {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.times-list-view-3 ul {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.times-list-view-2 li,
.times-list-view-3 li {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
}

.times-list-view-2 .time-entry .time-info,
.times-list-view-3 .time-entry .time-info {
  align-items: center;
}

.times-list-view-2 .time-entry .time-value,
.times-list-view-3 .time-entry .time-value {
  justify-content: center;
  text-align: center;
}

.times-list-view-2 .time-group-divider,
.times-list-view-3 .time-group-divider {
  grid-column: 1 / -1;
}

.times-list-view-2 .time-entry.time-over-minute .time-value {
  font-size: 0.95rem;
}

.times-list-view-3 .time-entry.time-over-minute .time-value {
  font-size: 0.85rem;
}

.times-list li {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.3s ease;
  color: var(--text-color);
}

.times-list li:hover {
  background-color: var(--hover-bg);
  box-shadow: 0 1px 3px var(--shadow-color);
}

.times-list li:last-child {
  border-bottom: none;
}

/* Comment indicator styles moved to .time-value section */

.time-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.time-value {
  font-size: 1.1rem;
  font-weight: bold;
  font-family: monospace;
  display: flex;
  align-items: center;
  width: 100%;
}

.times-list-view-2 .time-entry.time-has-meta .time-value,
.times-list-view-3 .time-entry.time-has-meta .time-value {
  font-size: 0.8rem;
}

.times-list-view-2 .time-entry.time-over-minute-plus2 .time-value,
.times-list-view-3 .time-entry.time-over-minute-plus2 .time-value {
  font-size: 0.5rem;
}

.comment-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  color: #3498db;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
}

[dir="rtl"] .comment-badge {
  right: auto;
  left: 10px;
}

.times-list-view-2 .time-entry.time-has-comment .comment-badge,
.times-list-view-3 .time-entry.time-has-comment .comment-badge {
  display: inline-flex;
}

.times-list-view-2 .comment-indicator,
.times-list-view-3 .comment-indicator {
  display: none;
}

.time-entry {
  position: relative;
}

.time-entry.group-min .time-text::before,
.time-entry.group-max .time-text::before,
.time-entry.group-min .time-text::after,
.time-entry.group-max .time-text::after {
  font-weight: 700;
  margin: 0 2px;
}

.time-entry.group-min .time-text::before,
.time-entry.group-min .time-text::after {
  content: "[";
  color: #2ecc71;
}

.time-entry.group-min .time-text::after {
  content: "]";
}

.time-entry.group-max .time-text::before,
.time-entry.group-max .time-text::after {
  content: "[";
  color: #e74c3c;
}

.time-entry.group-max .time-text::after {
  content: "]";
}

.time-entry.group-min.group-max .time-text::before,
.time-entry.group-min.group-max .time-text::after {
  color: #f39c12;
}

.time-entry.selected {
  background: color-mix(in srgb, var(--accent-color) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent-color) 45%, transparent);
}

.time-entry .selection-indicator {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: white;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: scale(0.9);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    background-color 0.2s ease;
}

[dir="rtl"] .time-entry .selection-indicator {
  right: auto;
  left: 12px;
}

.times-panel.selection-mode .time-entry {
  padding-right: 42px;
}

[dir="rtl"] .times-panel.selection-mode .time-entry {
  padding-right: 10px;
  padding-left: 42px;
}

.times-panel.selection-mode .time-entry .selection-indicator {
  opacity: 0.6;
}

.times-panel.selection-mode .time-entry:hover .selection-indicator {
  opacity: 0.9;
}

.time-entry.selected .selection-indicator {
  opacity: 1;
  background: var(--accent-color);
  transform: scale(1);
}

.time-group-divider {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-color);
  opacity: 0.6;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.04);
}

.time-group-divider:hover {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: none;
  cursor: default;
}

.times-empty {
  padding: 16px 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.7;
  cursor: default;
}

.times-empty:hover {
  background: none;
  box-shadow: none;
}

.time-date {
  font-size: 0.8rem;
  color: var(--text-color);
  opacity: 0.7;
  margin-top: 3px;
  transition: color 0.3s ease;
}

.comment-indicator {
  color: #3498db;
  margin-left: auto;
  font-size: 0.8rem;
  transition: color 0.3s ease;
}

/* RTL specific spacing for comment indicator */
[dir="rtl"] .comment-indicator {
  margin-left: 0;
  margin-right: auto;
}

.dark-mode .comment-indicator {
  color: #64b5f6;
}

.delete-time {
  background-color: #e74c3c;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 0.8rem;
  height: 28px;
  width: 28px;
}

.delete-time:hover {
  background-color: #c0392b;
}

.times-panel-footer {
  padding: 15px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.3s ease;
}

.footer-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#clear-times-btn {
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

#clear-times-btn:hover {
  background: #c0392b;
}

#edit-session-btn {
  background: #3498db;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

#edit-session-btn:hover {
  background: #2980b9;
}

#edit-session-btn.hidden {
  display: none;
}

#stats-btn {
  background: #9b59b6;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

#stats-btn:hover {
  background: #8e44ad;
}

#stats-btn i {
  font-size: 1rem;
}

.action-button {
  background-color: var(--accent-color, #a57865);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

.action-button:hover {
  background-color: var(--accent-color-hover, #8a6553);
}

.action-button.danger {
  background-color: #e74c3c;
}

.action-button.danger:hover {
  background-color: #c0392b;
}

/* Reset buttons styling */
.reset-button {
  background: var(--error-color, #e74c3c);
  color: white;
  border: 2px solid var(--error-color, #e74c3c);
  transition: all 0.3s ease;
}

.reset-button:hover {
  background: var(--error-color-hover, #c0392b);
  border-color: var(--error-color-hover, #c0392b);
}

.reset-button:active {
  transform: translateY(0);
}

.reset-option-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 10px 0;
}

.reset-option-info {
  flex: 1;
}

.reset-option-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 4px;
}

.reset-option-title i {
  color: var(--accent-color);
  font-size: 1.1em;
}

.reset-option-description {
  color: var(--text-secondary);
  font-size: 0.9em;
  line-height: 1.4;
}

/* Responsive design for reset options */
@media (max-width: 768px) {
  .reset-option-container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .reset-button {
    width: 100%;
    justify-content: center;
  }
}
#disconnect-cube-btn {
  width: 30px;
}
.delete-button {
  background: var(--error-color, #e74c3c);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

.delete-button:hover {
  background: var(--error-hover-color, #c0392b);
}

.modal-footer-buttons {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  width: 100%;
}

/* Times toggle button */
.times-toggle {
  position: fixed;
  right: 15px;
  bottom: 15px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--header-bg);
  color: var(--header-text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px var(--shadow-color);
  z-index: 2000; /* Higher z-index to ensure it's above the times panel */
  cursor: pointer;
  transition:
    all 0.2s,
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
  border: none;
  font-size: 1.2rem;
}

/* Learn button (positioned opposite to times toggle) */
.learn-button {
  position: fixed;
  left: 15px;
  bottom: 15px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px var(--shadow-color);
  z-index: 2000;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  font-size: 1.2rem;
  transform: translateY(100px);
  opacity: 0;
  visibility: hidden;
}

.learn-button.show {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  display: flex !important;
}

.learn-button:hover {
  transform: scale(1.05) translateY(0);
  background-color: var(--btn-hover);
  box-shadow: 0 4px 15px var(--shadow-color);
}

/* Learning Mode Styles */
.learning-mode .scramble-section {
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 5px var(--shadow-color);
}

.learning-mode .scramble {
  display: none;
}

.algorithm-box {
  display: none;
  font-family: monospace;
  font-size: calc(1.6rem * var(--font-scale));
  padding: 12px;
  background-color: var(--card-bg);
  border-radius: 8px;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  direction: ltr;
  word-wrap: break-word;
  line-height: 1.7;
  letter-spacing: 0.1em;
  box-shadow: 0 2px 5px var(--shadow-color);
  color: var(--text-color);
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}

.algorithm-box-content {
  width: 100%;
}

.learning-mode .algorithm-box {
  display: flex;
}

/* Make algorithm box clickable in normal practice mode */
.learning-mode:not([data-practice-mode="advanced"]) .algorithm-box {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.learning-mode:not([data-practice-mode="advanced"]) .algorithm-box:hover {
  background-color: var(--hover-bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow-color);
}

.algorithm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 5px;
}

.algorithm-nav-buttons {
  display: flex;
  gap: 8px;
}

.algorithm-nav-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.algorithm-nav-btn:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
}

.algorithm-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.algorithm-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.algorithm-control-btn {
  background: none;
  border: none;
  color: var(--text-color);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.algorithm-control-btn:hover {
  background-color: var(--hover-bg);
  color: var(--accent-color);
}

.algorithm-control-btn.active {
  color: var(--accent-color);
  background-color: var(--hover-bg);
}

.algorithm-text {
  text-align: center;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

.algorithm-name {
  font-size: 0.9rem;
  color: var(--text-color);
  margin-bottom: 5px;
  text-align: center;
}

/* Learning mode stats modifications */
.learning-mode .stat-item:first-child .stat-label {
  /* Change "Solves" to "Times" in learning mode */
}

.learning-mode .stat-item:nth-child(n + 5) {
  /* Hide avg12 and beyond in learning mode */
  display: none;
}

/* Hide stats button in learning mode */
.learning-mode #stats-btn {
  display: none;
}

/* Disable stats container pointer events in learning mode */
.learning-mode .stats-container {
  cursor: default;
}

.learning-mode .stats-container:hover {
  background-color: var(--card-bg);
}

/* Learning mode visualization */
.learning-mode .visualization {
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 5px var(--shadow-color);
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
  max-width: 100%;
  max-height: 300px; /* Prevent overflow on desktop */
  overflow: hidden;
}

/* Ensure visualization content stays within bounds in learning mode */
.learning-mode .visualization img,
.learning-mode .visualization > * {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Desktop specific constraints for learning mode visualization */
@media (min-width: 768px) {
  .learning-mode .visualization {
    max-height: 200px; /* Smaller on desktop to prevent overflow */
  }
}

@media (min-width: 1024px) {
  .learning-mode .visualization {
    max-height: 220px; /* Slightly larger on larger screens but still compact */
  }
}

/* Learning mode header controls */
.learning-header-controls {
  display: none;
  gap: 5px;
  align-items: center;
}

.learning-mode .learning-header-controls {
  display: flex;
}

.learning-mode .event-selector {
  display: none;
}

.learning-mode .action-button {
  display: none;
}

.learning-header-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
}

.learning-header-btn:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
}

.learning-header-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.learning-header-btn.active {
  color: var(--accent-color);
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
}

/* F2L Slot Button */
.f2l-slot-btn {
  display: none;
  min-width: 40px;
  font-weight: 600;
}

/* Show F2L slot button only for F2L algorithm sets in learning mode */
.learning-mode[data-algset="F2L"] .f2l-slot-btn {
  display: flex;
}

/* csTimer Scramble Button */
.ll-mode-toggle-btn {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 80px;
}

.ll-mode-toggle-btn.advanced-mode {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.ll-mode-toggle-btn .mode-text {
  font-size: 12px;
  font-weight: 500;
}

/* Mobile: Make toggle button same size as other buttons */
@media (max-width: 768px) {
  .ll-mode-toggle-btn {
    min-width: 36px;
    gap: 0;
  }

  .ll-mode-toggle-btn .mode-text {
    display: none;
  }
}

.ll-scramble-btn {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.cstimer-scramble-btn:hover {
  background-color: var(--btn-hover);
  border-color: var(--btn-hover);
}

.cstimer-scramble-btn i {
  font-size: 1rem;
}

/* Close learning button */
.close-learning-button {
  display: none;
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  align-items: center;
  justify-content: center;
}

/* Advanced Mode Time List Styles */
.advanced-mode-header {
  background: linear-gradient(
    135deg,
    var(--accent-color),
    var(--primary-color)
  );
  color: white;
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 0;
  cursor: default;
}

.advanced-mode-header-content {
  padding: 12px 16px;
}

.advanced-mode-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1.1em;
}

.advanced-mode-subtitle {
  font-size: 0.85em;
  opacity: 0.9;
  margin-top: 4px;
}

.case-entry {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.case-entry:hover {
  border-color: var(--accent-color);
  background-color: var(--hover-bg);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.case-info {
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 12px;
}

.case-visualization {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-secondary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.case-image {
  color: var(--text-secondary);
  font-size: 1.5em;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.case-visualization-img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  border-radius: 4px;
}

.case-image-loading {
  color: var(--text-secondary);
  font-size: 1.2em;
  animation: spin 1s linear infinite;
}

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

.case-details {
  flex: 1;
  min-width: 0;
}

.case-name {
  font-weight: 600;
  font-size: 1.1em;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.case-category {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.case-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}

.times-count {
  font-size: 0.9em;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.mean-time {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--accent-color);
}

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

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

.case-modal-content {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.case-modal-header {
  background: linear-gradient(
    135deg,
    var(--accent-color),
    var(--primary-color)
  );
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.case-modal-title-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.case-modal-title {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.case-modal-case-name {
  font-size: 1.4em;
  font-weight: 600;
  margin: 0;
}

.case-modal-case-info {
  font-size: 0.9em;
  opacity: 0.9;
  font-weight: 400;
}

.case-modal-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.case-modal-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.case-modal-stat .stat-label {
  font-size: 0.8em;
  opacity: 0.8;
  font-weight: 400;
}

.case-modal-stat .stat-value {
  font-size: 1.1em;
  font-weight: 600;
}

.case-modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.2em;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  margin-left: 15px;
}

.case-modal-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.case-modal-body {
  padding: 20px;
  max-height: 50vh;
  overflow-y: auto;
}

.case-modal-times-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.case-modal-times-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.2em;
}

.case-modal-clear-all {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s ease;
}

.case-modal-clear-all:hover {
  background: var(--danger-hover);
}

.case-modal-times-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.case-modal-time-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.case-modal-time-entry:hover {
  border-color: var(--accent-color);
  background: var(--hover-bg);
}

.case-modal-time-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.case-modal-time-value {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--text-primary);
}

.case-modal-time-details {
  font-size: 0.85em;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
}

.case-modal-time-delete {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8em;
  transition: background-color 0.2s ease;
}

.case-modal-time-delete:hover {
  background: var(--danger-hover);
}

.case-modal-empty {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 40px 20px;
}

.learning-mode .close-learning-button {
  display: flex;
}

.learning-mode .learning-button {
  display: none;
}

.close-learning-button:hover {
  background-color: var(--btn-hover);
  transform: scale(1.05);
}

/* Disabled settings in learning mode */
.learning-mode .setting-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.learning-mode .setting-item.disabled label {
  color: var(--text-color);
  opacity: 0.6;
}

.learning-mode .setting-item.disabled input[type="checkbox"] {
  opacity: 0.5;
}

.learning-mode .setting-item.disabled select {
  opacity: 0.5;
}

/* Privacy setting in practice mode - disabled and visually indicated */
.learning-mode #show-privacy-header-checkbox {
  /* Disable checkbox during practice mode */
  opacity: 0.5;
  pointer-events: none;
}

.learning-mode .settings-option:has(#show-privacy-header-checkbox) {
  /* Add visual indication that this setting is disabled in practice mode */
  position: relative;
  opacity: 0.7;
}

.learning-mode .settings-option:has(#show-privacy-header-checkbox) label {
  color: var(--text-color);
  opacity: 0.6;
}

.learning-mode .settings-option:has(#show-privacy-header-checkbox)::after {
  content: " (disabled in practice mode)";
  font-size: 0.8em;
  color: var(--text-color);
  opacity: 0.6;
  font-style: italic;
}

/* RTL times toggle button */
[dir="rtl"] .times-toggle {
  right: auto;
  left: 15px;
}

/* RTL learn button */
[dir="rtl"] .learn-button {
  left: auto;
  right: 15px;
}

.times-toggle:hover {
  transform: scale(1.05);
  background-color: var(--btn-hover);
}

/* Active state for times toggle */
.times-toggle.active {
  background-color: var(--btn-hover);
}

/* Modal styles (common for settings and solve details) */
.settings-modal,
.solve-details-modal,
.info-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.settings-modal.show,
.solve-details-modal.show,
.info-modal.show {
  opacity: 1;
  visibility: visible;
}

.settings-content,
.solve-details-content {
  background-color: var(--container-bg);
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 15px var(--shadow-color);
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Info Modal Styles */
.info-modal-content {
  background-color: var(--container-bg);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow-color);
  width: 95%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

.info-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--header-bg);
  border-radius: 8px 8px 0 0;
}

.info-modal-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--header-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.info-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--header-text);
  opacity: 0.8;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  padding: 5px;
  border-radius: 4px;
}

.info-modal-close:hover {
  opacity: 1;
  transform: scale(1.1);
  background-color: rgba(255, 255, 255, 0.1);
}

.info-modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) var(--card-bg);
}

.info-section {
  margin-bottom: 30px;
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow-color);
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

.info-section:last-child {
  margin-bottom: 0;
}

.info-section-title {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--accent-color);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 8px;
}

.info-section-content {
  color: var(--text-color);
  line-height: 1.6;
}

.info-section-content p {
  margin-bottom: 15px;
}

.info-action-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 12px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.3s ease;
  margin: 10px 0;
}

.info-action-btn:hover {
  background-color: var(--btn-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.info-note {
  background-color: var(--bg-color);
  border-left: 4px solid var(--accent-color);
  padding: 12px 15px;
  margin: 15px 0;
  border-radius: 0 4px 4px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Shortcuts Grid */
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.shortcut-category {
  background-color: var(--bg-color);
  border-radius: 6px;
  padding: 15px;
  border: 1px solid var(--border-color);
}

.shortcut-category h4 {
  color: var(--accent-color);
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.shortcut-item:last-child {
  border-bottom: none;
}

.shortcut-item kbd {
  background-color: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--accent-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  min-width: 80px;
  text-align: center;
}

.shortcut-item span {
  flex: 1;
  margin-left: 15px;
  color: var(--text-color);
  font-size: 0.9rem;
}

/* Mobile Gestures */
.gesture-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.gesture-item:last-child {
  border-bottom: none;
}

.gesture-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
  font-size: 1.2rem;
}

.gesture-description {
  flex: 1;
}

.gesture-description strong {
  display: block;
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 4px;
}

.gesture-description span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 15px;
  background-color: var(--bg-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.feature-item:hover {
  box-shadow: 0 4px 12px var(--shadow-color);
}

.feature-item i {
  font-size: 1.5rem;
  color: var(--accent-color);
  margin-top: 2px;
}

.feature-item strong {
  display: block;
  color: var(--text-color);
  font-size: 1rem;
  margin-bottom: 6px;
}

.feature-item p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.4;
}

/* Sync Features */
.sync-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.sync-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--bg-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-color);
}

.sync-feature i {
  color: var(--accent-color);
  font-size: 1.1rem;
}

/* Font Awesome Icon Fix */
.fas,
.far,
.fab,
.fal,
.fad,
.fa {
  font-family:
    "Font Awesome 6 Free", "Font Awesome 6 Brands", "Font Awesome 6 Pro" !important;
  font-weight: 900;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  line-height: 1;
}

.fab {
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400;
}

/* Settings Section Title Icons */
.settings-section-title i {
  margin-right: 8px;
  color: var(--accent-color);
  font-size: 1.1rem;
  display: inline-block;
  width: auto;
  height: auto;
  opacity: 1;
  visibility: visible;
  font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  text-rendering: auto !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* Brand icons need different font-weight */
.settings-section-title i.fab {
  font-family: "Font Awesome 6 Brands" !important;
  font-weight: 400 !important;
}

/* Force visibility for specific problematic icons */
.settings-section-title .fa-stopwatch,
.settings-section-title .fa-eye,
.settings-section-title .fa-globe {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  font-style: normal !important;
  text-rendering: auto !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
  color: var(--accent-color) !important;
  margin-right: 8px !important;
  font-size: 1.1rem !important;
}

.settings-section-title {
  display: flex;
  align-items: center;
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 15px;
  color: var(--text-color);
}

/* Google Drive Sync Settings Styles */

/* Compact Sync Container */
.sync-compact-container {
  padding: 8px 0;
}

.sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-buttons-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition:
    background-color 0.3s ease,
    transform 0.2s ease;
  min-width: 36px;
  height: 36px;
}

.sync-btn:hover {
  background-color: var(--accent-color-hover);
  transform: scale(1.05);
}

.sync-btn:active {
  transform: scale(0.95);
}

.sync-btn i {
  font-size: 1rem;
}

.sync-disconnect-btn {
  background-color: #e74c3c;
}

.sync-disconnect-btn:hover {
  background-color: #c0392b;
}

.sync-auto-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 36px;
  height: 36px;
}

.sync-auto-toggle input {
  display: none;
}

.sync-auto-toggle i {
  font-size: 1rem;
  color: var(--text-color);
  opacity: 0.5;
  transition: all 0.3s ease;
}

.sync-auto-toggle:hover {
  border-color: var(--accent-color);
}

.sync-auto-toggle:hover i {
  opacity: 0.8;
}

.sync-auto-toggle input:checked + i {
  color: var(--accent-color);
  opacity: 1;
  animation: spin 1s ease-in-out;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Legacy - keep for compatibility */
.sync-status-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.sync-status-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sync-status-label {
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.95rem;
}

.sync-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

.sync-status.connected {
  background-color: #e8f5e8;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.sync-status.error {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

.sync-status.syncing {
  background-color: #e3f2fd;
  color: #1565c0;
  border: 1px solid #bbdefb;
  animation: pulse 2s infinite;
}

.sync-status:not(.connected):not(.error):not(.syncing) {
  background-color: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Dark mode sync status colors */
.dark-mode .sync-status.connected {
  background-color: #1b5e20;
  color: #a5d6a7;
  border-color: #2e7d32;
}

.dark-mode .sync-status.error {
  background-color: #b71c1c;
  color: #ef9a9a;
  border-color: #c62828;
}

.dark-mode .sync-status.syncing {
  background-color: #0d47a1;
  color: #90caf9;
  border-color: #1565c0;
}

.sync-connection-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-connect-btn,
.sync-disconnect-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.3s ease;
}

.sync-connect-btn:hover,
.sync-disconnect-btn:hover {
  background-color: var(--accent-color-hover);
}

.sync-disconnect-btn {
  background-color: #e74c3c;
}

.sync-disconnect-btn:hover {
  background-color: #c0392b;
}

.sync-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 8px;
}

.sync-action-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.3s ease;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

.sync-action-btn:hover {
  background-color: var(--accent-color-hover);
}

.sync-action-btn i {
  font-size: 1.1rem;
}

.sync-auto-option {
  margin: 0 10px !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-auto-option .checkbox-label {
  margin-bottom: 0;
}

.setting-note {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.8;
  line-height: 1.4;
  margin-top: 0;
  margin-left: 20px;
  display: block;
}

/* Responsive design for sync section */
@media (max-width: 768px) {
  .settings-section-title {
    font-size: 0.95rem;
  }

  .settings-section-title i {
    font-size: 1rem;
    margin-right: 6px;
  }

  .sync-status-container {
    padding: 12px;
    gap: 10px;
  }

  .sync-actions {
    flex-direction: row;
    gap: 8px;
  }

  .sync-action-btn {
    flex: 1;
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  /* Compact sync row on mobile */
  .sync-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .sync-buttons-row {
    justify-content: center;
    gap: 8px;
  }

  .sync-btn {
    padding: 8px 10px;
    min-width: 40px;
    height: 40px;
  }

  .sync-status {
    text-align: center;
    font-size: 0.8rem;
  }

  .settings-section-title {
    font-size: 0.9rem;
    margin-bottom: 12px;
  }

  .settings-section-title i {
    font-size: 0.9rem;
    margin-right: 5px;
  }

  .setting-note {
    font-size: 0.8rem;
    margin-left: 18px;
  }
}

/* Legal Links Grid Styles */
.legal-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.legal-link {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.3s ease;
  position: relative;
}

.legal-link:hover {
  background-color: var(--hover-bg);
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.legal-link i:first-child {
  font-size: 1.5rem;
  color: var(--accent-color);
  min-width: 24px;
  text-align: center;
}

.legal-link div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legal-link strong {
  font-size: 1.1rem;
  color: var(--text-color);
  font-weight: 600;
}

.legal-link p {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.8;
  margin: 0;
  line-height: 1.4;
}

.legal-link i:last-child {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.6;
  margin-left: auto;
}

.legal-link:hover i:last-child {
  opacity: 1;
  color: var(--accent-color);
}

/* RTL support for legal links */
[dir="rtl"] .legal-link {
  direction: rtl;
}

[dir="rtl"] .legal-link i:last-child {
  margin-left: 0;
  margin-right: auto;
}

/* Info Modal Responsive Styles */
@media (max-width: 768px) {
  .info-modal-content {
    width: 98%;
    height: 95vh;
    margin: 2.5vh 1%;
  }

  .info-modal-header {
    padding: 15px 20px;
  }

  .info-modal-title {
    font-size: 1.3rem;
  }

  .info-modal-body {
    padding: 20px;
  }

  .shortcuts-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .sync-features {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .shortcut-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .shortcut-item kbd {
    min-width: auto;
    align-self: flex-start;
  }

  .shortcut-item span {
    margin-left: 0;
  }

  .info-section {
    padding: 15px;
    margin-bottom: 20px;
  }

  .info-section-title {
    font-size: 1.2rem;
  }

  .legal-links-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .legal-link {
    padding: 15px;
    gap: 12px;
  }

  .legal-link i:first-child {
    font-size: 1.3rem;
  }

  .legal-link strong {
    font-size: 1rem;
  }

  .legal-link p {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .info-modal-content {
    width: 100%;
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .info-modal-header {
    border-radius: 0;
    padding: 12px 15px;
  }

  .info-modal-title {
    font-size: 1.2rem;
  }

  .info-modal-body {
    padding: 15px;
  }

  .info-section {
    padding: 12px;
    margin-bottom: 15px;
  }

  .gesture-item {
    padding: 10px 0;
  }

  .gesture-icon {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .feature-item {
    padding: 12px;
  }
}

.settings-header,
.solve-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.settings-title,
.solve-details-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-color);
  transition: color 0.3s ease;
}

.settings-close,
.solve-details-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.7;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    opacity 0.3s ease;
}

.settings-close:hover,
.solve-details-close:hover {
  background-color: var(--card-bg);
  opacity: 1;
}

.settings-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.solve-details-body {
  padding: 15px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.settings-section,
.solve-details-section {
  margin-bottom: 15px;
  width: 100%;
  box-sizing: border-box;
}

.solve-details-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.solve-details-section-title {
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-color);
  transition: color 0.3s ease;
}

.copy-scramble-btn,
#stat-detail-copy-scramble {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9rem;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.copy-scramble-btn:hover,
#stat-detail-copy-scramble:hover {
  background-color: var(--hover-bg);
  color: var(--accent-color);
}

.copy-scramble-btn:active,
#stat-detail-copy-scramble:active {
  transform: scale(0.95);
}

/* Ensure scrambles are always LTR direction and center-aligned */
.solve-details-scramble,
.scramble,
.fmc-scramble {
  direction: ltr !important;
  text-align: center !important;
  font-family: monospace !important;
}

/* Override RTL styles specifically for scrambles */
[dir="rtl"] .solve-details-scramble,
[dir="rtl"] .scramble,
[dir="rtl"] .fmc-scramble {
  direction: ltr !important;
  text-align: center !important;
  font-family: monospace !important;
}

/* Ensure scramble text elements also follow the same rules */
.scramble #scramble-text,
.solve-details-scramble .scramble-text,
.fmc-scramble .scramble-text {
  direction: ltr !important;
  text-align: center !important;
  font-family: monospace !important;
}

[dir="rtl"] .scramble #scramble-text,
[dir="rtl"] .solve-details-scramble .scramble-text,
[dir="rtl"] .fmc-scramble .scramble-text {
  direction: ltr !important;
  text-align: center !important;
  font-family: monospace !important;
}

.settings-option {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-color);
  cursor: pointer;
  transition: color 0.3s ease;
}

.checkbox-label span,
.checkbox-label .checkbox-text {
  order: 1;
}

.checkbox-label input[type="checkbox"] {
  order: 2;
}

[dir="rtl"] .checkbox-label {
  flex-direction: row-reverse;
}

.checkbox-label.disabled,
.checkbox-label input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.setting-note {
  font-size: 0.75rem;
  color: var(--text-color);
  opacity: 0.7;
  margin-top: 5px;
  margin-left: 0;
  font-style: italic;
  transition:
    color 0.3s ease,
    opacity 0.3s ease;
}

/* Slider styles */
.slider-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.slider-label {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-color);
  width: 100%;
  transition: color 0.3s ease;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
  transition: background 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #a57865;
  cursor: pointer;
  transition: background 0.3s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #a57865;
  cursor: pointer;
  border: none;
  transition: background 0.3s ease;
}

.slider-value {
  min-width: 40px;
  text-align: center;
  font-family: monospace;
  font-weight: bold;
}

/* Custom Checkbox Styling */
.checkbox-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 61px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 16px;
  background-color: gray;
  cursor: pointer;
  position: relative;
  transition:
    background-color 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
  margin: 0;
  flex-shrink: 0;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.checkbox-label input[type="checkbox"]:hover {
  background-color: darkgray;
}

.checkbox-label input[type="checkbox"]:focus {
  outline: none;
  box-shadow:
    0 0 0 3px var(--focus-ring),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.checkbox-label input[type="checkbox"]:checked {
  background-color: var(--toggle-on);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    inset 0 2px 5px rgba(0, 0, 0, 0.08);
}

.checkbox-label input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 2px;
  width: 36px;
  height: 20px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: var(--toggle-knob);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 -1px 2px rgba(0, 0, 0, 0.08);
  transform: translateX(0);
  transition:
    transform 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.25s ease;
}

.checkbox-label input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

.checkbox-label input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--card-bg);
  box-shadow: inset 0 0 0 1px var(--border-color);
}

.checkbox-label input[type="checkbox"]:disabled:checked {
  background-color: var(--border-color);
}

.settings-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  transition: border-color 0.3s ease;
}

.settings-footer .settings-save-center {
  grid-column: 2;
  justify-self: center;
}

.settings-footer-spacer {
  grid-column: 3;
}

.solve-details-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.3s ease;
}

.solve-details-footer .action-button {
  min-width: 100px;
}

#info-btn {
  background-color: var(--bg-color) !important;
  color: var(--text-color) !important;
  border: 1px solid var(--border-color) !important;
}

#info-btn:hover {
  background-color: var(--hover-bg) !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}

/* Solve details specific styles */
.solve-details-time {
  font-size: 2.5rem;
  font-weight: bold;
  font-family: monospace;
  text-align: center;
  margin-bottom: 5px;
  color: var(--text-color);
  transition: color 0.3s ease;
}

.solve-details-date {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.7;
  margin-bottom: 20px;
  transition: color 0.3s ease;
}

.solve-details-scramble {
  font-family: monospace;
  font-size: calc(
    1.5rem * var(--font-scale)
  ); /* Base font size with scale factor */
  background-color: var(--card-bg);
  color: var(--text-color);
  padding: 10px;
  border-radius: 4px;
  word-wrap: break-word;
  word-break: break-all;
  overflow-wrap: break-word;
  line-height: 1.7; /* Increased line height */
  letter-spacing: 0.1em; /* Added letter spacing */
  margin-bottom: 10px;
  max-width: 100%;
  overflow-x: hidden;
  box-shadow: 0 1px 3px var(--shadow-color);
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    box-shadow 0.3s ease;
}

/* Puzzle-specific font sizes for solve details */
.solve-details-scramble.event-222 {
  font-size: calc(1.9rem * var(--font-scale)); /* 2x2 */
}

.solve-details-scramble.event-333,
.solve-details-scramble.event-333oh,
.solve-details-scramble.event-333fm,
.solve-details-scramble.event-333bf {
  font-size: calc(1.8rem * var(--font-scale)); /* 3x3 and variants */
}

.solve-details-scramble.event-444,
.solve-details-scramble.event-444bf {
  font-size: calc(1.7rem * var(--font-scale)); /* 4x4 */
}

.solve-details-scramble.event-555,
.solve-details-scramble.event-555bf {
  font-size: calc(1.6rem * var(--font-scale)); /* 5x5 */
}

.solve-details-scramble.event-666,
.solve-details-scramble.event-777 {
  font-size: calc(1.3rem * var(--font-scale)); /* 6x6 and 7x7 */
  letter-spacing: 0.08em; /* Slightly reduced letter spacing for long scrambles */
}

.solve-details-scramble.event-skewb,
.solve-details-scramble.event-pyram {
  font-size: calc(1.8rem * var(--font-scale)); /* Skewb and Pyraminx */
}

.solve-details-scramble.event-sq1 {
  font-size: calc(1.7rem * var(--font-scale)); /* Square-1 */
}

.solve-details-scramble.event-clock {
  font-size: calc(1.8rem * var(--font-scale)); /* Clock */
}

.solve-details-scramble.event-minx {
  font-size: calc(1.4rem * var(--font-scale)); /* Megaminx */
}

.solve-details-penalty {
  display: flex;
  gap: 15px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.solve-details-penalty .radio-label {
  gap: 0;
}

.solve-details-penalty .radio-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.solve-details-penalty .radio-label span {
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.solve-details-penalty .radio-label input[type="radio"]:checked + span {
  background: var(--accent-color);
  color: white;
  border-color: transparent;
}

.solve-details-penalty .radio-label input[type="radio"]:disabled + span {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--card-bg);
  border-color: var(--border-color);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  color: var(--text-color);
  cursor: pointer;
  transition: color 0.3s ease;
}

/* Custom Radio Button Styling */
.radio-label input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  background-color: var(--container-bg);
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  margin: 0;
  flex-shrink: 0;
}

.radio-label input[type="radio"]:hover {
  border-color: var(--accent-color);
  background-color: var(--hover-bg);
}

.radio-label input[type="radio"]:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(165, 120, 101, 0.2);
}

.radio-label input[type="radio"]:checked {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.radio-label input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: white;
  transform: translate(-50%, -50%);
}

.radio-label input[type="radio"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--card-bg);
  border-color: var(--border-color);
}

.radio-label input[type="radio"]:disabled:checked {
  background-color: var(--border-color);
}

/* General checkbox and radio styling for any inputs not in specific label classes */
input[type="checkbox"]:not(.checkbox-label input[type="checkbox"]) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 61px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 16px;
  background-color: gray;
  cursor: pointer;
  position: relative;
  transition:
    background-color 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
  margin: 0 8px 0 0;
  flex-shrink: 0;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

input[type="checkbox"]:not(.checkbox-label input[type="checkbox"]):hover {
  background-color: var(--toggle-off);
}

input[type="checkbox"]:not(.checkbox-label input[type="checkbox"]):focus {
  outline: none;
  box-shadow:
    0 0 0 3px var(--focus-ring),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

input[type="checkbox"]:not(.checkbox-label input[type="checkbox"]):checked {
  background-color: var(--toggle-on);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    inset 0 2px 5px rgba(0, 0, 0, 0.08);
}

input[type="checkbox"]:not(.checkbox-label input[type="checkbox"]):disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--card-bg);
  box-shadow: inset 0 0 0 1px var(--border-color);
}

input[type="checkbox"]:not(
    .checkbox-label input[type="checkbox"]
  ):disabled:checked {
  background-color: var(--border-color);
}

input[type="checkbox"]:not(
    .checkbox-label input[type="checkbox"]
  ):checked::after {
  transform: translateX(20px);
}

input[type="checkbox"]:not(.checkbox-label input[type="checkbox"])::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 2px;
  width: 36px;
  height: 20px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: var(--toggle-knob);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 -1px 2px rgba(0, 0, 0, 0.08);
  transform: translateX(0);
  transition:
    transform 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.25s ease;
}

input[type="radio"]:not(.radio-label input[type="radio"]) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  background-color: var(--container-bg);
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  margin: 0 8px 0 0;
  flex-shrink: 0;
}

input[type="radio"]:not(.radio-label input[type="radio"]):hover {
  border-color: var(--accent-color);
  background-color: var(--hover-bg);
}

input[type="radio"]:not(.radio-label input[type="radio"]):focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(165, 120, 101, 0.2);
}

input[type="radio"]:not(.radio-label input[type="radio"]):checked {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

input[type="radio"]:not(.radio-label input[type="radio"]):checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: white;
  transform: translate(-50%, -50%);
}

#solve-details-comment {
  width: 100%;
  height: 80px; /* Fixed height instead of min-height */
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none; /* Prevent resizing which can cause scrolling issues */
  box-sizing: border-box; /* Include padding in width/height calculation */
  background-color: var(--container-bg);
  color: var(--text-color);
  transition:
    border-color 0.3s ease,
    background-color 0.3s ease,
    color 0.3s ease;
}

/* Debug info */
.debug-info {
  position: fixed;
  bottom: 10px;
  right: 10px;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 4px;
  text-align: left;
  font-family: monospace;
  font-size: 0.7rem;
  display: none;
  max-width: 300px;
  z-index: 50;
}

.debug-info.show {
  display: block;
}

.hidden {
  display: none !important;
}

/* Mobile-only elements */
.mobile-only {
  display: none;
}

/* All Events View */
.all-events-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 0;
}

.event-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.event-summary-item:hover {
  background-color: var(--accent-color);
  border-color: var(--header-bg);
}

.event-summary-item:hover .event-name,
.event-summary-item:hover .event-stat-value {
  color: white;
}

.event-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-color);
  min-width: 120px;
}

.event-stats {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.event-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  min-width: 80px;
}

.event-stat:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.event-stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.event-stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-color);
}

.event-stat-value.no-data {
  color: var(--text-secondary);
  font-style: italic;
}

/* Statistics Details Panel - Mobile Responsive */
@media (max-width: 768px) {
  .stats-details-panel {
    height: 100vh;
  }

  .stats-details-header {
    padding: 15px 20px;
    min-height: 50px;
  }

  .stats-details-title-container {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  /* Stack rows vertically on mobile */
  .stats-row {
    flex-direction: column;
    gap: 1rem;
  }

  /* All Events View Mobile */
  .event-summary-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }

  .event-name {
    min-width: auto;
    width: 100%;
    text-align: center;
  }

  .event-stats {
    width: 100%;
    justify-content: space-around;
    gap: 1rem;
  }

  .event-stat {
    min-width: auto;
    flex: 1;
  }

  .stats-details-title-text {
    font-size: 1.2rem;
  }

  .stats-event-selector-btn {
    min-width: 130px;
    max-width: 220px;
    font-size: 0.9rem;
  }

  .stats-details-content {
    padding: 15px 20px;
  }

  .stats-section {
    margin-bottom: 20px;
    padding: 15px;
  }

  .stats-subsection-title {
    font-size: 0.95rem;
    margin: 10px 0 8px 0;
  }

  .stats-section-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-card-value {
    font-size: 1.1rem;
  }

  .analysis-grid,
  .predictions-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .chart-container {
    padding: 15px;
    min-height: 200px;
  }

  .record-item {
    padding: 10px 12px;
  }

  .record-label {
    font-size: 0.9rem;
  }

  .record-value {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .stats-details-header {
    padding: 12px 15px;
  }

  .stats-details-content {
    padding: 12px 15px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card-value {
    font-size: 1rem;
  }

  .chart-container {
    min-height: 180px;
  }
}

/* Responsive design */
@media (max-width: 768px) {
  .main-content {
    /* Keep the same layout as desktop */
    grid-template-areas:
      "scramble scramble"
      "timer timer"
      "stats visualization";
    grid-template-rows: auto 1fr auto;
  }

  .timer,
  .inspection,
  .inspection.ready {
    font-size: 4rem;
  }

  .stats-container,
  .numeric-keyboard-container,
  .visualization {
    height: auto;
    min-height: 150px;
  }

  /* Mobile numeric keyboard adjustments */

  .numeric-key {
    padding: 12px;
    font-size: 1.1rem;
    min-height: 45px;
  }

  .times-panel {
    width: 100%;
    left: -100%;
  }

  /* Show mobile-only elements */
  .mobile-only {
    display: block;
  }

  /* Keep times toggle visible even when panel is open */
  .times-toggle {
    z-index: 2500; /* Even higher z-index on mobile */
    bottom: 15px;
    right: 15px;
    position: fixed;
  }

  /* Hide button text on mobile to save space in times panel footer */
  .times-panel-footer .footer-buttons button span,
  .times-panel-footer .footer-actions button span {
    display: none;
  }

  /* Adjust button padding for icon-only display on mobile */
  #clear-times-btn,
  #edit-session-btn,
  #stats-btn {
    padding: 8px;
    min-width: 36px;
    gap: 0;
  }

  /* RTL mobile fixes */
  [dir="rtl"] .times-toggle {
    z-index: 2500; /* Ensure it stays above other elements */
  }

  [dir="rtl"] .learn-button {
    z-index: 2500; /* Ensure it stays above other elements */
  }

  [dir="rtl"] .times-panel {
    left: auto;
    right: -100%;
    transition:
      right 0.3s ease,
      background-color 0.3s ease,
      box-shadow 0.3s ease;
  }

  [dir="rtl"] .times-panel.show {
    left: auto;
    right: 0;
  }

  .header-center {
    gap: 5px;
  }

  /* Mobile RTL adjustments */
  [dir="rtl"] .header-right {
    right: auto;
    left: 10px;
  }

  [dir="rtl"] .header-left {
    left: auto;
    right: 10px;
  }

  .header-center {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .timer,
  .inspection,
  .inspection.ready {
    font-size: 3.5rem;
  }

  /* Fix manual input container on mobile */
  .manual-input-container {
    width: 90%;
    max-width: 100%;
    margin: 20px auto;
    left: 0;
    right: 0;
    position: relative;
  }

  /* Ensure the timer container centers its content */
  .timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .manual-time-input {
    font-size: 1.8rem;
    padding: 15px 50px 15px 15px; /* Increase right padding for the inspection timer */
    max-width: 250px; /* Smaller max-width for mobile */
  }

  .manual-input-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .input-container {
    max-width: 250px;
  }

  .manual-inspection {
    font-size: 1.3rem;
    right: 15px;
  }

  /* Adjust all scramble font sizes for mobile */
  .scramble {
    font-size: calc(
      1.4rem * var(--font-scale)
    ); /* Mobile base font size with scale factor */
    letter-spacing: 0.08em; /* Added letter spacing for mobile */
    line-height: 1.6; /* Increased line height for mobile */
  }

  /* Mobile puzzle-specific font sizes */
  .scramble.event-222 {
    font-size: calc(1.8rem * var(--font-scale)); /* 2x2 */
  }

  .scramble.event-333,
  .scramble.event-333oh,
  .scramble.event-333fm,
  .scramble.event-333bf {
    font-size: calc(1.7rem * var(--font-scale)); /* 3x3 and variants */
  }

  .scramble.event-444,
  .scramble.event-444bf,
  .scramble.event-sq1,
  .scramble.event-clock {
    font-size: calc(1.6rem * var(--font-scale)); /* 4x4, Square-1, Clock */
  }

  .scramble.event-555,
  .scramble.event-555bf {
    font-size: calc(1.5rem * var(--font-scale)); /* 5x5 */
  }

  .scramble.event-666,
  .scramble.event-777 {
    font-size: calc(1.3rem * var(--font-scale)); /* 6x6 and 7x7 */
    letter-spacing: 0.06em; /* Further reduced letter spacing for mobile */
  }

  .scramble.event-minx {
    font-size: calc(1.4rem * var(--font-scale)); /* Megaminx */
  }

  .scramble.event-skewb,
  .scramble.event-pyram {
    font-size: calc(1.8rem * var(--font-scale)); /* Skewb and Pyraminx */
  }

  .settings-content,
  .solve-details-content {
    width: 95%;
    max-height: 90vh;
  }
}
.container {
  transform: scale(1) !important;
}
/* Scrollbar styling */
.times-list,
.solve-details-body,
.settings-body {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--card-bg);
}

/* Dark mode scrollbar */
.dark-mode .times-list,
.dark-mode .solve-details-body,
.dark-mode .settings-body {
  scrollbar-color: #a57865 #2d2d2d;
}

/* Hidden elements */
/* Audio elements are now handled by the audio-manager.js */

/* MBLD Modal Styles */
.mbld-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 3000;
  overflow: auto;
}

.mbld-modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.mbld-modal-content {
  background-color: var(--container-bg);
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow-color);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

.mbld-scrambles-content,
.mbld-visualizations-content {
  max-width: 800px;
  width: 95%;
  height: 90vh;
}

.mbld-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
}

.mbld-modal-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-color);
}

.mbld-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 5px;
  transition: color 0.3s ease;
}

.mbld-modal-close:hover {
  color: #e74c3c;
}

.mbld-modal-body {
  padding: 20px;
  overflow: hidden scroll;
  flex-grow: 1;
}

.mbld-modal-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.mbld-input-group {
  margin-bottom: 15px;
}

.mbld-input-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-color);
}

.mbld-input {
  width: 50%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--container-bg);
  color: var(--text-color);
  font-size: 1rem;
  transition:
    border-color 0.3s ease,
    background-color 0.3s ease;
}

.mbld-input:focus {
  outline: none;
  border-color: var(--header-bg);
}

.mbld-info {
  margin-top: 15px;
  padding: 10px;
  background-color: var(--card-bg);
  border-radius: 4px;
  color: var(--text-color);
  text-align: center;
  font-size: 14px;
}

.mbld-info.warning {
  background-color: #fff3cd;
  color: #856404;
  font-weight: bold;
}

.mbld-info p {
  margin: 5px 0;
}

/* MBLD Scrambles Container */
.mbld-scramble-item {
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.mbld-scramble-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.mbld-scramble-number {
  font-weight: bold;
  color: var(--text-color);
}

.mbld-scramble-text {
  font-family: monospace;
  font-size: 1.1rem;
  margin-bottom: 15px;
  word-wrap: break-word;
  line-height: 1.5;
  color: var(--text-color);
}

/* MBLD Visualizations Container */
.mbld-visualizations-wrapper {
  width: 100%;
  padding: 10px;
}

.mbld-visualizations-title {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-color);
  font-size: 1.2rem;
}

.mbld-visualization-item {
  margin-bottom: 30px;
  padding: 15px;
  background-color: var(--card-bg);
  border-radius: 8px;
  transition: background-color 0.3s ease;
  box-shadow: 0 2px 5px var(--shadow-color);
}

.mbld-visualization-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 5px;
}

.mbld-visualization-number {
  font-weight: bold;
  color: var(--text-color);
  font-size: 1.1rem;
}

/* Two-column layout for visualization modal */
.mbld-two-column-container {
  display: flex;
  flex-direction: row;
  gap: 15px;
  width: 100%;
}

.mbld-scramble-column {
  flex: 1;
  min-width: 0; /* Prevent overflow */
}

.mbld-visualization-column {
  flex: 1;
  min-width: 0; /* Prevent overflow */
}

.mbld-visualization-scramble {
  font-family: monospace;
  font-size: 0.9rem;
  word-wrap: break-word;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color-secondary);
  padding: 8px;
  border-radius: 4px;
  height: 100%;
  overflow-y: auto;
  max-height: 200px;
}

.mbld-cube-visualization {
  width: 100%;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background-color: var(--bg-color);
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.mbld-cube-visualization twisty-player {
  width: 100%;
  height: 100%;
}

/* Responsive layout for small screens */
@media (max-width: 768px) {
  .mbld-two-column-container {
    flex-direction: column;
  }

  .mbld-visualization-scramble {
    max-height: 100px;
    margin-bottom: 10px;
  }

  .mbld-cube-visualization {
    height: 180px;
  }
}

.mbld-visualization {
  width: 100%;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Make scramble area clickable for MBLD */
.scramble.mbld-clickable {
  cursor: pointer;
  position: relative;
}

/* Removed the after pseudo-element that was adding the text */

/* MBLD Result Display */
.mbld-result {
  display: flex;
  align-items: center;
}

.mbld-score {
  font-weight: bold;
  margin-right: 10px;
}

.mbld-time {
  color: var(--text-color);
}

/* FMC Modal Styles */
.fmc-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.fmc-modal.show {
  opacity: 1;
  visibility: visible;
}

.fmc-modal-content {
  background-color: var(--card-bg);
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  transform: translateY(-20px);
}

.fmc-modal.show .fmc-modal-content {
  transform: translateY(0);
}

.fmc-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
}

.fmc-modal-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-color);
}

.fmc-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-color);
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.fmc-modal-close:hover {
  opacity: 1;
}

.fmc-modal-body {
  padding: 20px;
  overflow-y: auto;
}

.fmc-modal-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.fmc-info {
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--bg-color-secondary);
  border-radius: 6px;
  color: var(--text-color);
  font-size: 0.95rem;
  line-height: 1.5;
}

.fmc-timer-container {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  padding: 10px 15px;
  background-color: var(--bg-color-secondary);
  border-radius: 6px;
}

.fmc-timer-label {
  font-weight: bold;
  margin-right: 10px;
  color: var(--text-color);
}

.fmc-timer {
  font-size: 1.5rem;
  font-family: monospace;
  color: var(--text-color);
}

.fmc-scramble-section {
  margin-bottom: 20px;
}

.fmc-scramble-label {
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-color);
}

.fmc-scramble {
  padding: 15px;
  background-color: var(--bg-color-secondary);
  border-radius: 6px;
  font-family: monospace;
  font-size: 1.1rem;
  line-height: 1.5;
  word-wrap: break-word;
  color: var(--text-color);
}

.fmc-solution-section {
  margin-bottom: 20px;
}

.fmc-solution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.fmc-solution-label {
  font-weight: bold;
  color: var(--text-color);
}

.fmc-move-count-container {
  color: var(--text-color);
  font-size: 0.9rem;
}

.fmc-solution-input {
  width: 100%;
  padding: 15px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: monospace;
  font-size: 1rem;
  resize: vertical;
  min-height: 150px;
  transition: border-color 0.3s ease;
}

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

.fmc-validation {
  margin-top: 10px;
  min-height: 20px;
  font-size: 0.9rem;
}

.fmc-validation.error {
  color: #e74c3c;
}

.fmc-validation.success {
  color: #2ecc71;
}

.fmc-validation.warning {
  color: #f39c12;
}

.fmc-notation-help {
  margin-top: 20px;
  padding: 15px;
  background-color: var(--bg-color-secondary);
  border-radius: 6px;
}

.fmc-notation-help-title {
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-color);
}

.fmc-notation-help-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-color);
}

/* FMC Result Display */
.fmc-result {
  display: flex;
  align-items: center;
}

.fmc-move-count {
  font-weight: bold;
  margin-right: 10px;
  color: var(--text-color);
}

.fmc-time {
  color: var(--text-color);
  font-size: 0.9rem;
  opacity: 0.8;
}

/* FMC Details in Solve Details Modal */
.fmc-details-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.fmc-details-section {
  padding: 10px;
  background-color: var(--bg-color-secondary);
  border-radius: 6px;
}

.fmc-details-header {
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--text-color);
}

.fmc-details-scramble,
.fmc-details-solution {
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  color: var(--text-color);
  margin-bottom: 10px;
}

.fmc-details-move-count {
  font-weight: bold;
  color: var(--accent-color);
  margin-top: 5px;
  font-size: 0.9rem;
}

/* MBLD Solve Details Scrambles */
.mbld-scrambles-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px;
  margin-top: 10px;
}

.mbld-solve-details-scramble-item {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.mbld-solve-details-scramble-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.mbld-solve-details-scramble-header {
  font-weight: bold;
  margin-bottom: 5px;
  color: var(--text-color);
}

.mbld-solve-details-scramble-text {
  font-family: monospace;
  word-wrap: break-word;
  line-height: 1.5;
  color: var(--text-color);
}

/* Webkit scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

.dark-mode ::-webkit-scrollbar-thumb {
  background-color: #a57865;
}

/* Custom Modal Styles */
#custom-modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  pointer-events: none;
}

.custom-modal,
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 10001;
  visibility: hidden;
  padding: 10px;
  box-sizing: border-box;
}

.custom-modal.show,
.modal.show {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.custom-modal-content,
.modal-content {
  background-color: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  color: var(--text-color);
}

.custom-modal.show .custom-modal-content,
.modal.show .modal-content {
  transform: translateY(0);
}

.custom-modal-title,
.modal-title {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.2rem;
  color: var(--text-color);
  font-weight: bold;
}

/* Modal header, body, footer */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  flex-shrink: 0;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scroll-behavior: smooth;
  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) var(--card-bg);
}

/* Webkit scrollbar styling */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--card-bg);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--header-bg);
}

/* Scroll indicator for modal content */
.modal-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(transparent, var(--card-bg));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-content.has-scroll::after {
  opacity: 1;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-color);
  cursor: pointer;
  padding: 5px;
  transition: color 0.3s ease;
  width: auto;
  height: auto;
}

.modal-close:hover {
  color: #e74c3c;
  background: none;
  transform: none;
  box-shadow: none;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border-color);
  padding-top: 15px;
}

.custom-modal-message {
  margin-bottom: 20px;
  line-height: 1.5;
}

.custom-modal-input-container,
.input-group {
  margin-bottom: 20px;
}

.custom-modal-input {
  width: 75%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
}

.session-input {
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
}

/* Styling for session puzzle dropdown */
#session-puzzle {
  padding-right: 30px; /* Extra space for the dropdown arrow */
}

#session-puzzle optgroup {
  font-weight: bold;
  color: var(--text-color);
  background-color: var(--bg-color-secondary);
}

/* Custom styling for the session puzzle dropdown */
.session-puzzle-dropdown {
  position: relative;
  width: 100%;
}

.session-puzzle-dropdown .session-input {
  width: 100%;
}

/* Style for the custom dropdown */
.custom-dropdown-container {
  position: relative;
  width: 100%;
}

.custom-dropdown-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
}

.custom-dropdown-selected i {
  margin-right: 8px;
}

.custom-dropdown-options {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  z-index: 1000;
  display: none;
}

.custom-dropdown-options.show {
  display: block;
}

.custom-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.custom-dropdown-option:hover {
  background-color: var(--bg-color-secondary);
}

.custom-dropdown-group-label {
  font-weight: bold;
  padding: 8px 12px;
  background-color: var(--bg-color-secondary);
  color: var(--text-color);
}

/* ============================================
   Modal Puzzle Selector with Sub-dropdowns
   ============================================ */

.puzzle-selector-wrapper {
  position: relative;
  width: 100%;
}

.puzzle-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease;
}

.puzzle-selector-btn:hover {
  border-color: var(--accent-color);
}

.puzzle-selector-btn .fa-chevron-down {
  margin-left: auto;
  opacity: 0.6;
  font-size: 0.8rem;
}

.puzzle-selector-btn .cubing-icon,
.puzzle-selector-btn .puzzle-icon,
.puzzle-selector-btn .fas {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

/* Main puzzle dropdown */
.puzzle-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 280px;
  max-height: 350px;
  overflow-y: auto;
  background-color: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 1100;
  display: none;
}

.puzzle-dropdown.show {
  display: block;
}

/* Puzzle group header */
.puzzle-group-header {
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
}

.puzzle-group-header:not(:first-child) {
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
}

/* Puzzle option */
.puzzle-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.2s ease;
  position: relative;
}

.puzzle-option:hover {
  background-color: var(--card-bg);
}

.puzzle-option .cubing-icon,
.puzzle-option .puzzle-icon,
.puzzle-option .fas {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.puzzle-option .variant-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  opacity: 0.5;
}

/* Puzzle sub-dropdown */
.puzzle-sub-dropdown {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 200px;
  background-color: var(--container-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 1101;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  margin-left: 2px;
}

.puzzle-option.has-variants:hover > .puzzle-sub-dropdown,
.puzzle-sub-dropdown:hover {
  display: block;
}

/* Sub-options in puzzle dropdown (reuse existing .sub-option styles) */
.puzzle-sub-dropdown .sub-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.puzzle-sub-dropdown .sub-option:hover {
  background-color: var(--card-bg);
}

.puzzle-sub-dropdown .sub-group-header {
  padding: 6px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--container-bg);
  border-bottom: 1px solid var(--border-color);
}

.puzzle-sub-dropdown .sub-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* RTL support for puzzle dropdown */
[dir="rtl"] .puzzle-selector-btn {
  text-align: right;
}

[dir="rtl"] .puzzle-selector-btn .fa-chevron-down {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .puzzle-option .variant-arrow {
  margin-left: 0;
  margin-right: auto;
  transform: scaleX(-1);
}

[dir="rtl"] .puzzle-sub-dropdown {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: 2px;
}

/* Mobile adjustments for puzzle dropdown */
@media (max-width: 768px) {
  .puzzle-sub-dropdown {
    position: fixed;
    left: 50% !important;
    right: auto !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 280px;
    max-height: 50vh;
    margin: 0;
  }

  .puzzle-option.has-variants .variant-arrow {
    transform: rotate(90deg);
  }

  [dir="rtl"] .puzzle-option.has-variants .variant-arrow {
    transform: rotate(-90deg);
  }
}

/* Puzzle icons are handled by puzzle-icons.css */

/* Input group styling */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-weight: bold;
  color: var(--text-color);
}

.custom-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.custom-modal-button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.custom-modal-confirm {
  background-color: var(--accent-color);
  color: #ffffff; /* Always white text for better contrast */
}

.custom-modal-confirm:hover {
  background-color: var(--accent-color-hover);
}

.custom-modal-cancel {
  background-color: var(--bg-color-secondary);
  color: var(--text-color);
  border: 1px solid var(--border-color); /* Add border for better visibility */
}

.custom-modal-cancel:hover {
  background-color: var(--border-color);
}

/* FMC result styling in times list */
.fmc-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.fmc-move-count {
  font-weight: bold;
  color: var(--timer-color);
}

.fmc-time {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 2px;
}

/* Stat Detail Modal */
#stat-detail-modal .modal-content {
  max-width: 800px;
  width: 95%;
  max-height: 90vh;
}

/* Mobile responsive adjustments for modals */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-width: none;
    margin: 10px;
    padding: 15px;
    max-height: 95vh;
  }

  #stat-detail-modal .modal-content {
    width: 98%;
    margin: 5px;
    max-height: 95vh;
  }

  .stat-detail-info {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stat-detail-duration-info {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stat-detail-scramble-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .stat-detail-scramble-text {
    margin-right: 0;
    word-break: break-word;
  }

  .stat-detail-scramble-time {
    min-width: auto;
    text-align: left;
    font-size: 1rem;
  }
}

.stat-detail-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.stat-detail-label {
  font-weight: 500;
  color: var(--text-color);
}

.stat-detail-value {
  font-weight: bold;
  color: var(--accent-color);
}

.stat-detail-scramble-section {
  margin-bottom: 1.5rem;
}

.stat-detail-scramble-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.stat-detail-scramble {
  padding: 1rem;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-family: monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-all;
  text-align: center;
}

.stat-detail-average-info {
  padding: 1rem;
  background-color: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.stat-detail-duration-info {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-detail-datetime-range {
  grid-column: 1 / -1;
}

.stat-detail-datetime-range .stat-detail-value {
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.stat-detail-scrambles-section {
  margin-top: 1.5rem;
}

.stat-detail-scrambles-list {
  margin-top: 0.5rem;
}

.stat-detail-scramble-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: var(--bg-color);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-family: monospace;
  font-size: 0.9rem;
}

.stat-detail-scramble-text {
  flex: 1;
  margin-right: 1rem;
  word-break: break-all;
}

.stat-detail-scramble-time {
  font-weight: bold;
  color: var(--accent-color);
  min-width: 80px;
  text-align: right;
}

.stat-detail-scramble-time.best {
  color: #28a745;
}

.stat-detail-scramble-time.worst {
  color: #dc3545;
}

.stat-detail-times-list {
  margin-bottom: 1rem;
}

.stat-detail-times {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.stat-detail-time-item {
  padding: 0.5rem;
  background-color: var(--bg-color);
  border-radius: 4px;
  text-align: center;
  font-family: monospace;
  font-size: 0.9rem;
}

.stat-detail-time-item.best {
  color: #28a745;
  font-weight: bold;
}

.stat-detail-time-item.worst {
  color: #dc3545;
  font-weight: bold;
}

/* Make clickable statistics have hover effect */
.stat-card[style*="cursor: pointer"],
.record-item[style*="cursor: pointer"] {
  transition:
    background-color 0.2s ease,
    transform 0.1s ease,
    border-color 0.2s ease;
}

.stat-card[style*="cursor: pointer"]:hover,
.record-item[style*="cursor: pointer"]:hover {
  background-color: var(--accent-color);
  border-color: var(--header-bg);
}

.stat-card[style*="cursor: pointer"]:hover .stat-card-label,
.stat-card[style*="cursor: pointer"]:hover .stat-card-value,
.record-item[style*="cursor: pointer"]:hover .record-label,
.record-item[style*="cursor: pointer"]:hover .record-value {
  color: white;
}

/* Import/Export Section */
.stats-import-export-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background-color: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.import-export-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.import-export-btn {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
}

.import-export-btn:hover {
  background-color: var(--header-bg);
}

.import-export-btn:active {
  transform: translateY(0);
}

.import-export-btn i {
  font-size: 1rem;
}

@media (max-width: 768px) {
  .import-export-buttons {
    flex-direction: column;
  }
}

/* ============================================================================
   SMARTPHONE LINK MODE STYLES
   ============================================================================ */

/* Smartphone Link Status - similar to Stackmat status */
.smartphone-link-status {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 5;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.smartphone-link-status.show {
  display: block;
}

.smartphone-link-connection {
  display: flex;
  align-items: center;
  gap: 8px;
}

.smartphone-link-connection .smartphone-status-icon {
  font-size: 1.1rem;
  color: var(--text-color);
}

.smartphone-link-status.connected .smartphone-status-icon {
  color: #28a745;
}

.smartphone-link-status.waiting .smartphone-status-icon {
  color: #ff9800;
}

.smartphone-link-status.disconnected .smartphone-status-icon {
  color: #dc3545;
}

.smartphone-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
}

.smartphone-link-status.connected .smartphone-status-dot {
  background: #28a745;
  box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
  animation: smartphonePulse 2s infinite;
}

.smartphone-link-status.waiting .smartphone-status-dot {
  background: #ff9800;
  animation: smartphoneWaiting 1s infinite;
}

.smartphone-link-status.reconnecting .smartphone-status-dot {
  background: #ff9800;
  animation: smartphoneWaiting 0.5s infinite;
}

.smartphone-link-status.disconnected .smartphone-status-dot {
  background: #dc3545;
}

@keyframes smartphonePulse {
  0%,
  100% {
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
  }
  50% {
    box-shadow: 0 0 12px rgba(40, 167, 69, 0.9);
  }
}

@keyframes smartphoneWaiting {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.smartphone-status-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-color);
  white-space: nowrap;
}

/* Action buttons in status bar */
.smartphone-action-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  background: var(--btn-bg, #8a6553);
  color: white;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

.smartphone-action-btn:hover {
  background: var(--header-bg, #a57865);
  transform: scale(1.05);
}

.smartphone-action-btn.disconnect {
  background: #dc3545;
}

.smartphone-action-btn.disconnect:hover {
  background: #c82333;
}

/* Mobile responsive Smartphone Link status */
@media (max-width: 768px) {
  .smartphone-link-status {
    top: 5px;
    left: 5px;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .smartphone-link-connection {
    gap: 6px;
  }

  .smartphone-status-text {
    font-size: 0.75rem;
  }

  .smartphone-action-btn {
    padding: 3px 6px;
    font-size: 0.7rem;
  }
}

/* Smartphone Link Modal - override base .modal styles */
.smartphone-link-modal.modal {
  /* Reset base modal hidden state */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10002;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.smartphone-link-modal.modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.smartphone-link-modal-content {
  background: var(--card-bg, #ffffff);
  border-radius: 16px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.smartphone-link-modal-content .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--header-bg, #a57865);
  color: white;
}

.smartphone-link-modal-content .modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.smartphone-link-modal-content .close-modal {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.smartphone-link-modal-content .close-modal:hover {
  background: rgba(255, 255, 255, 0.2);
}

.smartphone-link-modal-body {
  padding: 24px;
  text-align: center;
}

.qr-code-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  margin-bottom: 16px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.qr-code-container canvas,
.qr-code-container img {
  border-radius: 8px;
}

.qr-code-loading,
.qr-code-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-color, #666);
}

.qr-code-loading i {
  font-size: 2rem;
  color: var(--header-bg, #a57865);
}

.qr-code-error i {
  font-size: 2rem;
  color: #f44336;
}

.qr-instructions {
  font-size: 0.95rem;
  color: var(--text-color, #666);
  margin-bottom: 16px;
  line-height: 1.5;
}

.session-id-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.session-id-value {
  font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--header-bg, #a57865);
  background: rgba(165, 120, 101, 0.1);
  padding: 6px 12px;
  border-radius: 6px;
}

.connection-status-text {
  font-size: 0.9rem;
  color: var(--text-color, #888);
  margin: 0;
}

/* QR Link Actions (Copy Link & Scan QR buttons) */
.qr-link-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.qr-link-actions .action-button.small {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 6px;
}

.qr-link-actions .action-button.small i {
  font-size: 0.9rem;
}

/* QR Scanner Section */
.qr-scanner-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.qr-scanner-container {
  position: relative;
  width: 280px;
  height: 280px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

#qr-scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.qr-scanner-frame {
  width: 200px;
  height: 200px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.qr-scanner-instructions {
  font-size: 0.9rem;
  color: var(--text-color, #666);
  text-align: center;
  margin: 0;
}

.smartphone-link-modal-content .modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  background: var(--card-bg, #f5f5f5);
  border-top: 1px solid var(--border-color, #ddd);
}

.smartphone-link-modal-content .modal-footer .action-button {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.smartphone-link-modal-content .modal-footer .action-button:not(.secondary) {
  background: var(--btn-bg, #8a6553);
  color: white;
}

.smartphone-link-modal-content
  .modal-footer
  .action-button:not(.secondary):hover {
  background: var(--header-bg, #a57865);
}

.smartphone-link-modal-content .modal-footer .action-button.secondary {
  background: #e0e0e0;
  color: #333;
}

.smartphone-link-modal-content .modal-footer .action-button.secondary:hover {
  background: #d0d0d0;
}

/* Dark mode overrides for smartphone link */
@media (prefers-color-scheme: dark) {
  .smartphone-link-status {
    background: var(--card-bg, #1e1e1e);
    border-color: var(--border-color, #333);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .smartphone-link-modal-content {
    background: var(--card-bg, #2a2a2a);
  }

  .qr-code-container {
    background: #ffffff;
  }

  .smartphone-link-modal-content .modal-footer {
    background: var(--card-bg, #222);
    border-color: #444;
  }

  .smartphone-link-modal-content .modal-footer .action-button.secondary {
    background: #444;
    color: #fff;
  }

  .smartphone-link-modal-content .modal-footer .action-button.secondary:hover {
    background: #555;
  }

  .qr-link-actions .action-button.secondary {
    background: #444;
    color: #fff;
  }

  .qr-link-actions .action-button.secondary:hover {
    background: #555;
  }

  .qr-scanner-instructions {
    color: #aaa;
  }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .smartphone-link-status {
    margin: 8px;
    padding: 8px 12px;
    gap: 8px;
  }

  .smartphone-link-status .smartphone-status-text {
    font-size: 0.8rem;
  }

  .smartphone-link-modal-content {
    max-width: 100%;
    margin: 10px;
    border-radius: 12px;
  }

  .smartphone-link-modal-body {
    padding: 16px;
  }

  .qr-code-container {
    min-height: 180px;
  }

  .qr-link-actions {
    flex-direction: column;
    gap: 8px;
  }

  .qr-link-actions .action-button.small {
    width: 100%;
  }

  .qr-scanner-container {
    width: 100%;
    max-width: 280px;
    height: 250px;
  }
}

/* ==========================================
   Mobile Landscape Layout
   Target: Mobile phones in landscape mode only
   Uses max-height to exclude tablets/laptops/desktops/TVs
   Typical mobile landscape height: 320-450px
   ========================================== */
@media screen and (orientation: landscape) and (max-height: 450px) {
  /* Make the main container a 4-column, 5-row grid */
  .container {
    display: grid;
    grid-template-columns: minmax(100px, 0.9fr) 1fr 1fr minmax(80px, 0.9fr);
    grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
    gap: 8px;
    padding: 8px;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    overflow: hidden;
    box-sizing: border-box;
  }

  /* Header becomes ROWS 1-2, COLUMN 1 - contains dropdown + buttons */
  header {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    background-color: var(--bg-color);
    border-radius: 0;
    box-shadow: none;
    height: 100%;
    box-sizing: border-box;
    align-content: stretch;
  }

  /* Flatten header divisions so children participate in header's flex */
  .header-left,
  .header-center,
  .header-right {
    display: contents;
  }

  /* Event selector - full width row 1 */
  .event-selector {
    flex: 0 0 100%;
    width: 100%;
    height: 50%;
    display: flex;
    align-items: stretch;
    order: 1;
    box-sizing: border-box;
  }

  .event-selector-btn {
    width: 100%;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.8rem;
    min-height: unset;
    height: 100%;
  }

  /* Buttons - row 2, equal width, auto-adjust when privacy hidden */
  .learning-button,
  .apps-menu-button,
  .settings-button,
  #new-scramble.action-button {
    flex: 1 1 0;
    min-width: 0;
    height: calc(50% - 4px);
    padding: 4px 2px;
    font-size: 0.7rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  /* Privacy button - no !important so JS can hide it */
  .privacy-link {
    flex: 1 1 0;
    min-width: 0;
    height: calc(50% - 4px);
    padding: 4px 2px;
    font-size: 0.7rem;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    order: 3;
  }

  .privacy-link .privacy-text {
    display: none;
  }

  /* Button ordering */
  .learning-button,
  .apps-menu-button {
    order: 2;
  }

  .settings-button {
    order: 4;
  }

  #new-scramble.action-button {
    order: 5;
  }

  /* Hide unnecessary header elements in mobile landscape */
  .battle-button,
  .close-learning-button,
  .learning-header-controls {
    display: none !important;
  }

  /* Main content uses display: contents so children join container grid */
  .main-content {
    display: contents;
  }

  /* Scramble section - ROWS 1-2, COLUMNS 2-4 */
  .scramble-section {
    grid-area: unset !important;
    grid-column: 2 / 5 !important;
    grid-row: 1 / 3 !important;
    margin: 0;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    min-height: 0 !important;
    max-height: none !important;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    align-self: stretch;
  }

  .scramble-wrapper {
    width: 100%;
    max-height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    box-sizing: border-box;
  }

  .scramble {
    width: 100%;
    max-height: 100% !important;
    flex: 1 1 auto;
    font-size: 0.95rem;
    line-height: 1.4;
    letter-spacing: 0.05em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
    display: flex;
  }

  /* Stats container - ROWS 3-5, COLUMN 1 */
  .stats-container {
    grid-column: 1;
    grid-row: 3 / 6;
    min-height: unset;
    padding: 8px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .stats {
    flex-direction: column;
    gap: 2px;
  }

  .stat-item {
    padding: 2px 0;
    flex-direction: row;
    gap: 4px;
  }

  .stat-label,
  .stat-value {
    font-size: 0.9rem;
  }

  /* Show ao1000 in mobile landscape */
  .stat-item-ao1000 {
    display: flex !important;
  }

  /* Timer container - ROWS 3-5, COLUMNS 2-3 */
  .timer-container {
    grid-column: 2 / 4;
    grid-row: 3 / 6;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 8px;
    min-height: unset;
  }

  .timer {
    font-size: 4rem;
  }

  .inspection,
  .inspection.ready {
    font-size: 4rem;
  }

  /* Visualization - ROWS 3-5, COLUMN 4 */
  .visualization {
    grid-column: 4;
    grid-row: 3 / 6;
    min-height: unset;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .visualization > * {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }

  /* Hide numeric keyboard in mobile landscape to save space, except in typing mode */
  body:not(.timer-mode-typing) .numeric-keyboard-container {
    display: none !important;
  }

  /* In typing mode, show keyboard and hide stats */
  body.timer-mode-typing .stats-container {
    display: none !important;
  }

  /* Position numeric keyboard in same grid area as stats in landscape */
  body.timer-mode-typing .numeric-keyboard-container {
    grid-column: 1;
    grid-row: 3 / 6;
    min-height: unset;
    padding: 4px;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
  }

  /* Force inner keyboard element to show in landscape typing mode */
  body.timer-mode-typing .numeric-keyboard {
    display: block !important;
  }

  /* Compact keyboard buttons for landscape */
  body.timer-mode-typing .numeric-key {
    padding: 6px 4px;
    font-size: 0.95rem;
    min-height: 32px;
  }

  /* Hide battle panel and other non-essential elements */
  .battle-panel,
  .battle-stats,
  .stackmat-status,
  .smartphone-link-status {
    display: none !important;
  }

  /* Hide manual input container in landscape, except in typing mode */
  body:not(.timer-mode-typing) .manual-input-container {
    display: none !important;
  }

  /* Style manual input container for landscape typing mode */
  body.timer-mode-typing .manual-input-container {
    display: flex !important;
    margin: 0;
    max-width: 100%;
  }

  /* Algorithm box adjustments for learning mode */
  .algorithm-box {
    font-size: 0.85rem;
    padding: 4px 8px;
  }

  /* Event dropdown adjustments */
  .event-dropdown {
    max-height: 60vh;
    font-size: 0.85rem;
  }

  .event-option {
    padding: 6px 10px;
  }

  /* Times panel adjustments - slide from right edge */
  .times-panel {
    width: 250px;
    max-width: 40vw;
  }

  .times-panel.open {
    transform: translateX(0);
  }

  /* Settings modal - full height for better visibility */
  .settings-content {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* Additional breakpoint for very small landscape screens (e.g., iPhone SE landscape) */
@media screen and (orientation: landscape) and (max-height: 350px) {
  .container {
    gap: 4px;
    padding: 4px;
  }

  header {
    padding: 4px;
    gap: 2px;
  }

  .event-selector-btn {
    padding: 4px 6px;
    font-size: 0.7rem;
    min-height: 28px;
  }

  .learning-button,
  .apps-menu-button,
  .settings-button,
  #new-scramble.action-button {
    padding: 4px 2px;
    font-size: 0.65rem;
  }

  .scramble {
    font-size: 0.85rem;
  }

  .timer {
    font-size: 2rem;
  }

  .inspection,
  .inspection.ready {
    font-size: 2rem;
  }

  .stat-label,
  .stat-value {
    font-size: 0.6rem;
  }

  .stats-container,
  .timer-container,
  .visualization,
  .scramble-section {
    padding: 0;
  }
}
