/* Serenity - Zen Garden Discord Activity */
/* Serene Interactive, Global */

:root {
    --sand-light: #e6ddd4;
    --sand-dark: #d4c8b8;
    --sand-shadow: #c4b5a5;
    --stone-color: #6b6b6b;
    --stone-light: #8a8a8a;
    --plant-green: #4a7c59;
    --bamboo-green: #7cb342;
    --accent: #9c8aa5;
    --text: #4a4a4a;
    --text-light: #7a7a7a;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--sand-light) 0%, var(--sand-dark) 100%);
    color: var(--text);
    -webkit-overflow-scrolling: none;
    overscroll-behavior: none;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--sand-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-text {
    font-size: 1.5rem;
    color: var(--text-light);
    margin-bottom: 2rem;
    letter-spacing: 2px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--sand-shadow);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Main UI */
.ui-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    box-sizing: border-box;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.header h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 3px;
    color: var(--text);
    margin: 0;
    text-align: center;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-light);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 500;
    text-align: center;
    margin: 0;
}

.logo-icon {
    width: 40px;
    height: 40px;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--panel-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border: 2px solid transparent;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 60px;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
}

.tool-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.tool-btn:active {
    transform: scale(0.95);
}

.tool-btn.active {
    border-color: var(--accent);
    background: rgba(156, 138, 165, 0.1);
}

.tool-btn span {
    font-size: 1.5rem;
    line-height: 1;
}

.tool-btn small {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.divider {
    width: 1px;
    background: var(--sand-shadow);
    margin: 0 0.5rem;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 
        inset 0 2px 10px rgba(0, 0, 0, 0.1),
        0 4px 20px rgba(0, 0, 0, 0.1);
    background: #d8cfc0;
    min-height: 0;
    touch-action: none;
}

#sand-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
    background: #e8dfd6;
    z-index: 1;
    touch-action: none;
}

#object-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
    z-index: 2;
}

#message-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
    z-index: 3;
}

.instructions {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-light);
    pointer-events: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    z-index: 10;
    white-space: nowrap;
    text-align: center;
}

.instructions .mobile-text {
    display: none;
}

.canvas-container:hover .instructions {
    opacity: 0;
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.5rem;
    flex-shrink: 0;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Song Marquee - subtle zen style */
.song-marquee {
    width: 120px;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.song-marquee:hover {
    opacity: 0.9;
}

.song-text {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-light);
    letter-spacing: 1px;
    font-weight: 400;
    animation: scroll-marquee 8s linear infinite;
    padding-left: 100%;
}

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

.brand {
    font-size: 0.8rem;
    color: var(--text-light);
    letter-spacing: 1px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s ease;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ui-container > * {
    animation: fadeIn 0.5s ease forwards;
}

/* Particle effects */
.particle {
    position: absolute;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(0.5);
    }
}

/* Thought Modal */
.thought-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.thought-modal.active {
    opacity: 1;
    visibility: visible;
}

.thought-modal-content {
    background: linear-gradient(135deg, #faf8f5 0%, #f5f0e8 100%);
    padding: 1.5rem 2rem;
    border-radius: 20px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    max-width: 320px;
    width: 90%;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.thought-modal.active .thought-modal-content {
    transform: scale(1);
}

.thought-prompt {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    letter-spacing: 1px;
    font-weight: 400;
}

#thought-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--sand-dark);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 1rem;
    -webkit-appearance: none;
}

#thought-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(156, 138, 165, 0.15);
}

#thought-input::placeholder {
    color: var(--sand-shadow);
}

.thought-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.thought-btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-appearance: none;
}

.thought-btn.secondary {
    background: var(--sand-dark);
    color: var(--text-light);
}

.thought-btn.secondary:hover {
    background: var(--sand-shadow);
}

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

.thought-btn.primary:hover {
    background: #8a7893;
    transform: translateY(-1px);
}

.thought-btn:active {
    transform: scale(0.95);
}

/* Reset Confirmation Modal */
.reset-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.reset-modal.active {
    opacity: 1;
    visibility: visible;
}

.reset-modal-content {
    background: linear-gradient(135deg, #faf8f5 0%, #f5f0e8 100%);
    padding: 1.5rem 2rem;
    border-radius: 20px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    max-width: 300px;
    width: 90%;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.reset-modal.active .reset-modal-content {
    transform: scale(1);
}

.reset-modal-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.reset-modal-title {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.reset-modal-text {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1.25rem;
    line-height: 1.4;
}

.reset-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.reset-btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-appearance: none;
    min-width: 80px;
}

.reset-btn.cancel {
    background: var(--sand-dark);
    color: var(--text-light);
}

.reset-btn.cancel:hover {
    background: var(--sand-shadow);
}

.reset-btn.confirm {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.reset-btn.confirm:hover {
    background: rgba(239, 68, 68, 1);
}

.reset-btn:active {
    transform: scale(0.95);
}

/* Desktop Styles (default above) */

/* Tablet Styles */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.75rem;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
    }
    
    .toolbar {
        gap: 0.4rem;
        padding: 0.6rem;
    }
    
    .tool-btn {
        padding: 0.6rem 0.8rem;
        min-width: 55px;
    }
    
    .tool-btn span {
        font-size: 1.3rem;
    }
    
    .tool-btn small {
        font-size: 0.65rem;
    }
}

/* Mobile Styles - Single row toolbar like desktop */
@media (max-width: 768px) {
    .ui-container {
        padding: 0.5rem;
        padding-top: max(0.25rem, env(safe-area-inset-top));
        padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
    }
    
    /* Compact header - two rows: logo+title, then subtitle */
    .header {
        margin-bottom: 0.35rem;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0.15rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
        letter-spacing: 1.5px;
    }
    
    .subtitle {
        display: block;
        font-size: 0.65rem;
        letter-spacing: 1px;
        margin: 0;
    }
    
    .logo-icon {
        width: 24px;
        height: 24px;
    }
    
    .logo-container {
        gap: 0.35rem;
        margin-bottom: 0;
    }
    
    /* Single row toolbar - compact with ALL text visible */
    .toolbar {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 0.3rem;
        padding: 0.4rem 0.5rem;
        margin-bottom: 0.5rem;
        border-radius: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .toolbar::-webkit-scrollbar {
        display: none;
    }
    
    .tool-btn {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.25rem 0.35rem;
        min-width: 42px;
        min-height: 40px;
        border-radius: 8px;
        gap: 0.1rem;
    }
    
    .tool-btn span {
        font-size: 1rem;
        line-height: 1;
    }
    
    .tool-btn small {
        font-size: 0.6rem;
        letter-spacing: 0.2px;
        text-transform: uppercase;
    }
    
    .divider {
        width: 1px;
        height: 24px;
        margin: 0 0.1rem;
        flex-shrink: 0;
    }
    
    /* Maximize canvas - reduce margins/padding */
    .canvas-container {
        border-radius: 10px;
    }
    
    /* Smaller/hidden instructions */
    .instructions {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
        bottom: 0.5rem;
        opacity: 0.6;
    }
    
    .instructions .desktop-text {
        display: none;
    }
    
    .instructions .mobile-text {
        display: inline;
    }
    
    /* Compact footer */
    .footer {
        margin-top: 0.4rem;
        padding-top: 0.25rem;
    }
    
    .brand {
        font-size: 0.7rem;
    }
    
    .song-marquee {
        width: 90px;
    }
    
    .song-text {
        font-size: 0.7rem;
    }
    
    .icon-btn {
        font-size: 1rem;
        padding: 0.35rem;
    }
}

/* Small Mobile Styles */
@media (max-width: 400px) {
    .ui-container {
        padding: 0.4rem;
        padding-top: max(0.2rem, env(safe-area-inset-top));
        padding-bottom: max(0.2rem, env(safe-area-inset-bottom));
    }
    
    .header {
        margin-bottom: 0.25rem;
        gap: 0.1rem;
    }
    
    .header h1 {
        font-size: 1.15rem;
        letter-spacing: 1px;
    }
    
    .subtitle {
        font-size: 0.6rem;
        letter-spacing: 0.8px;
    }
    
    .logo-icon {
        width: 22px;
        height: 22px;
    }
    
    .logo-container {
        gap: 0.3rem;
    }
    
    .toolbar {
        gap: 0.2rem;
        padding: 0.3rem 0.35rem;
        margin-bottom: 0.4rem;
    }
    
    .tool-btn {
        padding: 0.2rem 0.3rem;
        min-width: 38px;
        min-height: 36px;
        border-radius: 6px;
    }
    
    .tool-btn span {
        font-size: 0.9rem;
    }
    
    .tool-btn small {
        font-size: 0.55rem;
        letter-spacing: 0;
    }
    
    .divider {
        height: 20px;
        margin: 0 0.05rem;
    }
    
    .canvas-container {
        border-radius: 8px;
    }
    
    .instructions {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        bottom: 0.4rem;
    }
    
    .footer {
        margin-top: 0.4rem;
    }
    
    .brand {
        font-size: 0.65rem;
    }
    
    .song-marquee {
        width: 75px;
    }
    
    .song-text {
        font-size: 0.65rem;
    }
}

/* Extra small mobile - keep all text visible */
@media (max-width: 360px) {
    .header {
        margin-bottom: 0.2rem;
    }
    
    .header h1 {
        font-size: 1.1rem;
    }
    
    .subtitle {
        font-size: 0.55rem;
        letter-spacing: 0.5px;
    }
    
    .logo-icon {
        width: 20px;
        height: 20px;
    }
    
    .toolbar {
        gap: 0.15rem;
        padding: 0.25rem 0.3rem;
    }
    
    .tool-btn {
        min-width: 34px;
        min-height: 34px;
        padding: 0.2rem 0.25rem;
    }
    
    .tool-btn span {
        font-size: 0.85rem;
    }
    
    .tool-btn small {
        font-size: 0.5rem;
        letter-spacing: 0;
    }
    
    .divider {
        height: 18px;
        margin: 0 0.05rem;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .ui-container {
        padding: 0.4rem;
        padding-top: max(0.2rem, env(safe-area-inset-top));
        padding-bottom: max(0.2rem, env(safe-area-inset-bottom));
    }
    
    .header {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        margin-bottom: 0.25rem;
        gap: 0.15rem;
    }
    
    .header h1 {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }
    
    .subtitle {
        display: block;
        font-size: 0.55rem;
        letter-spacing: 0.8px;
        width: 100%;
        text-align: center;
        margin-top: 0.05rem;
    }
    
    .logo-icon {
        width: 22px;
        height: 22px;
    }
    
    .logo-container {
        gap: 0.35rem;
        margin-bottom: 0;
    }
    
    .toolbar {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.25rem;
        padding: 0.25rem 0.4rem;
        margin-bottom: 0.35rem;
        border-radius: 8px;
    }
    
    .tool-btn {
        padding: 0.2rem 0.3rem;
        min-width: 38px;
        min-height: 34px;
        border-radius: 6px;
    }
    
    .tool-btn span {
        font-size: 0.9rem;
    }
    
    .tool-btn small {
        font-size: 0.55rem;
    }
    
    .divider {
        height: 18px;
        margin: 0 0.1rem;
    }
    
    .canvas-container {
        border-radius: 8px;
    }
    
    .instructions {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
    
    .footer {
        margin-top: 0.35rem;
    }
}

/* Prevent text selection on mobile */
@media (pointer: coarse) {
    * {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    input, textarea {
        -webkit-user-select: text;
        user-select: text;
    }
}
