@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: #000;
    color: #00ff00;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 800px;
    background: #000;
    border: 6px solid #00ff00;
    box-shadow: 12px 12px 0px #ff0080, 24px 24px 0px #ffff00;
    padding: 40px;
    position: relative;
}

.container::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: linear-gradient(45deg, #ff0080, #00ff00, #ffff00);
    z-index: -1;
    border-radius: 0;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 4px 4px 0px #ff0080;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.mode-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    gap: 0;
}

.toggle-btn {
    background: #333;
    color: #aaa;
    border: 4px solid #333;
    padding: 12px 20px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.1s ease;
    flex: 1;
    max-width: 200px;
}

.toggle-btn.active {
    background: #ff0080;
    color: #000;
    border-color: #ff0080;
    box-shadow: 0 0 20px #ff0080;
    font-weight: 800;
    position: relative;
}

.toggle-btn.active::before {
    content: '▶ ';
    font-size: 0.8em;
}

.toggle-btn:first-child {
    border-right: none;
}

.toggle-btn:hover:not(.active) {
    background: #555;
    border-color: #555;
    color: #fff;
}

.toggle-btn:focus {
    outline: 4px solid #ffff00;
    outline-offset: 2px;
}

.toggle-btn:focus:not(:focus-visible) {
    outline: none;
}

.toggle-btn:focus-visible {
    outline: 4px solid #ffff00;
    outline-offset: 2px;
}

.input-section {
    margin-bottom: 30px;
}

label,
.output-label {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    color: #ffff00;
}

textarea {
    width: 100%;
    min-height: 120px;
    background: #000;
    border: 4px solid #00ff00;
    color: #00ff00;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    padding: 15px;
    resize: vertical;
    outline: none;
}

textarea:focus {
    border-color: #ff0080;
    box-shadow: 0 0 20px #ff0080;
}

.encode-mode textarea {
    text-transform: uppercase;
}

.controls {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

button {
    background: #ff0080;
    color: #000;
    border: none;
    padding: 15px 30px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    cursor: pointer;
    border: 4px solid #ff0080;
    box-shadow: 6px 6px 0px #000;
    transition: all 0.1s ease;
}

button:hover {
    background: #ffff00;
    border-color: #ffff00;
    transform: translate(2px, 2px);
    box-shadow: 4px 4px 0px #000;
}

button:active {
    transform: translate(6px, 6px);
    box-shadow: 0px 0px 0px #000;
}

button:disabled {
    background: #333;
    color: #aaa;
    border-color: #333;
    cursor: not-allowed;
    transform: none;
    box-shadow: 6px 6px 0px #000;
}

button:focus {
    outline: 4px solid #ffff00;
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

button:focus-visible {
    outline: 4px solid #ffff00;
    outline-offset: 2px;
}

.output-section {
    margin-bottom: 30px;
}

.message-display {
    background: #111;
    border: 4px solid #ffff00;
    padding: 20px;
    min-height: 80px;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 3px;
    line-height: 1.8;
}

.letter {
    display: inline-block;
    padding: 2px 4px;
    margin: 2px;
    border-radius: 0;
    transition: all 0.3s ease;
}

.letter.active {
    background: #ff0080;
    color: #000;
    transform: scale(1.2);
    box-shadow: 0 0 20px #ff0080;
    border: 3px solid #ffff00;
    font-weight: 800;
}

.morse-display {
    background: #111;
    border: 4px solid #00ff00;
    padding: 20px;
    min-height: 80px;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #00ff00;
}

.status {
    background: #111;
    border: 4px solid #ff0080;
    padding: 15px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #ff0080;
    text-transform: uppercase;
}

.playing {
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.speed-control input {
    background: #000;
    border: 4px solid #ffff00;
    color: #ffff00;
    padding: 8px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    width: 80px;
    text-align: center;
}

.speed-control input:focus {
    outline: 4px solid #ff0080;
    outline-offset: 2px;
    box-shadow: 0 0 20px #ff0080;
}

.decode-mode .controls {
    justify-content: center;
}

.decode-mode .speed-control {
    display: none;
}

.morse-help {
    background: #111;
    border: 4px solid #ffff00;
    padding: 15px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #ffff00;
    display: none;
}

.decode-mode .morse-help {
    display: block;
}
h2 {
    text-align: center;
    color: #00ff00;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}
.date-time {
    font-size: 0.875rem;
    text-align: center;
    margin-bottom:10px;
}

/* Respect user's motion preferences for accessibility */
@media (prefers-reduced-motion: reduce) {
    .playing {
        animation: none;
        opacity: 0.7;
    }

    .toggle-btn,
    button,
    .letter,
    textarea {
        transition: none;
    }

    button:hover,
    button:active {
        transform: none;
    }
}