@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Zen+Kaku+Gothic+New:wght@500;700;900&display=swap');

:root {
    --bg-color: #050505;
    --text-color: #eee;
    --accent-cyan: #0ff;
    --accent-magenta: #f0f;
    --accent-red: #f00;
    --accent-green: #0f0;
    --glass-bg: rgba(20, 20, 20, 0.8);
    --border-color: rgba(0, 255, 255, 0.3);
    --modal-bg: rgba(10, 10, 10, 0.95);
}

* {
    box-sizing: border-box;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Share Tech Mono', 'Zen Kaku Gothic New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* Background Glitch Text */
.bg-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15vw;
    opacity: 0.05;
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
    font-weight: 900;
    color: var(--accent-cyan);
    animation: text-flicker 3s infinite;
}

@keyframes text-flicker {

    0%,
    19%,
    21%,
    23%,
    25%,
    54%,
    56%,
    100% {
        opacity: 0.05;
    }

    20%,
    24%,
    55% {
        opacity: 0.2;
        transform: translate(-50%, -50%) skewX(10deg);
    }
}

#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.4;
}

/* Main Container */
.container {
    width: 90%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    position: relative;
    z-index: 10;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--accent-cyan);
    text-shadow: 0 0 5px var(--accent-cyan);
    letter-spacing: 2px;
}

/* Timer Bar */
.timer-container {
    width: 100%;
    height: 15px;
    background: #111;
    border: 1px solid var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    transition: width 0.1s linear;
    box-shadow: 0 0 20px var(--accent-cyan);
}

.timer-bar.warning {
    background: var(--accent-red);
    box-shadow: 0 0 30px var(--accent-red);
    animation: pulse-red 0.2s infinite alternate;
}

@keyframes pulse-red {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.6;
    }
}

/* Constraints */
.constraints {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    gap: 10px;
}

.constraint-box {
    background: rgba(0, 20, 20, 0.6);
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.constraint-box:last-child {
    align-items: flex-end;
    text-align: right;
    border-color: rgba(255, 0, 255, 0.3);
}

.constraint-label {
    color: var(--accent-cyan);
    font-size: 0.7rem;
    margin-bottom: 2px;
    font-weight: bold;
}

.constraint-box:last-child .constraint-label {
    color: var(--accent-magenta);
}

/* Main Word Display */
.word-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--accent-cyan);
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 255, 255, 0.05);
    padding: 30px;
}

.word-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid transparent;
    background: linear-gradient(45deg, var(--accent-cyan), transparent, var(--accent-magenta)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
    pointer-events: none;
}

.word-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

@media (min-width: 600px) {
    .word-row {
        flex-direction: row;
        justify-content: center;
        gap: 30px;
    }
}

.word {
    font-size: 3rem;
    font-weight: 900;
    text-align: center;
    color: #fff;
    text-shadow: 2px 2px 0px rgba(255, 0, 255, 0.5), -2px -2px 0px rgba(0, 255, 255, 0.5);
    transition: transform 0.1s;
    position: relative;
}

.word.slot-active {
    filter: blur(2px);
    transform: scale(0.95);
    opacity: 0.8;
}

.conjunction {
    font-size: 1.2rem;
    color: #888;
    font-style: italic;
    background: #000;
    padding: 2px 10px;
    border: 1px solid #333;
}

/* AI Assist Message */
.assist-message {
    margin-top: 20px;
    min-height: 1.5em;
    font-size: 1.1rem;
    color: #ffaa00;
    /* Distinct orange/gold color */
    text-align: center;
    font-weight: bold;
    text-shadow: 0 0 5px #ffaa00;
    opacity: 0;
    transition: opacity 0.5s;
    width: 100%;
}

.assist-message.active {
    opacity: 1;
    animation: type-in 0.3s steps(20, end);
}

@keyframes type-in {
    from {
        clip-path: inset(0 100% 0 0);
    }

    to {
        clip-path: inset(0 0 0 0);
    }
}

/* Voice Input UI */
.voice-status {
    font-size: 0.8rem;
    color: #666;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    height: 1.2em;
    transition: color 0.3s;
}

.voice-status.listening {
    color: var(--accent-red);
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.live-transcript {
    width: 100%;
    margin-top: 5px;
    font-size: 0.9rem;
    color: var(--accent-cyan);
    min-height: 1.5em;
    text-align: center;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border: 1px solid #333;
}

/* Slider */
.slider-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 0 5px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 24px;
    width: 24px;
    background: #000;
    border: 2px solid var(--accent-cyan);
    cursor: pointer;
    margin-top: -10px;
    box-shadow: 0 0 10px var(--accent-cyan);
    transition: background 0.2s;
}

input[type=range]::-webkit-slider-thumb:hover {
    background: var(--accent-cyan);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: linear-gradient(90deg, var(--accent-magenta), var(--accent-cyan), var(--accent-green));
}

/* Assist Toggle */
.assist-toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    justify-content: center;
}

#assistToggle {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.toggle-label {
    color: var(--accent-cyan);
    font-weight: bold;
    cursor: pointer;
    text-shadow: 0 0 5px var(--accent-cyan);
}

/* Buttons */
.btn-group {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
}

.btn {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 15px 40px;
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    letter-spacing: 3px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.btn:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 30px var(--accent-cyan);
    text-shadow: none;
    transform: translateY(-2px);
}

.btn:hover::after {
    opacity: 0.2;
    transform: scale(1);
}

.btn:active {
    transform: scale(0.98);
    box-shadow: 0 0 10px var(--accent-cyan);
}

.btn-secondary {
    border: 1px solid #444;
    color: #888;
    font-size: 1rem;
    padding: 10px 20px;
    background: transparent;
    letter-spacing: 1px;
}

.btn-secondary:hover {
    border-color: #fff;
    color: #fff;
    background: #222;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* Help Button */
.btn-help {
    background: transparent;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 255, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 255, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 255, 0);
    }
}

.btn-help:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 15px var(--accent-cyan);
    animation: none;
}

/* Guide Button */
.btn-guide {
    background: transparent;
    border: 1px solid var(--accent-magenta);
    color: var(--accent-magenta);
    padding: 5px 15px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-shadow: 0 0 5px var(--accent-magenta);
}

.btn-guide:hover {
    background: var(--accent-magenta);
    color: #000;
    box-shadow: 0 0 15px var(--accent-magenta);
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    pointer-events: auto;
    display: none;
}

.tutorial-overlay.active {
    display: block;
}

.tutorial-spotlight {
    position: relative;
    z-index: 210 !important;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.8) !important;
    border: 2px solid var(--accent-green);
    border-radius: 5px;
    pointer-events: none;
    /* Let clicks pass through if needed, or block */
    transition: all 0.5s;
}

.tutorial-box {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(10, 20, 10, 0.95);
    border: 1px solid var(--accent-green);
    padding: 20px;
    z-index: 220;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.2);
    text-align: left;
}

.tutorial-box p {
    color: #eee;
    margin-top: 0;
    line-height: 1.5;
}

.tutorial-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.btn-tut {
    background: var(--accent-green);
    color: #000;
    border: none;
    padding: 5px 15px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
}

.btn-tut:hover {
    background: #fff;
}

.btn-tut.secondary {
    background: transparent;
    color: #888;
    border: 1px solid #444;
}

.btn-tut.secondary:hover {
    color: #fff;
    border-color: #fff;
}

.btn-tut.secondary:hover {
    color: #fff;
    border-color: #fff;
}

/* History UI */
.history-card {
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid #333;
    padding: 10px;
    border-left: 3px solid var(--accent-cyan);
}

.history-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 5px;
}

.history-keywords {
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
}

.history-meta {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 10px;
}

.history-log {
    background: #000;
    color: var(--accent-cyan);
    padding: 8px;
    font-size: 0.85rem;
    max-height: 80px;
    overflow-y: auto;
    border: 1px solid #222;
    white-space: pre-wrap;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    background: var(--modal-bg);
    border: 1px solid var(--accent-cyan);
    padding: 0;
    /* Layout handled by header/content */
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    /* Enable scrolling */
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 10px 20px;
    border-bottom: 1px solid #333;
    background: var(--modal-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-content {
    padding: 20px;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .container {
        width: 100%;
        padding: 10px;
    }

    .word {
        font-size: 2rem;
    }

    .modal {
        width: 95%;
        max-height: 85vh;
    }
}

.modal h2 {
    color: var(--accent-cyan);
    margin: 0;
    font-size: 1.4rem;
    border-bottom: none;
    /* Moved to header */
    padding-bottom: 0;
}

.modal p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: #ccc;
}

.modal h3 {
    color: var(--accent-magenta);
    border-left: 3px solid var(--accent-magenta);
    padding-left: 10px;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.modal-section {
    margin-bottom: 15px;
}

.modal ol {
    padding-left: 20px;
    color: #ccc;
    line-height: 1.6;
}

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

.modal li {
    margin-bottom: 8px;
}

.modal li::before {
    content: '> ';
    color: var(--accent-cyan);
}

.modal-close {
    position: static;
    /* Handled by flex in header */
    color: #666;
    cursor: pointer;
    font-size: 2rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}


/* Keyframe Animations */
.shake {
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.panic-mode {
    animation: panic-flash 0.5s infinite;
}

@keyframes panic-flash {
    0% {
        background-color: var(--bg-color);
        box-shadow: inset 0 0 0 0 transparent;
    }

    50% {
        background-color: #200;
        box-shadow: inset 0 0 50px var(--accent-red);
    }

    100% {
        background-color: var(--bg-color);
        box-shadow: inset 0 0 0 0 transparent;
    }
}

.glitch-anim {
    animation: glitch 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
    color: var(--accent-red);
}

@keyframes glitch {
    0% {
        transform: translate(0)
    }

    20% {
        transform: translate(-2px, 2px)
    }

    40% {
        transform: translate(-2px, -2px)
    }

    60% {
        transform: translate(2px, 2px)
    }

    80% {
        transform: translate(2px, -2px)
    }

    100% {
        transform: translate(0)
    }
}