    :root {
      --bg: #090d16;
      --card-bg: #131b2e;
      --card-border: #1e293b;
      --text: #f8fafc;
      --text-muted: #94a3b8;
      --clv-color: #38bdf8;
      --hkp-color: #fbbf24;
      --tube-width: 92px;
      --tube-height: 440px;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      user-select: none;
      -webkit-user-select: none;
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    }

    body {
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 16px 20px 24px;
      overflow-x: hidden;
    }

    /* Container sized specifically for iPad Pro 11-inch Portrait */
    .app-viewport {
      width: 100%;
      max-width: 820px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    /* Header Bar: Stabilized 3-Column Grid */
    header {
      background: var(--card-bg);
      border: 1px solid var(--card-border);
      border-radius: 16px;
      padding: 10px 20px;
      min-height: 68px; /* Locked anchor height prevents any vertical bounce */
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
      transition: border-color 0.3s ease, box-shadow 0.3s ease;
    }

    /* Left-Justified Center Title */
    .title-group {
      text-align: left;
      margin-left: 4px;
    }

    .title-group h1 {
      font-size: 20px;
      font-weight: 700;
      letter-spacing: -0.02em;
      color: #fff;
      line-height: 1.2;
    }

    .title-group p {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
      letter-spacing: 0.02em;
    }

    /* Right Action Buttons */
    .btn-group {
      justify-self: end;
      display: flex;
      align-items: center;
      gap: 8px;
    }
	
	/* Anti-Shift Fixed Widths */
    #btn-main {
      min-width: 114px;
      text-align: center;
    }

    #btn-undo {
      min-width: 126px;
      text-align: center;
    }
	
    /* Left Utilities */
    .header-left {
      display: flex;
      align-items: center;
      gap: 14px;
    }

    /* Stacked Demo Toggle (No Shift) */
    .demo-toggle-group {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      user-select: none;
    }
	
    /* Strict Anti-Wrap & Height Lockdown for All Buttons */
    button {
      padding: 10px 18px;
      border-radius: 10px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      border: none;
      transition: all 0.15s ease;
      		
      white-space: nowrap !important; /* Prevents text from ever breaking onto 2 lines */
      height: 40px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .btn-primary {
      background: #2563eb;
      color: #fff;
      box-shadow: 0 2px 8px rgba(37,99,235,0.4);
    }
    .btn-primary:active { transform: scale(0.97); background: #1d4ed8; }

    .btn-secondary {
      background: #1e293b;
      color: #cbd5e1;
      border: 1px solid #334155;
    }
    .btn-secondary:active { transform: scale(0.97); background: #334155; }

    /* Legend Bar with Contextual Info Button */
    .legend-bar {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 24px;
      font-size: 13px;
      padding: 4px 0;
    }

    .legend-item {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .legend-line {
      width: 24px;
      height: 4px;
      border-radius: 2px;
    }
    .line-clv { background: var(--clv-color); }
    .line-hkp { background: var(--hkp-color); border-top: 1px dashed #fff; }

    /* Stage: Vertical Tubes */
    .stage {
      background: var(--card-bg);
      border: 1px solid var(--card-border);
      border-radius: 20px;
      padding: 24px 16px 20px;
      display: flex;
      justify-content: space-around;
      position: relative;
      box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
    }

    .tube-column {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: var(--tube-width);
    }

    .cylinder-container {
      position: relative;
      width: var(--tube-width);
      height: var(--tube-height);
      background: rgba(255, 255, 255, 0.02);
      border-radius: 46px 46px 20px 20px;
      border: 2px solid rgba(255, 255, 255, 0.12);
      border-top: 3px solid rgba(255, 255, 255, 0.25);
      overflow: hidden;
      box-shadow: inset 0 0 16px rgba(0,0,0,0.6);
    }

    /* Glass highlights */
    .cylinder-container::before {
      content: "";
      position: absolute;
      top: 0;
      left: 6px;
      width: 8px;
      height: 100%;
      background: linear-gradient(90deg, rgba(255,255,255,0.25), rgba(255,255,255,0.0));
      z-index: 10;
      pointer-events: none;
      border-radius: 4px;
    }

    .candy-canvas {
      width: 100%;
      height: 100%;
      position: absolute;
      bottom: 0;
      left: 0;
      z-index: 2;
    }

    /* Overlay Target Lines */
    .target-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 5;
      pointer-events: none;
    }

    .target-line {
      position: absolute;
      width: 100%;
      height: 2px;
      z-index: 6;
    }

    .target-clv {
      background: var(--clv-color);
      box-shadow: 0 0 6px var(--clv-color);
    }

    .target-hkp {
      border-top: 2px dashed var(--hkp-color);
    }

    .error-band-clv {
      position: absolute;
      width: 100%;
      background: rgba(56, 189, 248, 0.15);
      border-top: 1px dotted rgba(56, 189, 248, 0.5);
      border-bottom: 1px dotted rgba(56, 189, 248, 0.5);
      z-index: 4;
    }

    .error-band-hkp {
      position: absolute;
      width: 100%;
      background: rgba(251, 191, 36, 0.12);
      border-top: 1px dashed rgba(251, 191, 36, 0.4);
      border-bottom: 1px dashed rgba(251, 191, 36, 0.4);
      z-index: 3;
    }

    /* Column Footers */
    .tube-meta {
      margin-top: 12px;
      text-align: center;
    }

    .color-name {
      font-size: 13px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .count-readout {
      font-size: 18px;
      font-weight: 800;
      margin-top: 2px;
      font-variant-numeric: tabular-nums;
    }

    .pct-readout {
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 500;
    }

    /* Analytics Dashboard */
    .dashboard {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
    }

    .stat-card {
      background: var(--card-bg);
      border: 1px solid var(--card-border);
      border-radius: 18px;
      padding: 16px 20px;
      position: relative;
    }

    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
    }

    .plant-title {
      font-size: 15px;
      font-weight: 700;
    }

    .status-badge {
      font-size: 11px;
      font-weight: 700;
      padding: 4px 8px;
      border-radius: 6px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .badge-consistent {
      background: rgba(34, 197, 94, 0.2);
      color: #4ade80;
      border: 1px solid rgba(34, 197, 94, 0.4);
    }

    .badge-rejected {
      background: rgba(239, 68, 68, 0.2);
      color: #f87171;
      border: 1px solid rgba(239, 68, 68, 0.4);
    }

    .metrics-row {
      display: flex;
      justify-content: space-between;
      margin-top: 8px;
    }
	
	.metric-item span {
      display: block;
      font-size: 11px;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    /* Override the parent block and uppercase rules */
    .metric-item span .math-symbol {
      display: inline !important;
      text-transform: none !important;
      font-style: italic;
      font-weight: 600;
      font-family: "Segoe UI Symbol", "Cambria Math", "SF Pro Display", sans-serif;
    }
		
    .metric-item strong {
      font-size: 17px;
      font-weight: 700;
      font-variant-numeric: tabular-nums;
    }

    /* Bottom Summary Bar */
    .verdict-banner {
      grid-column: span 2;
      background: linear-gradient(135deg, #1e293b, #0f172a);
      border: 1px solid #334155;
      border-radius: 14px;
      padding: 14px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .verdict-text h4 {
      font-size: 14px;
      color: #e2e8f0;
      font-weight: 600;
    }

    .verdict-text p {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .ratio-pill {
      background: #1e1b4b;
      border: 1px solid #4338ca;
      color: #a5b4fc;
      padding: 6px 14px;
      border-radius: 20px;
      font-size: 13px;
      font-weight: 700;
    }

    /* Modal for adding a bag */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.7);
      backdrop-filter: blur(4px);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 100;
    }

    .modal-card {
      background: #1e293b;
      border: 1px solid #334155;
      border-radius: 20px;
      padding: 24px;
      width: 90%;
      max-width: 480px;
      box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    }

    .modal-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin: 16px 0 20px;
    }

    .input-field label {
      display: block;
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 4px;
      text-transform: uppercase;
    }

    .input-field input {
      width: 100%;
      padding: 10px;
      border-radius: 8px;
      background: #0f172a;
      border: 1px solid #334155;
      color: #fff;
      font-size: 16px;
      font-weight: 700;
      text-align: center;
    }
		
	/* --- Demo / Simulation Mode Styling using an iOS Toggle Switch --- */
    .toggle-wrapper {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-right: 4px;
      user-select: none;
    }

    .toggle-label {
      font-size: 9px;
      font-weight: 800;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      text-transform: uppercase;
      transition: color 0.3s ease;
    }

    .switch {
      position: relative;
      display: inline-block;
      width: 44px;
      height: 24px;
    }

    .switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #1e293b;
      border: 1px solid #334155;
      transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .slider:before {
      position: absolute;
      content: "";
      height: 18px;
      width: 18px;
      left: 2px;
      bottom: 2px;
      background-color: #cbd5e1;
      transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
	
    .slider-ticks {
      width: 100%; /* Forces ticks to span the full width of the slider */
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 10px;
      color: var(--text-muted);
      margin-top: 4px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      padding: 0 4px; /* Aligns text with the center of the thumb at both ends */
      box-sizing: border-box;
    }

    /* iOS Amber Active State */
    .switch input:checked + .slider {
      background-color: #d97706;
      border-color: #f59e0b;
      box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
    }

    .switch input:checked + .slider:before {
      transform: translateX(20px);
      background-color: #ffffff;
    }

    .slider.round {
      border-radius: 24px;
    }

    .slider.round:before {
      border-radius: 50%;
    }
	

    /* Subdued, tight amber glow in Demo mode */
    header.demo-mode-active {
      background: linear-gradient(135deg, #1c1917, #24201c);
      border-color: #d97706;
      box-shadow: 0 4px 16px rgba(217, 119, 6, 0.2);
    }

    header.demo-mode-active .title-group h1 {
      color: #fbbf24;
    }

    header.demo-mode-active .title-group p {
      color: #fde68a;
    }

    .btn-mode-active {
      background: #78350f !important;
      color: #fef08a !important;
      border-color: #f59e0b !important;
    }

    .btn-play-active {
      background: #d97706 !important;
      color: #fff !important;
      box-shadow: 0 2px 10px rgba(217, 119, 6, 0.4) !important;
    }
	
	/* --- Vertical Percentage Axis --- */
    .y-axis-container {
      width: 48px;
      height: var(--tube-height);
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      position: relative;
      margin-right: 6px;
      user-select: none;
    }

    .axis-track {
      width: 100%;
      height: 100%;
      position: relative;
      border-right: 1px solid rgba(255, 255, 255, 0.15);
    }

    .axis-tick {
      position: absolute;
      right: 0;
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      transform: translateY(50%);
    }

    .tick-label {
      font-size: 11px;
      font-weight: 700;
      color: var(--text-muted);
      margin-right: 6px;
      font-variant-numeric: tabular-nums;
    }

    .tick-mark {
      width: 6px;
      height: 1px;
      background: rgba(255, 255, 255, 0.3);
    }

    /* Polished Likelihood Ratio Pill */
    .ratio-pill {
      background: #141b2e;
      border: 1px solid #3b82f6;
      color: #93c5fd;
      padding: 8px 16px;
      border-radius: 20px;
      font-size: 13px;
      font-weight: 700;
      white-space: nowrap;
      transition: all 0.3s ease;
    }
	
	
	/* --- Smooth Opacity Transitions for Target Overlays --- */
    .target-line,
    .error-band-clv,
    .error-band-hkp {
      transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Flanking Arrow Readout Layout */
    .count-readout {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 3px;
      margin-top: 2px;
    }

    .arrow-ind {
      font-size: 10px;
      font-weight: 800;
      width: 12px;
      display: inline-block;
      user-select: none;
    }

    .arrow-clv {
      text-align: right;
      color: var(--clv-color);
    }

    .arrow-hkp {
      text-align: left;
      color: var(--hkp-color);
    }

    .count-val {
      font-size: 18px;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      transition: color 0.3s ease;
      min-width: 28px;
      text-align: center;
    }


    /* --- Borderless Standalone Icon Buttons (Info & Settings) --- */
    .btn-icon {
      background: transparent !important;
      border: none !important;
      box-shadow: none !important;
      padding: 4px !important;
      width: auto !important;
      height: auto !important;
      min-width: unset !important;
      font-size: 16px;
      line-height: 1;
      color: var(--text-muted);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: color 0.15s ease, transform 0.15s ease;
      user-select: none;
    }

    .btn-icon:hover {
      color: #38bdf8;
    }

    .btn-icon:active {
      transform: scale(0.92);
      color: #fff;
    }
	
    /* Larger, Sleek Settings Gear */
    #btn-settings {
      font-size: 26px !important; /* Slightly larger, crisp touch target */
      color: var(--text-muted);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.25s ease, color 0.2s ease;
    }
    #btn-settings:hover {
      color: #38bdf8;
      transform: rotate(45deg);
    }
    #btn-settings:active {
      transform: scale(0.92) rotate(90deg);
    }	
	
	    /* Header Bar: Clean Flexbox with Left-to-Right Flow */
    header {
      background: var(--card-bg);
      border: 1px solid var(--card-border);
      border-radius: 16px;
      padding: 10px 20px;
      min-height: 68px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0 4px 12px rgba(0,0,0,0.3);
      transition: border-color 0.3s ease, box-shadow 0.3s ease;
    }

    /* Larger, Sleek Settings Gear */
    #btn-settings {
      font-size: 26px !important; /* Slightly larger, crisp touch target */
      color: var(--text-muted);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.25s ease, color 0.2s ease;
    }
    #btn-settings:hover {
      color: #38bdf8;
      transform: rotate(45deg);
    }
    #btn-settings:active {
      transform: scale(0.92) rotate(90deg);
    }

    /* Left-Justified Title */
    .title-group {
      text-align: left;
      margin-left: 4px;
    }

    .title-group h1 {
      font-size: 20px;
      font-weight: 700;
      letter-spacing: -0.02em;
      color: #fff;
      line-height: 1.2;
    }

    .title-group p {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
      letter-spacing: 0.02em;
    }

    .btn-info-legend {
      background: transparent !important;
      border: none !important;
      color: var(--text-muted);
      font-size: 18px;
      line-height: 1;
      padding: 2px 6px !important;
      height: auto !important;
      min-width: unset !important;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: color 0.2s ease, transform 0.2s ease;
      margin-left: -8px;
    }

    .btn-info-legend:hover,
    .btn-info-legend:active {
      color: #38bdf8;
      transform: scale(1.2);
    }
	

    /* --- Info Modal Styling --- */
    .info-modal-card {
      max-width: 580px;
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      padding: 24px;
      overflow: hidden;
    }

    .info-header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 16px;
      border-bottom: 1px solid #334155;
      padding-bottom: 12px;
    }

    .info-header h2 {
      font-size: 19px;
      font-weight: 700;
      color: #fff;
    }

    .info-sub {
      font-size: 12px;
      color: var(--text-muted);
      margin-top: 2px;
    }

    .btn-close {
      width: 32px;
      height: 32px;
      min-width: 32px !important;
      padding: 0 !important;
      border-radius: 8px;
      background: #1e293b;
      color: #94a3b8;
      border: 1px solid #334155;
      font-size: 14px;
      cursor: pointer;
    }

    .info-body {
      overflow-y: auto;
      padding-right: 6px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .info-section h3 {
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #38bdf8;
      margin-bottom: 6px;
    }

    .info-section p {
      font-size: 13px;
      line-height: 1.5;
      color: #cbd5e1;
      margin-bottom: 6px;
    }

    /* --- Recipe Table --- */
    .recipe-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
      margin-top: 8px;
      background: #0f172a;
      border-radius: 8px;
      overflow: hidden;
    }

    .recipe-table th, 
    .recipe-table td {
      padding: 9px 12px;
      border-bottom: 1px solid #1e293b;
    }

    .recipe-table th, 
    .recipe-table td {
      padding: 8px 10px;
      text-align: left;
      border-bottom: 1px solid #1e293b;
    }

    .recipe-table th {
      background: #1e293b;
      color: #94a3b8;
      font-weight: 700;
      font-size: 11px;
      text-transform: uppercase;
      vertical-align: bottom; /* Aligns single-line and two-line headers along bottom baseline */
      line-height: 1.3;
    }

    .recipe-table td:first-child,
    .recipe-table th:first-child {
      white-space: nowrap;
      min-width: 95px;
    }

    .recipe-table th:nth-child(2),
    .recipe-table td:nth-child(2),
    .recipe-table th:nth-child(3),
    .recipe-table td:nth-child(3) {
      text-align: center;
    }

    .swatch {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      margin-right: 8px;
      vertical-align: middle;
    }

	.highlight-val-clv {
      font-weight: 700;
      color: var(--clv-color) !important;
    }

	.highlight-val-hkp {
      font-weight: 700;
      color: var(--hkp-color) !important;
    }

    .info-link {
      color: #38bdf8;
      font-size: 13px;
      font-weight: 600;
      text-decoration: none;
      display: inline-block;
      margin-top: 4px;
    }
    .info-link:hover { text-decoration: underline; }

    .info-footer {
      margin-top: 18px;
      padding-top: 12px;
      border-top: 1px solid #334155;
    }
	
	
	/* --- Settings Modal Styling --- */
    .settings-modal-card {
      max-width: 580px;
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      padding: 24px;
      overflow: hidden;
    }

    .settings-body {
      overflow-y: auto;
      padding-right: 6px;
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    .settings-section h3 {
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: #38bdf8;
      margin-bottom: 8px;
    }

    .settings-desc {
      font-size: 12px;
      color: var(--text-muted);
      line-height: 1.4;
      margin-bottom: 10px;
    }

    /* Export Box */
    .export-box {
      background: #0f172a;
      border: 1px solid #1e293b;
      border-radius: 10px;
      padding: 12px 16px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .export-stat {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .export-label {
      font-size: 11px;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    .export-stat strong {
      font-size: 14px;
      color: #fff;
    }

    .btn-export {
      background: #059669;
      color: #fff;
      font-weight: 700;
      padding: 10px 16px;
      border-radius: 8px;
      border: none;
      cursor: pointer;
      box-shadow: 0 2px 8px rgba(5, 150, 105, 0.4);
      transition: all 0.15s ease;
    }
    .btn-export:active { transform: scale(0.96); background: #047857; }

    /* Setting Rows */
    .setting-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 0;
      border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .setting-title {
      font-size: 13px;
      font-weight: 600;
      color: #e2e8f0;
    }

    .setting-hint {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 2px;
    }
	
	.setting-hint strong {
      color: #38bdf8;
      font-weight: 700;
    }

    .setting-control {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
	  width: 140px; /* Locks the control width */
      min-width: 140px;
    }
	
    .setting-control input[type="range"] {
      width: 100%; /* Slider stretches across the full 140px */
      accent-color: #38bdf8;
      cursor: pointer;
    }

    .range-val {
      font-size: 12px;
      font-weight: 700;
      color: #38bdf8;
      min-width: 65px;
      text-align: right;
      font-variant-numeric: tabular-nums;
    }

    .setting-select {
      background: #0f172a;
      border: 1px solid #334155;
      color: #fff;
      font-size: 12px;
      font-weight: 600;
      padding: 8px 12px;
      border-radius: 8px;
      cursor: pointer;
    }

    .settings-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 18px;
      padding-top: 12px;
      border-top: 1px solid #334155;
    }
	
	/* Candy Log Pulse Animation */
    @keyframes countPop {
      0% { transform: scale(1); }
      40% { transform: scale(1.38); color: #38bdf8; text-shadow: 0 0 14px rgba(56, 189, 248, 0.7); }
      100% { transform: scale(1); }
    }

    .count-pop {
      animation: countPop 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    
    /* ===================================================
       MOBILE & SMALL SCREEN RESPONSIVE ENGINE (< 768px)
       =================================================== */
    @media (max-width: 768px) {
      body {
        padding: 8px;
        min-height: 100dvh; /* Modern iOS dynamic viewport */
        overflow-y: auto;   /* Allows micro-scroll so Safari bar collapses */
      }

      .app-viewport {
        max-width: 100%;
        gap: 10px;
      }

      /* Compact Mobile Header */
      header {
        padding: 8px 12px;
        min-height: 56px;
      }

      .title-group h1 {
        font-size: 15px;
      }

      .title-group p {
        font-size: 9px;
      }

      #btn-settings {
        font-size: 22px !important;
      }

      /* Button sizing for thumb touch */
      button {
        height: 36px;
        padding: 6px 10px;
        font-size: 12px;
      }

      #btn-main { min-width: 85px; }
      #btn-undo { min-width: 95px; }

      /* Compact Stage & Acrylic Cylinders */
      :root {
        --tube-width: 48px;
        --tube-height: 280px;
      }

      .stage {
        padding: 14px 8px 12px;
      }

      .y-axis-container {
        width: 32px;
        margin-right: 2px;
      }

      .tick-label {
        font-size: 9px;
      }

      .cylinder-container {
        border-radius: 24px 24px 12px 12px;
      }

      .color-name {
        font-size: 10px;
      }

      .count-val {
        font-size: 15px;
      }

      .pct-readout {
        font-size: 10px;
      }

      .arrow-ind {
        font-size: 8px;
        width: 8px;
      }

      /* Stack Analytics Cards on Phone */
      .dashboard {
        grid-template-columns: 1fr;
        gap: 10px;
      }

      .stat-card {
        padding: 12px 14px;
      }

      /* Legend Bar */
      .legend-bar {
        font-size: 11px;
        gap: 12px;
      }

      .legend-line {
        width: 16px;
      }

      /* Verdict Banner */
      .verdict-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
      }

      .ratio-pill {
        align-self: flex-start;
        font-size: 11px;
        padding: 6px 12px;
      }
    }
	
	