:root {
    --bg-color: #0f0f11;
    --text-color: #e2e2e2;
    --accent-color: #6c757d;
    --card-bg: #1a1a1d;
    --border-color: #2a2a2d;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: "Georgia", "Times New Roman", serif;
}

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

body, html {
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    overflow: hidden; /* Prevent scrolling for app-like feel */
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    margin-bottom: 1.5rem;
    text-align: center;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.05em;
    margin-bottom: 0.2rem;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

main {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1.5rem;
}

/* Input Section */
.input-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 150px;
}

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

textarea {
    flex: 1;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-color);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--text-color);
}

textarea::placeholder {
    color: var(--accent-color);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
}

.download-container {
    display: flex;
    justify-content: center;
    margin-top: -0.5rem;
}

.tertiary-btn {
    background-color: transparent;
    color: var(--accent-color);
    border: 1px dashed var(--border-color);
    border-radius: 15px;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease;
}

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

button {
    background-color: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 25px;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.1s ease, background-color 0.3s ease;
    will-change: transform;
}

button:active:not(:disabled) {
    transform: scale(0.96);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

button:hover:not(:disabled) .btn-icon {
    transform: translateX(4px);
}

.secondary-btn {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    margin-left: 1rem;
}

.secondary-btn:hover:not(:disabled) {
    border-color: var(--text-color);
}

/* Word Popup */
#word-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

#word-popup:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.popup-content {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

#close-popup {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    line-height: 1;
}

.popup-content h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-family: var(--font-serif);
}

#popup-strategy-section {
    text-align: center;
}

#popup-strategy-text {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-style: italic;
    color: #fff;
    margin-bottom: 0.5rem;
}

#popup-strategy-author {
    font-size: 0.8rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Output Section */
.output-section {
    flex: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 200px;
}

#strategy-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#strategy-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#strategy-card.card-hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

#strategy-text {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    line-height: 1.4;
    color: #fff;
    font-style: italic;
}

#strategy-author {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

footer {
    text-align: center;
    padding-top: 1rem;
    font-size: 0.75rem;
    color: var(--accent-color);
    letter-spacing: 0.05em;
}

/* Status dots for thinking effect */
.dots {
    display: inline-block;
    width: 1.5em;
    text-align: left;
}