/* CSS Variables for Light and Dark Themes */
:root {
    /* Light Theme Variables */
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: white;
    --text-color: #2c3e50;
    --text-color-light: #7f8c8d;
    --header-gradient-start: #3498db;
    --header-gradient-end: #2980b9;
    --header-text: white;
    --connection-info-bg: linear-gradient(145deg, #f8fafc, #e2e8f0);
    --connection-info-border: #3498db;
    --standard-selector-bg: linear-gradient(145deg, #ffffff, #f1f5f9);
    --standard-selector-border: #cbd5e1;
    --standard-label-color: #475569;
    --standard-label-hover-bg: #e0f2fe;
    --device-dropdown-bg: linear-gradient(145deg, #ffffff, #f8fafc);
    --device-dropdown-border: #cbd5e1;
    --pin-gradient-start: #64748b;
    --pin-gradient-end: #94a3b8;
    --score-panel-bg: linear-gradient(145deg, #f8fafc, #e2e8f0);
    --score-panel-border: #cbd5e1;
    --btn-primary-bg: linear-gradient(145deg, #3b82f6, #2563eb);
    --btn-primary-hover: linear-gradient(145deg, #2563eb, #1d4ed8);
    --btn-success-bg: linear-gradient(145deg, #10b981, #059669);
    --btn-success-hover: linear-gradient(145deg, #059669, #047857);
    --btn-warning-bg: linear-gradient(145deg, #f59e0b, #d97706);
    --btn-warning-hover: linear-gradient(145deg, #d97706, #b45309);
    --btn-danger-bg: linear-gradient(145deg, #ef4444, #dc2626);
    --btn-danger-hover: linear-gradient(145deg, #dc2626, #b91c1c);
    --shadow-color: rgba(0,0,0,0.1);
    --border-color: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --container-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-color-light: #cbd5e1;
    --header-gradient-start: #1e40af;
    --header-gradient-end: #1d4ed8;
    --header-text: white;
    --connection-info-bg: linear-gradient(145deg, #334155, #475569);
    --connection-info-border: #3b82f6;
    --standard-selector-bg: linear-gradient(145deg, #374151, #4b5563);
    --standard-selector-border: #6b7280;
    --standard-label-color: #f1f5f9;
    --standard-label-hover-bg: #1e40af;
    --device-dropdown-bg: linear-gradient(145deg, #374151, #4b5563);
    --device-dropdown-border: #6b7280;
    --pin-gradient-start: #64748b;
    --pin-gradient-end: #94a3b8;
    --score-panel-bg: linear-gradient(145deg, #334155, #475569);
    --score-panel-border: #6b7280;
    --btn-primary-bg: linear-gradient(145deg, #3b82f6, #2563eb);
    --btn-primary-hover: linear-gradient(145deg, #2563eb, #1d4ed8);
    --btn-success-bg: linear-gradient(145deg, #10b981, #059669);
    --btn-success-hover: linear-gradient(145deg, #059669, #047857);
    --btn-warning-bg: linear-gradient(145deg, #f59e0b, #d97706);
    --btn-warning-hover: linear-gradient(145deg, #d97706, #b45309);
    --btn-danger-bg: linear-gradient(145deg, #ef4444, #dc2626);
    --btn-danger-hover: linear-gradient(145deg, #dc2626, #b91c1c);
    --shadow-color: rgba(0,0,0,0.4);
    --border-color: #475569;
    --glass-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(148, 163, 184, 0.2);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    color: var(--text-color);
    position: relative;
}

/* Enhanced Background with animated particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* RTL Support for Persian */
body.rtl {
    direction: rtl;
    font-family: 'Tahoma', 'Arial', sans-serif;
}

body.rtl .device-selection {
    flex-direction: row-reverse;
}

body.rtl .controls {
    flex-direction: row-reverse;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.4) 50%, 
        transparent
    );
    z-index: 1;
}

.header {
    background: linear-gradient(135deg, var(--header-gradient-start), var(--header-gradient-end));
    color: var(--header-text);
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: rotate 20s linear infinite;
    pointer-events: none;
}

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

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.02em;
    position: relative;
    z-index: 2;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
    position: relative;
    z-index: 2;
}

.header nav {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 3;
}

.game-area {
    padding: 40px;
    background: var(--container-bg);
    position: relative;
}

.device-selection {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.device-selector {
    text-align: center;
    flex: 1;
    min-width: 150px;
}

.device-selector h3 {
    margin-bottom: 10px;
    color: var(--text-color);
    font-size: 16px;
}

.device-dropdown {
    padding: 12px 16px;
    border: 2px solid var(--device-dropdown-border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--device-dropdown-bg);
    color: var(--text-color);
    cursor: pointer;
    min-width: 120px;
    width: 100%;
    max-width: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.device-dropdown:focus {
    outline: none;
    border-color: var(--header-gradient-start);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.connection-info {
    text-align: center;
    padding: 20px;
    background: var(--connection-info-bg);
    border-radius: 16px;
    margin: 25px 0;
    border: 2px solid var(--connection-info-border);
    color: var(--text-color);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.connection-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--connection-info-border), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.standard-selector {
    margin-top: 15px;
    padding: 15px;
    background: var(--standard-selector-bg);
    border-radius: 12px;
    border: 1px solid var(--standard-selector-border);
    text-align: center;
}

.standard-selector strong {
    color: var(--text-color);
    font-size: 14px;
    margin-bottom: 10px;
    display: block;
}

.standard-options {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.standard-label {
    margin: 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid var(--standard-selector-border);
    background: rgba(255, 255, 255, 0.05);
    min-width: 80px;
    justify-content: center;
}

.standard-label:hover {
    color: var(--connection-info-border);
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--connection-info-border);
    transform: translateY(-1px);
}

.standard-label input[type="radio"] {
    margin-right: 8px;
    margin-left: 0;
    transform: scale(1.2);
    accent-color: var(--connection-info-border);
}

.standard-label input[type="radio"]:checked {
    accent-color: var(--connection-info-border);
}

.standard-label:has(input[type="radio"]:checked),
.standard-label.selected {
    color: white;
    background: var(--connection-info-border);
    border-color: var(--connection-info-border);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.standard-label span {
    font-weight: 600;
    font-size: 13px;
}

/* Fallback for browsers that don't support :has() */
@supports not selector(:has(*)) {
    .standard-label input[type="radio"]:checked {
        accent-color: white;
    }
}

.standard-selector input[type="radio"] {
    margin-left: 5px;
    margin-right: 5px;
    transform: scale(1.2);
}

/* RTL Support for Persian */
body.rtl .standard-label {
    flex-direction: row-reverse;
}

body.rtl .standard-label input[type="radio"] {
    margin-right: 0;
    margin-left: 8px;
}

.cable-workspace {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 40px 0;
    flex-wrap: wrap;
    gap: 30px;
}

.rj45-socket {
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    border-radius: 24px;
    padding: 35px;
    box-shadow: 
        inset 0 4px 8px rgba(0,0,0,0.4),
        0 12px 24px rgba(0,0,0,0.2),
        0 0 40px rgba(0,0,0,0.1);
    position: relative;
    min-width: 300px;
    max-width: 100%;
    box-sizing: border-box;
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rj45-socket::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.1) 0%,
        transparent 25%,
        transparent 75%,
        rgba(255, 255, 255, 0.1) 100%
    );
    border-radius: 24px;
    z-index: -1;
}

.socket-label {
    color: #fff;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 16px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.socket-body {
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    border-radius: 16px;
    padding: 25px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.socket-opening {
    background: linear-gradient(145deg, #000, #1a1a1a);
    height: 120px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    border: 3px solid #555;
    box-shadow: 
        inset 0 4px 8px rgba(0, 0, 0, 0.5),
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.pin-container {
    display: flex;
    height: 100%;
    align-items: flex-end;
    padding: 25px;
    gap: 3px;
    overflow: hidden;
    box-sizing: border-box;
}

.pin {
    flex: 1;
    height: 90px;
    background: linear-gradient(to top, var(--pin-gradient-start), var(--pin-gradient-end));
    border-radius: 6px 6px 0 0;
    position: relative;
    border: 2px solid #666;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    min-width: 25px;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.pin::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent
    );
    border-radius: 6px 6px 0 0;
}

.pin:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    animation: pin-glow 1s infinite alternate;
}

@keyframes pin-glow {
    0% { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2); }
    100% { box-shadow: 0 6px 12px rgba(59, 130, 246, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.3); }
}

.pin.drag-over {
    border-color: #3b82f6;
    background: linear-gradient(to top, #3b82f6, #60a5fa);
    animation: pin-ready 0.5s infinite alternate;
}

@keyframes pin-ready {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.pin.has-wire {
    background: var(--wire-color);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    border-color: #333;
}

.pin-number {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #888;
    font-weight: bold;
}

.cable-connection {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #666;
}

.cable-line {
    width: 250px;
    height: 10px;
    background: linear-gradient(90deg, #666, #888, #666);
    border-radius: 5px;
    position: relative;
    margin: 15px 0;
}

.cable-line::before,
.cable-line::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 12px;
    background: #555;
    border-radius: 6px;
    top: -2px;
}

.cable-line::before {
    left: -10px;
}

.cable-line::after {
    right: -10px;
}

.wire-palette {
    background: var(--score-panel-bg);
    border-radius: 20px;
    padding: 25px;
    margin: 30px 0;
    border: 1px solid var(--score-panel-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.wire-palette::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--connection-info-border), 
        transparent
    );
}

.wire-palette h3 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.wires-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    justify-items: center;
    max-width: 100%;
}

.wire-spool {
    width: 85px;
    height: 85px;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 6px 20px rgba(0,0,0,0.15),
        inset 0 2px 4px rgba(255,255,255,0.2),
        0 0 0 3px rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    position: relative;
    user-select: none;
}

.wire-spool::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.4), 
        rgba(255, 255, 255, 0.1)
    );
    pointer-events: none;
}

.wire-spool:hover {
    transform: translateY(-3px) scale(1.08);
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.25),
        inset 0 2px 4px rgba(255,255,255,0.3),
        0 0 0 3px rgba(255,255,255,0.2);
}

.wire-spool:active {
    cursor: grabbing;
    transform: translateY(-1px) scale(1.02);
}

.wire-spool.dragging {
    opacity: 0.7;
    transform: scale(1.1);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
}

/* رنگ‌های سیم‌ها */
.wire-white-orange { 
    background: linear-gradient(135deg, #fff 0%, #fff 50%, #ff8c00 50%, #ff8c00 100%);
    color: #333;
}
.wire-orange { background: linear-gradient(135deg, #ff8c00, #ff6600); }
.wire-white-green { 
    background: linear-gradient(135deg, #fff 0%, #fff 50%, #32cd32 50%, #32cd32 100%);
    color: #333;
}
.wire-blue { background: linear-gradient(135deg, #0066ff, #0044cc); }
.wire-white-blue { 
    background: linear-gradient(135deg, #fff 0%, #fff 50%, #0066ff 50%, #0066ff 100%);
    color: #333;
}
.wire-green { background: linear-gradient(135deg, #32cd32, #228b22); }
.wire-white-brown { 
    background: linear-gradient(135deg, #fff 0%, #fff 50%, #8b4513 50%, #8b4513 100%);
    color: #333;
}
.wire-brown { background: linear-gradient(135deg, #8b4513, #654321); }

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 12px rgba(0,0,0,0.1),
        inset 0 1px 2px rgba(255,255,255,0.2);
    min-width: 120px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 8px 20px rgba(0,0,0,0.15),
        inset 0 1px 2px rgba(255,255,255,0.3);
    animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
    0% { box-shadow: 0 8px 20px rgba(0,0,0,0.15), inset 0 1px 2px rgba(255,255,255,0.3); }
    100% { box-shadow: 0 12px 30px rgba(0,0,0,0.2), inset 0 2px 4px rgba(255,255,255,0.4); }
}

.btn:active {
    transform: translateY(-1px);
    animation: none;
}

.btn-primary {
    background: var(--btn-primary-bg);
    color: white;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
}

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

.btn-success:hover {
    background: var(--btn-success-hover);
}

.btn-warning {
    background: var(--btn-warning-bg);
    color: white;
}

.btn-warning:hover {
    background: var(--btn-warning-hover);
}

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

.btn-danger:hover {
    background: var(--btn-danger-hover);
}

.score-panel {
    display: flex;
    justify-content: space-around;
    background: var(--score-panel-bg);
    border-radius: 16px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--score-panel-border);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.score-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
}

.score-item {
    text-align: center;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.score-item:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.05);
}

.score-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        var(--btn-primary-bg), 
        var(--btn-success-bg), 
        var(--btn-warning-bg)
    );
}

/* Timer Styles */
.timer-panel {
    text-align: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 20px;
    padding: 20px;
    margin: 25px 0;
    box-shadow: 
        0 10px 25px rgba(99, 102, 241, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.timer-panel::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

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

.timer-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timer-label {
    font-size: 14px;
    opacity: 0.9;
    position: relative;
    z-index: 2;
    font-weight: 500;
}

/* Difficulty Selector */
.difficulty-selector {
    text-align: center;
    margin: 25px 0;
    padding: 25px;
    background: var(--connection-info-bg);
    border-radius: 20px;
    border: 1px solid var(--connection-info-border);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.difficulty-selector::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        #10b981, 
        #f59e0b, 
        #ef4444
    );
}

.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.current-level-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 8px 16px;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.level-icon {
    font-size: 16px;
    animation: pulse 2s infinite;
}

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

.difficulty-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.difficulty-btn:hover::before {
    left: 100%;
}

.difficulty-btn.easy {
    background: var(--btn-success-bg);
    color: white;
}

.difficulty-btn.medium {
    background: var(--btn-warning-bg);
    color: white;
}

.difficulty-btn.hard {
    background: var(--btn-danger-bg);
    color: white;
}

.difficulty-btn.active {
    transform: scale(1.05);
    box-shadow: 
        0 8px 20px rgba(59, 130, 246, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    position: relative;
}

.difficulty-btn.active::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #10b981;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.difficulty-btn:hover {
    transform: translateY(-2px);
}

/* Language Toggle */
.language-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    font-weight: 500;
    z-index: 3;
}

.language-toggle:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Sound Effects Toggle */
.sound-toggle {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    font-weight: 500;
}

.sound-toggle:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Theme Toggle */
.theme-toggle {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 8px 16px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    font-weight: 500;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Animation for correct wire placement */
@keyframes wireSuccess {
    0% { transform: scale(1); }
    25% { transform: scale(1.15); box-shadow: 0 0 25px #10b981; }
    50% { transform: scale(1.3); box-shadow: 0 0 35px #10b981; }
    75% { transform: scale(1.15); box-shadow: 0 0 25px #10b981; }
    100% { transform: scale(1); }
}

.pin.wire-success {
    animation: wireSuccess 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced floating animation for wire selection */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

.wire-spool.selected {
    border: 3px solid #fbbf24;
    box-shadow: 
        0 10px 30px rgba(0,0,0,0.3),
        0 0 30px rgba(251, 191, 36, 0.8),
        inset 0 2px 4px rgba(255,255,255,0.3);
    transform: scale(1.1);
    animation: float 2s ease-in-out infinite;
}

/* Enhanced drag over effect */
.pin-drop-zone.drag-over {
    background: linear-gradient(to top, #10b981, #34d399) !important;
    box-shadow: 
        0 0 20px rgba(16, 185, 129, 0.8),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    border-color: #10b981 !important;
    transform: scale(1.08);
    animation: pulse 1s ease-in-out infinite alternate;
}

/* Enhanced wire drag animation */
.wire-spool.dragging {
    opacity: 0.8;
    transform: scale(1.15) rotate(5deg);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
    box-shadow: 
        0 15px 35px rgba(0,0,0,0.4),
        0 0 30px rgba(255, 255, 255, 0.3);
}

/* Smooth loading animation for containers */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: slideInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Breathing effect for active elements */
@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.difficulty-btn.active {
    animation: breathe 3s ease-in-out infinite;
}

/* Glow effect for important UI elements */
@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.8); }
}

.timer-panel {
    animation: glow 3s ease-in-out infinite;
}

/* High Score Display */
.high-score {
    text-align: center;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1f2937;
    border-radius: 16px;
    padding: 20px;
    margin: 25px 0;
    font-weight: 600;
    box-shadow: 
        0 10px 25px rgba(251, 191, 36, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.high-score::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
    animation: shine 4s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { transform: scale(0.8) rotate(0deg); opacity: 0.5; }
    50% { transform: scale(1.2) rotate(180deg); opacity: 1; }
}

/* Progress Bar */
.progress-container {
    background: rgba(226, 232, 240, 0.5);
    border-radius: 12px;
    overflow: hidden;
    margin: 25px 0;
    height: 24px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 12px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 
        0 2px 4px rgba(16, 185, 129, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%
    );
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: 600;
    font-size: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.score-item {
    text-align: center;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--header-gradient-start);
}

.score-label {
    font-size: 12px;
    color: var(--text-color-light);
    margin-top: 5px;
}

.message {
    text-align: center;
    padding: 20px;
    border-radius: 16px;
    margin: 25px 0;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    animation: slideInMessage 0.5s ease forwards;
}

@keyframes slideInMessage {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    transition: left 0.5s ease;
}

.message.success {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #047857;
    border: 1px solid #10b981;
}

.message.success::before {
    background: #10b981;
}

.message.error {
    background: linear-gradient(135deg, #fee2e2, #fca5a5);
    color: #991b1b;
    border: 1px solid #ef4444;
}

.message.error::before {
    background: #ef4444;
}

.message.info {
    background: linear-gradient(135deg, #dbeafe, #93c5fd);
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.message.info::before {
    background: #3b82f6;
}

.message:hover::before {
    left: 0;
}

.pin-drop-zone {
    position: relative;
}

.wire-spool.selected {
    border: 4px solid #FFD700;
    box-shadow: 
        0 6px 12px rgba(0,0,0,0.3),
        0 0 20px rgba(255, 215, 0, 0.6);
    transform: scale(1.1);
}

.pin-drop-zone.drag-over {
    background: linear-gradient(to top, #4CAF50, #66bb6a) !important;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.8);
    border-color: #4CAF50 !important;
    transform: scale(1.05);
}

.pin.has-wire {
    background: var(--wire-color);
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    border-color: #333;
}

/* Very Small Mobile Devices */
@media (max-width: 360px) {
    .container {
        border-radius: 5px;
    }
    
    .header {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .header p {
        font-size: 11px;
    }
    
    .game-area {
        padding: 10px;
    }
    
    .rj45-socket {
        padding: 10px;
    }
    
    .socket-opening {
        height: 70px;
    }
    
    .pin-container {
        padding: 10px 5px;
        gap: 1px;
    }
    
    .pin {
        height: 50px;
        min-width: 12px;
    }
    
    .pin-number {
        bottom: -18px;
        font-size: 9px;
    }
    
    .wire-spool {
        width: 50px;
        height: 50px;
        font-size: 8px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 11px;
        min-width: 80px;
    }
    
    .cable-line {
        width: 100px;
        height: 6px;
    }
    
    .wire-palette {
        padding: 10px;
        margin: 15px 0;
    }
    
    .wires-container {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 8px;
    }
}

/* Enhanced responsive design */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .container {
        border-radius: 16px;
        margin: 0;
    }
    
    .header {
        padding: 20px 15px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    .language-toggle,
    .sound-toggle,
    .theme-toggle {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .language-toggle {
        top: 15px;
        left: 15px;
    }
    
    .header nav {
        top: 15px;
        right: 15px;
        gap: 8px;
    }
    
    .game-area {
        padding: 20px;
    }
    
    .device-selection {
        flex-direction: column;
        gap: 15px;
    }
    
    .device-dropdown {
        min-width: 100%;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .cable-workspace {
        flex-direction: column;
        gap: 20px;
        margin: 25px 0;
    }
    
    .rj45-socket {
        min-width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }
    
    .socket-opening {
        height: 90px;
    }
    
    .pin-container {
        padding: 15px 12px;
        gap: 3px;
    }
    
    .pin {
        height: 70px;
        min-width: 18px;
        border-radius: 4px 4px 0 0;
    }
    
    .pin-number {
        bottom: -22px;
        font-size: 11px;
    }
    
    .cable-line {
        width: 140px;
        height: 8px;
        margin: 12px 0;
    }
    
    .wire-palette {
        padding: 20px;
        margin: 25px 0;
    }
    
    .wire-palette h3 {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }
    
    .wires-container {
        gap: 12px;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    }
    
    .wire-spool {
        width: 70px;
        height: 70px;
        font-size: 10px;
    }
    
    .controls {
        gap: 12px;
        margin: 25px 0;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 13px;
        flex: 1;
        min-width: 0;
    }
    
    .difficulty-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .difficulty-btn {
        width: 100%;
        padding: 14px;
        font-size: 14px;
    }
    
    .timer-value {
        font-size: 1.75rem;
    }
    
    .score-panel {
        flex-direction: column;
        gap: 15px;
        padding: 20px;
    }
    
    .score-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .score-value {
        font-size: 1.25rem;
    }
    
    .score-label {
        font-size: 0.9rem;
        margin: 0;
    }
}

/* Tablet Responsive */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        margin: 10px;
    }
    
    .header {
        padding: 18px;
    }
    
    .game-area {
        padding: 20px;
    }
    
    .device-selection {
        flex-direction: column;
        gap: 15px;
    }
    
    .cable-workspace {
        flex-direction: column;
        gap: 20px;
    }
    
    .rj45-socket {
        min-width: 280px;
        padding: 20px;
    }
    
    .socket-opening {
        height: 100px;
    }
    
    .pin {
        height: 75px;
        min-width: 18px;
    }
    
    .wire-spool {
        width: 70px;
        height: 70px;
        font-size: 10px;
    }
    
    .cable-line {
        width: 200px;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .difficulty-buttons {
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .difficulty-btn {
        flex: 1;
        min-width: 140px;
    }
}

/* Large Tablet and Small Desktop */
@media (min-width: 769px) and (max-width: 1024px) {
    .cable-workspace {
        gap: 25px;
    }
    
    .wire-spool {
        width: 75px;
        height: 75px;
        font-size: 11px;
    }
    
    .rj45-socket {
        min-width: 320px;
    }
}

/* Enhanced accessibility and modern features */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced focus indicators for keyboard navigation */
.pin:focus,
.btn:focus,
.device-dropdown:focus,
.language-toggle:focus,
.sound-toggle:focus,
.difficulty-btn:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
    box-shadow: 
        0 0 0 2px #ffffff, 
        0 0 0 5px #3b82f6,
        0 4px 12px rgba(59, 130, 246, 0.3);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pin {
        border: 3px solid #000;
    }
    
    .btn {
        border: 2px solid #000;
        font-weight: 700;
    }
    
    .wire-spool {
        border: 3px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .container::before,
    .header::before,
    .timer-panel::before,
    .high-score::before,
    .progress-bar::after {
        animation: none !important;
    }
}

/* Keyboard navigation for pins */
.pin[tabindex="0"]:hover,
.pin[tabindex="0"]:focus {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 
        0 0 15px rgba(59, 130, 246, 0.6),
        0 4px 8px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

/* Print styles */
@media print {
    .header nav,
    .controls,
    .wire-palette,
    .timer-panel {
        display: none;
    }
    
    .container {
        box-shadow: none;
        background: white;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* Dark mode improvements */
[data-theme="dark"] .score-item {
    background: rgba(51, 65, 85, 0.8) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

[data-theme="dark"] .loading-screen {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* Enhanced glass morphism effects */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

/* Scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-gradient-start);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--header-gradient-start), var(--header-gradient-end));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--header-gradient-end), var(--header-gradient-start));
}

/* Selection styling */
::selection {
    background: var(--header-gradient-start);
    color: white;
}

::-moz-selection {
    background: var(--header-gradient-start);
    color: white;
}

/* Button accessibility */
.language-toggle,
.sound-toggle,
.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    margin: 0 5px;
    transition: all 0.3s ease;
}

.language-toggle:hover,
.sound-toggle:hover,
.theme-toggle:hover,
.language-toggle:focus,
.sound-toggle:focus,
.theme-toggle:focus {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ARIA live region for announcements */
.sr-live {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Better contrast for text */
.score-label,
.timer-label {
    font-weight: 600;
    color: var(--text-color);
}

/* Update text colors for dark mode */
.difficulty-selector h3,
.wire-palette h3,
.device-selector h3,
h1, h2, h3, h4, h5, h6 {
    color: var(--text-color);
}

.cable-connection div {
    color: var(--text-color-light);
}

.github-link p {
    color: var(--text-color-light) !important;
}

.github-link a {
    color: var(--header-gradient-start) !important;
}

/* Improved button states */
.difficulty-btn[aria-checked="true"] {
    background: #007bff;
    color: white;
    font-weight: bold;
}

/* Enhanced UI - Tooltips */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    animation: tooltip-show 0.3s ease forwards;
    margin-bottom: 5px;
}

[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    animation: tooltip-show 0.3s ease forwards;
}

@keyframes tooltip-show {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}