:root {
    --blueprint-blue: #0a2463;
    --blueprint-light: #1e3a5f;
    --gold: #ffd700;
    --paper-white: #f8f9fa;
    --grid-blue: #1a3a6a;
}

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

body {
    font-family: 'JetBrains Mono', monospace;
    background: linear-gradient(135deg, #030810 0%, #0a2463 50%, #051530 100%);
    min-height: 100vh;
    color: var(--paper-white);
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: relative;
    background: linear-gradient(180deg, var(--blueprint-blue) 0%, var(--blueprint-light) 100%);
    padding: 2rem 1rem;
    text-align: center;
    border-bottom: 4px solid var(--gold);
    overflow: hidden;
}

.main-title {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: 900;
    letter-spacing: 0.1em;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.3), 0 0 30px rgba(255,215,0,0.3);
    color: var(--paper-white);
    position: relative;
    z-index: 1;
}

.subtitle {
    font-size: clamp(0.75rem, 2vw, 1rem);
    color: var(--gold);
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

/* Gear Animation */
.gear {
    color: var(--gold);
    animation: rotate 8s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Generator Section */
.generator-section {
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1rem;
}

.prompt-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(255,255,255,0.1);
    border: 2px solid var(--gold);
    border-radius: 8px;
    color: var(--paper-white);
    outline: none;
    transition: all 0.3s;
}

.prompt-input::placeholder {
    color: rgba(255,255,255,0.5);
}

.prompt-input:focus {
    background: rgba(255,255,255,0.15);
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.button-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.example-button, .archive-button {
    flex: 1;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    background: rgba(255,215,0,0.1);
    border: 1px solid var(--gold);
    border-radius: 6px;
    color: var(--gold);
    cursor: pointer;
    transition: all 0.3s;
}

.example-button:hover, .archive-button:hover {
    background: rgba(255,215,0,0.2);
}

.generate-button {
    width: 100%;
    padding: 1.25rem 2rem;
    font-family: 'Oswald', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: linear-gradient(180deg, var(--gold) 0%, #b8860b 100%);
    border: none;
    border-radius: 8px;
    color: var(--blueprint-blue);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(255,215,0,0.3);
}

.generate-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255,215,0,0.5);
}

.generate-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.generate-button.generating {
    animation: pulse 1s infinite;
}

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

.generating-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.drafting-animation {
    width: 20px;
    height: 3px;
    background: var(--blueprint-blue);
    animation: draft 0.5s infinite;
}

@keyframes draft {
    0%, 100% { width: 10px; }
    50% { width: 30px; }
}

/* Error Message */
.error-message {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid #dc2626;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 1rem;
}

/* Archive Section */
.archive-section {
    margin-bottom: 2rem;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 1rem;
}

.archive-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.25rem;
    color: var(--gold);
    margin-bottom: 1rem;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
}

.archive-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
}

.archive-item:hover {
    transform: scale(1.05);
    border-color: var(--gold);
}

.archive-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.archive-info {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.archive-item-title {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archive-roll {
    font-size: 0.8rem;
    font-weight: bold;
}

/* Blueprint Card */
.blueprint-card {
    background: linear-gradient(135deg, rgba(10, 36, 99, 0.9) 0%, rgba(30, 58, 95, 0.9) 100%);
    border: 3px solid var(--gold);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.blueprint-header {
    background: var(--gold);
    padding: 1rem;
    text-align: center;
}

.blueprint-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blueprint-blue);
    text-transform: uppercase;
}

.blueprint-image-container {
    position: relative;
    padding: 1rem;
    background: 
        repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(255,255,255,0.03) 19px, rgba(255,255,255,0.03) 20px),
        repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(255,255,255,0.03) 19px, rgba(255,255,255,0.03) 20px);
}

.blueprint-image {
    width: 100%;
    border-radius: 4px;
    display: block;
}

.coffee-stain {
    position: absolute;
    top: 20px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(139, 90, 43, 0.15) 50%, rgba(139, 90, 43, 0.1) 60%, transparent 70%);
    pointer-events: none;
}

.fold-mark {
    position: absolute;
    background: rgba(0,0,0,0.1);
    pointer-events: none;
}

.fold-mark-v {
    width: 1px;
    height: 100%;
    left: 50%;
    top: 0;
}

.fold-mark-h {
    width: 100%;
    height: 1px;
    top: 50%;
    left: 0;
}

/* Specs Panel */
.specs-panel {
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    margin: 0 1rem;
    border-radius: 8px;
    border: 1px dashed rgba(255,215,0,0.5);
}

.specs-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1rem;
    color: var(--gold);
    margin-bottom: 0.75rem;
}

.specs-grid {
    display: grid;
    gap: 0.5rem;
}

.spec-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.spec-label {
    font-weight: bold;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
}

.spec-value {
    color: var(--paper-white);
    font-size: 0.85rem;
}

/* Dice Section */
.dice-section {
    padding: 2rem 1rem;
    text-align: center;
}

.dice-title {
    font-family: 'Oswald', sans-serif;
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: 1.5rem;
}

/* Fate Gauge */
.fate-gauge {
    position: relative;
    width: 200px;
    height: 100px;
    margin: 0 auto 1.5rem;
}

.gauge-arc {
    position: absolute;
    width: 100%;
    height: 200%;
    border-radius: 100px 100px 0 0;
    overflow: hidden;
    background: linear-gradient(90deg, 
        #dc2626 0%, #dc2626 16.6%,
        #ea580c 16.6%, #ea580c 33.3%,
        #eab308 33.3%, #eab308 50%,
        #84cc16 50%, #84cc16 66.6%,
        #22c55e 66.6%, #22c55e 83.3%,
        #ffd700 83.3%, #ffd700 100%
    );
}

.gauge-needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 4px;
    height: 80px;
    background: linear-gradient(to top, var(--paper-white), var(--gold));
    transform-origin: bottom center;
    transition: transform 0.5s ease-out;
    border-radius: 2px;
    z-index: 2;
}

.gauge-center {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: var(--gold);
    border-radius: 50%;
    border: 3px solid var(--paper-white);
    z-index: 3;
}

.gauge-labels {
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gold);
    padding: 0 10px;
}

/* Dice Display */
.dice-container {
    width: 100px;
    height: 100px;
    margin: 0 auto 1.5rem;
    perspective: 600px;
}

.dice-3d {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s;
}

.dice-container.rolling .dice-3d {
    animation: diceRoll 0.1s linear infinite;
}

@keyframes diceRoll {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    25% { transform: rotateX(90deg) rotateY(45deg); }
    50% { transform: rotateX(180deg) rotateY(90deg); }
    75% { transform: rotateX(270deg) rotateY(135deg); }
    100% { transform: rotateX(360deg) rotateY(180deg); }
}

.dice-face {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #1e3a5f, #0a2463);
    border: 4px solid var(--gold);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        inset 0 0 20px rgba(255,215,0,0.2),
        0 10px 30px rgba(0,0,0,0.5);
}

.dice-number {
    font-family: 'Oswald', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
}

.roll-button {
    padding: 1rem 2rem;
    font-family: 'Oswald', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: linear-gradient(180deg, #8b0000 0%, #5c0000 100%);
    border: 2px solid var(--gold);
    border-radius: 8px;
    color: var(--paper-white);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.roll-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(139,0,0,0.5);
}

.roll-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.roll-button.rolling {
    animation: shake 0.1s linear infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-2deg); }
    75% { transform: translateX(5px) rotate(2deg); }
}

/* Outcome Panel */
.outcome-panel {
    margin: 1rem;
    border: 3px solid;
    border-radius: 12px;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.outcome-header {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.outcome-roll {
    font-size: 1rem;
    color: rgba(0,0,0,0.7);
}

.outcome-label {
    font-family: 'Oswald', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blueprint-blue);
}

.outcome-description {
    padding: 1rem;
    text-align: center;
    font-style: italic;
    line-height: 1.6;
}

.share-button {
    display: block;
    width: calc(100% - 2rem);
    margin: 0 1rem 1rem;
    padding: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    background: #1da1f2;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.share-button:hover {
    background: #0d8ecf;
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti-particle {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 10px;
    animation: fall 3s ease-out forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Footer */
.footer {
    background: rgba(0,0,0,0.5);
    padding: 1.5rem;
    text-align: center;
    border-top: 2px solid rgba(255,215,0,0.3);
}

.footer a {
    color: var(--gold);
    text-decoration: none;
}

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

.disclaimer {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    margin-top: 0.5rem;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .header {
        padding: 1.5rem 0.75rem;
    }
    
    .main-content {
        padding: 1rem 0.75rem;
    }
    
    .blueprint-title {
        font-size: 1.2rem;
    }
    
    .dice-container {
        width: 80px;
        height: 80px;
    }
    
    .dice-number {
        font-size: 2rem;
    }
    
    .fate-gauge {
        width: 160px;
        height: 80px;
    }
    
    .gauge-needle {
        height: 64px;
    }
}