* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #9333ea;
    --secondary-color: #667eea;
    --accent-color: #f59e0b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --vertex-a-color: #FF6B6B;
    --vertex-b-color: #4ECDC4;
    --vertex-c-color: #45B7D1;
    
    --bg-primary: rgba(255, 255, 255, 0.95);
    --bg-secondary: rgba(248, 250, 252, 0.9);
    --bg-dark: rgba(0, 0, 0, 0.9);
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #ffffff;
    
    --border-color: rgba(226, 232, 240, 0.8);
    --shadow-light: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 8px 32px rgba(0, 0, 0, 0.15);
    
    --radius-small: 6px;
    --radius-medium: 10px;
    --radius-large: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #9333ea 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Emergency Notice */
.emergency-notice {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger-color);
    color: white;
    padding: 20px 30px;
    border-radius: var(--radius-large);
    text-align: center;
    z-index: 10000;
    box-shadow: var(--shadow-medium);
    max-width: 90vw;
}

.emergency-notice h2 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

/* Header */
.app-header {
    background: var(--bg-dark);
    backdrop-filter: blur(20px);
    color: white;
    padding: 20px 0;
    margin-bottom: 20px;
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-medium);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

.status-badges {
    display: flex;
    gap: 20px;
    align-items: center;
}

.canvas-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: var(--radius-medium);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #64748b;
    transition: all 0.3s ease;
}

.status-dot.ready {
    background: var(--success-color);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.status-dot.error {
    background: var(--danger-color);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.points-counter {
    font-family: 'SF Mono', monospace;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    margin-bottom: 30px;
}

/* Canvas Section */
.canvas-section {
    background: var(--bg-primary);
    border-radius: var(--radius-large);
    padding: 25px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
}

.canvas-container {
    position: relative;
    text-align: center;
}

#fractal-canvas {
    border: 3px solid var(--primary-color);
    border-radius: var(--radius-medium);
    background: #0a0a0a;
    box-shadow: var(--shadow-light);
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    cursor: crosshair;
}

/* Click Mode Overlay */
.click-mode-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 107, 107, 0.1);
    border: 3px dashed #FF6B6B;
    border-radius: var(--radius-medium);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

.click-indicator {
    background: rgba(255, 107, 107, 0.9);
    color: white;
    padding: 15px 25px;
    border-radius: var(--radius-large);
    text-align: center;
    font-weight: 600;
    box-shadow: var(--shadow-medium);
}

.pulse-dot {
    font-size: 24px;
    display: inline-block;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.click-text {
    display: block;
    margin-top: 8px;
    font-size: 14px;
}

.blink {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.5; }
}

/* Interaction Help */
.interaction-help {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    border: 1px solid var(--border-color);
}

.help-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.help-icon {
    font-size: 1.2rem;
}

/* Triangle Info */
.triangle-info {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 15px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
}

.triangle-info h3 {
    margin-bottom: 12px;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.vertices-display {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.vertex-item {
    background: white;
    padding: 8px 12px;
    border-radius: var(--radius-small);
    text-align: center;
    font-family: 'SF Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.vertex-item.vertex-a {
    border-left: 4px solid var(--vertex-a-color);
}

.vertex-item.vertex-b {
    border-left: 4px solid var(--vertex-b-color);
}

.vertex-item.vertex-c {
    border-left: 4px solid var(--vertex-c-color);
}

.triangle-area {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Controls Sidebar */
.controls-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: fit-content;
}

.control-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-large);
    padding: 20px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
}

.control-panel h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

/* Vertex Controls */
.vertex-selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.vertex-button {
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-medium);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.vertex-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.vertex-button.selected {
    box-shadow: 0 0 0 3px #FFD700;
    transform: scale(1.05);
}

.vertex-button.selected::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FFD700;
    color: black;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.triangle-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.preset-button {
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    background: white;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.preset-button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.vertex-coordinates {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.coord-display {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.coord-display:last-child {
    margin-bottom: 0;
}

.vertex-label {
    font-weight: 600;
}

.vertex-label.vertex-a {
    color: var(--vertex-a-color);
}

.vertex-label.vertex-b {
    color: var(--vertex-b-color);
}

.vertex-label.vertex-c {
    color: var(--vertex-c-color);
}

.interaction-mode {
    text-align: center;
}

.mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-label {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Starting Point Controls */
.start-point-modes {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

.mode-button {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    background: white;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.mode-button.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.mode-button.active {
    background: #FF6B6B;
    border-color: #FF6B6B;
    color: white;
    animation: pulse-button 2s infinite;
}

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

.start-point-status {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.status-item:last-child {
    margin-bottom: 0;
}

.status-item.active {
    background: rgba(255, 107, 107, 0.1);
    padding: 8px;
    border-radius: var(--radius-small);
    border: 1px solid #FF6B6B;
}

.status-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.status-value {
    font-family: 'SF Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
}

.manual-coordinates h4 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.coord-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 80px;
    gap: 8px;
    align-items: end;
}

.coord-inputs label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.coord-inputs input {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-small);
    font-size: 0.8rem;
    margin-top: 4px;
}

.coord-inputs input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.apply-button {
    padding: 6px 10px;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-small);
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

.apply-button:hover {
    background: #7c3aed;
}

.quick-presets h4 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.quick-presets {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.quick-presets .preset-button {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.75rem;
}

/* Construction Options */
.construction-options {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

/* Step Controls */
.step-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.step-btn {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    background: white;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.step-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.step-btn.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    grid-column: 1 / -1;
}

.step-btn.primary:hover {
    background: #d97706;
}

/* Custom Steps */
.custom-steps {
    margin-bottom: 15px;
}

.custom-steps label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-small);
    font-size: 0.9rem;
}

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

.input-group button {
    padding: 8px 15px;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-small);
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.input-group button:hover {
    background: #7c3aed;
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-radius: var(--radius-medium);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.action-btn.success {
    background: var(--success-color);
    color: white;
}

.action-btn.success:hover:not(:disabled) {
    background: #16a34a;
    transform: translateY(-1px);
}

.action-btn.danger {
    background: var(--danger-color);
    color: white;
}

.action-btn.danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Generation Controls */
.generation-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.speed-control {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 12px;
    border: 1px solid var(--border-color);
}

.speed-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.speed-control input[type="range"] {
    width: 100%;
    margin-bottom: 8px;
}

.speed-control span {
    font-family: 'SF Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

/* Step Status */
.step-status {
    background: var(--bg-secondary);
    border-radius: var(--radius-medium);
    padding: 12px;
    border: 1px solid var(--border-color);
}

.status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.status-row:last-child {
    margin-bottom: 0;
}

.status-row span:first-child {
    color: var(--text-secondary);
    font-weight: 500;
}

.status-row span:last-child {
    font-family: 'SF Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
}

/* Analysis Grid */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.analysis-item {
    background: var(--bg-secondary);
    padding: 8px 10px;
    border-radius: var(--radius-small);
    border: 1px solid var(--border-color);
    text-align: center;
}

.analysis-item.full-width {
    grid-column: 1 / -1;
}

.analysis-item .label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.analysis-item .value {
    font-family: 'SF Mono', monospace;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.analysis-item .value.vertex-a {
    color: var(--vertex-a-color);
}

.analysis-item .value.vertex-b {
    color: var(--vertex-b-color);
}

.analysis-item .value.vertex-c {
    color: var(--vertex-c-color);
}

/* Entropy Bar */
.entropy-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin: 6px 0;
}

.entropy-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    transition: width 0.5s ease;
    border-radius: 3px;
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-small);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.option-item:hover {
    background: var(--bg-primary);
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.option-item input[type="checkbox"] {
    display: none;
}

.option-item input[type="checkbox"]:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.option-item input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 10px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Color Controls */
.color-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-controls label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.color-controls select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-small);
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.color-controls select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Performance Monitor */
.performance-monitor {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--bg-dark);
    color: white;
    padding: 10px 15px;
    border-radius: var(--radius-medium);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    display: flex;
    gap: 15px;
    z-index: 1000;
}

.perf-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.perf-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perf-value {
    font-family: 'SF Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-dark);
    color: white;
    padding: 20px;
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-medium);
    max-width: 80vw;
    max-height: 60vh;
    overflow: auto;
    z-index: 10000;
}

.debug-panel h4 {
    margin-bottom: 15px;
    color: var(--accent-color);
}

.debug-logs {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: var(--radius-medium);
    font-family: 'SF Mono', monospace;
    font-size: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.debug-logs div {
    margin-bottom: 4px;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-weight: 600;
}

/* Mobile Toggle */
.mobile-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-medium);
    display: none;
    z-index: 1001;
    transition: all 0.3s ease;
}

.mobile-toggle:hover {
    background: #7c3aed;
    transform: scale(1.1);
}

/* Emergency Display */
.emergency-display {
    padding: 40px;
    text-align: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-large);
    border: 3px dashed var(--danger-color);
}

.emergency-display h2 {
    color: var(--danger-color);
    margin-bottom: 20px;
}

.emergency-display pre {
    background: var(--bg-dark);
    color: var(--success-color);
    padding: 20px;
    border-radius: var(--radius-medium);
    font-size: 0.8rem;
    margin: 20px 0;
    overflow: auto;
}

/* Footer */
.app-footer {
    text-align: center;
    color: white;
    padding: 25px 0;
    margin-top: 30px;
    opacity: 0.9;
}

.app-footer a {
    color: #fbbf24;
    text-decoration: none;
    font-weight: 600;
}

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

/* Responsive Design */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr 360px;
    }
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .controls-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-top: 3px solid var(--primary-color);
        height: 300px;
        overflow-y: auto;
        z-index: 1000;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 15px;
    }
    
    .control-panel {
        flex: 1;
        min-width: 280px;
        margin: 0 10px 10px 0;
    }
    
    .canvas-section {
        margin-bottom: 320px;
    }
    
    .performance-monitor {
        bottom: 320px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .main-layout {
        margin-bottom: 20px;
    }
    
    .canvas-section {
        padding: 15px;
        margin-bottom: 0;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .controls-sidebar {
        position: fixed;
        bottom: -450px;
        left: 0;
        right: 0;
        height: 450px;
        background: var(--bg-primary);
        border-top: 3px solid var(--primary-color);
        box-shadow: var(--shadow-medium);
        transition: bottom 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    .performance-monitor {
        bottom: 80px;
        flex-direction: column;
        gap: 8px;
    }
    
    .vertex-selection-grid {
        grid-template-columns: 1fr;
    }
    
    .triangle-presets {
        grid-template-columns: 1fr;
    }
    
    .step-controls {
        grid-template-columns: 1fr;
    }
    
    .analysis-grid {
        grid-template-columns: 1fr;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .vertices-display {
        grid-template-columns: 1fr;
    }
    
    .interaction-help {
        flex-direction: column;
        gap: 10px;
    }
    
    .coord-inputs {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .emergency-notice {
        padding: 15px 20px;
        margin: 0 10px;
    }
    
    .canvas-section {
        padding: 10px;
    }
    
    .triangle-info {
        padding: 10px;
    }
    
    .control-panel {
        padding: 15px;
    }
    
    .performance-monitor {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .control-panel,
    .canvas-section,
    .triangle-info {
        border: 3px solid #000;
        background: rgba(255, 255, 255, 1);
    }
    
    #fractal-canvas {
        border: 3px solid #000;
    }
    
    .app-header {
        background: rgba(0, 0, 0, 1);
        border: 3px solid #fff;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: rgba(31, 41, 55, 0.95);
        --bg-secondary: rgba(55, 65, 81, 0.9);
        --text-primary: #f3f4f6;
        --text-secondary: #9ca3af;
        --border-color: rgba(75, 85, 99, 0.8);
    }
    
    .vertex-item,
    .analysis-item,
    .option-item,
    .step-status,
    .start-point-status,
    .vertex-coordinates,
    .construction-options {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
}

/* Print styles */
@media print {
    .controls-sidebar,
    .performance-monitor,
    .debug-panel,
    .mobile-toggle {
        display: none;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .canvas-section {
        margin-bottom: 0;
    }
}