/* Theme Color Variables */
:root {
    /* Primary Palette */
    --color-dark-slate: #343659;
    --color-purple: #61428C;
    --color-light-periwinkle: #A7BAF2;
    --color-deep-maroon: #590B20;
    --color-bright-red: #F20707;
    --color-black: #0D0D0D;
    
    /* Semantic Color Mappings */
    --bg-primary: var(--color-deep-maroon);
    --bg-secondary: rgba(52, 54, 89, 0.647);
    --bg-card: rgba(52, 54, 89, 0.647);
    --bg-modal: rgba(52, 54, 89, 0.95);
    --bg-input: var(--color-dark-slate);
    --bg-button-primary: rgba(97, 66, 140, 0.647);
    --bg-button-danger: var(--color-deep-maroon);
    --bg-button-success: var(--color-purple);
    
    --text-primary: #fff;
    --text-secondary: var(--color-light-periwinkle);
    --text-accent: var(--color-purple);
    --text-muted: var(--color-deep-maroon);
    
    --border-primary: var(--color-purple);
    --border-secondary: var(--color-light-periwinkle);
    --border-accent: var(--color-deep-maroon);
    
    --accent-primary: var(--color-purple);
    --accent-secondary: var(--color-light-periwinkle);
    --accent-red: var(--color-deep-maroon);
    --accent-bright-red: var(--color-bright-red);
    
    --shadow-primary: rgba(97, 66, 140, 0.3);
    --shadow-secondary: rgba(167, 186, 242, 0.2);
    --shadow-red: rgba(89, 11, 32, 0.3);
    --shadow-dark: rgba(13, 13, 13, 0.5);
}

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

@font-face {
    font-family: 'Kinko';
    /* src: url('fonts/MeqanorRegular-woOKZ.otf') format('truetype'); */
    src: url('fonts/MeqanorRegular-woOKZ.otf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: monospace;
    background: #000000;
    min-height: 100vh;
    padding: 15px;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}


.header {
    text-align: center;
    color: #fff;
    margin-bottom: 15px;
}

.header h1 {
    font-family: 'Kinko', sans-serif;
    font-size: 5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-light-periwinkle) 50%, var(--color-deep-maroon) 100%);
    background-clip: text;
    margin-bottom: 5px;
    /* text-shadow: 0 0 30px rgba(97, 66, 140, 0.5); */
    /* filter: drop-shadow(0 0 10px rgba(97, 66, 140, 0.3)); */
}

.decorative-header {
    font-family: 'Kinko', sans-serif;
}

.decorative-header span {
    display: inline-block;
    background: linear-gradient(90deg, 
        var(--color-purple) 0%, 
        var(--color-purple) 12.5%, 
        var(--color-light-periwinkle) 25%, 
        var(--color-light-periwinkle) 37.5%, 
        var(--color-purple) 50%, 
        var(--color-purple) 62.5%, 
        var(--color-light-periwinkle) 75%, 
        var(--color-purple) 87.5%, 
        var(--color-light-periwinkle) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 300% 100%;
    animation: twinkleWaveHeader 3s ease-in-out infinite;
    transform-origin: center;
}

/* create wave effect with different delays for each letter */
.decorative-header span:nth-child(1) { animation-delay: 0s; }
.decorative-header span:nth-child(2) { animation-delay: 0.1s; }
.decorative-header span:nth-child(3) { animation-delay: 0.2s; }
.decorative-header span:nth-child(4) { animation-delay: 0.3s; }
.decorative-header span:nth-child(5) { animation-delay: 0.4s; }
.decorative-header span:nth-child(6) { animation-delay: 0.5s; }
.decorative-header span:nth-child(7) { animation-delay: 0.6s; }
.decorative-header span:nth-child(8) { animation-delay: 0.7s; }
.decorative-header span:nth-child(9) { animation-delay: 0.8s; }
.decorative-header span:nth-child(10) { animation-delay: 0.9s; }
.decorative-header span:nth-child(11) { animation-delay: 1.0s; }
.decorative-header span:nth-child(12) { animation-delay: 1.1s; }
.decorative-header span:nth-child(13) { animation-delay: 1.2s; }
.decorative-header span:nth-child(14) { animation-delay: 1.3s; }
.decorative-header span:nth-child(15) { animation-delay: 1.4s; }
.decorative-header span:nth-child(16) { animation-delay: 1.5s; }
.decorative-header span:nth-child(17) { animation-delay: 1.6s; }
.decorative-header span:nth-child(18) { animation-delay: 1.7s; }
.decorative-header span:nth-child(19) { animation-delay: 1.8s; }

@keyframes twinkleWaveHeader {
    0% {
        background-position: -150% 50%;
        opacity: 0.7;
        transform: scale(1);
    }
    25% {
        background-position: -50% 50%;
        opacity: 1;
        transform: scale(1.02);
    }
    50% {
        background-position: 50% 50%;
        opacity: 1;
        transform: scale(1);
    }
    75% {
        background-position: 150% 50%;
        opacity: 1;
        transform: scale(1.02);
    }
    100% {
        background-position: 250% 50%;
        opacity: 0.7;
        transform: scale(1);
    }
}

.header p {
    color: var(--text-primary);
    font-size: 1rem;
}

.decorative-text {
    display: inline-block;
}

.decorative-text span {
    display: inline-block;
    background: linear-gradient(90deg, 
        var(--color-purple) 0%, 
        var(--color-light-periwinkle) 25%, 
        var(--color-deep-maroon) 50%, 
        var(--color-light-periwinkle) 75%, 
        var(--color-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 100%;
    animation: twinkleWave 2.5s ease-in-out infinite;
}

/* Create wave effect with different delays for each character */
.decorative-text span:nth-child(1) { animation-delay: 0s; }
.decorative-text span:nth-child(2) { animation-delay: 0.15s; }
.decorative-text span:nth-child(3) { animation-delay: 0.3s; }
.decorative-text span:nth-child(4) { animation-delay: 0.45s; }
.decorative-text span:nth-child(5) { animation-delay: 0.6s; }
.decorative-text span:nth-child(6) { animation-delay: 0.75s; }
.decorative-text span:nth-child(7) { animation-delay: 0.9s; }
.decorative-text span:nth-child(8) { animation-delay: 1.05s; }
.decorative-text span:nth-child(9) { animation-delay: 1.2s; }
.decorative-text span:nth-child(10) { animation-delay: 1.35s; }
.decorative-text span:nth-child(11) { animation-delay: 1.5s; }
.decorative-text span:nth-child(12) { animation-delay: 1.65s; }
.decorative-text span:nth-child(13) { animation-delay: 1.8s; }
.decorative-text span:nth-child(14) { animation-delay: 1.95s; }
.decorative-text span:nth-child(15) { animation-delay: 2.1s; }
.decorative-text span:nth-child(16) { animation-delay: 2.25s; }
.decorative-text span:nth-child(17) { animation-delay: 2.4s; }
.decorative-text span:nth-child(18) { animation-delay: 2.55s; }

@keyframes twinkleWave {
    0% {
        background-position: -100% 50%;
        opacity: 0.6;
    }
    50% {
        background-position: 100% 50%;
        opacity: 1;
    }
    100% {
        background-position: -100% 50%;
        opacity: 0.6;
    }
}

.main-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 15px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 120px);
    position: relative;
    z-index: 1;
}

.drawing-section {
    background: var(--bg-secondary);
    padding: 18px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.tool-btn {
    padding: 12px 18px;
    border: 2px solid var(--border-primary);
    color: var(--text-secondary);
    border-radius: 15px;
    cursor: pointer;
    font-size: 1.3rem;
    transition: all 0.3s;
    box-shadow: 0 4px 10px var(--shadow-primary);
}

.tool-btn:hover {
    background: var(--color-purple);
    color: var(--text-primary);
    transform: translateY(-2px) scale(1.05);
}

.tool-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.color-picker {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-btn {
    width: 45px;
    height: 45px;
    border: 3px solid var(--color-dark-slate);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.color-btn.active {
    border-color: var(--color-purple);
    transform: scale(1.2);
}

.custom-color-btn {
    font-size: 1.2rem;
    background: #ffffff;
    border: 3px solid var(--color-dark-slate);
}

.custom-color-btn:hover {
    transform: scale(1.15);
}

.custom-color-btn.active {
    border-color: var(--color-purple);
}

/* Color Picker Modal */
.color-picker-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--shadow-dark);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.color-picker-content {
    background: var(--bg-modal);
    border: 3px solid var(--border-primary);
    border-radius: 25px;
    padding: 25px;
    box-shadow: 
        0 0 30px var(--shadow-primary),
        0 10px 40px var(--shadow-dark);
    max-width: 400px;
    width: 90%;
}

.color-picker-content h3 {
    color: var(--accent-primary);
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 800;
}

.color-preview-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    justify-content: center;
}

.color-preview {
    width: 80px;
    height: 80px;
    border: 4px solid var(--border-primary);
    border-radius: 15px;
    background: var(--color-black);
    box-shadow: 0 4px 15px var(--shadow-primary);
}

.color-hex-display {
    background: var(--bg-input);
    padding: 12px 20px;
    border-radius: 15px;
    border: 2px solid var(--border-primary);
}

.color-hex-display span {
    color: var(--text-accent);
    font-size: 1.2rem;
    font-weight: 700;
    font-family: monospace;
}

.rgb-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.rgb-slider {
    display: flex;
    align-items: center;
    gap: 15px;
}

.rgb-slider label {
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 60px;
    font-size: 1rem;
}

.rgb-slider label span {
    color: var(--text-accent);
    font-weight: 700;
    min-width: 35px;
    display: inline-block;
}

.rgb-slider input[type="range"] {
    flex: 1;
    height: 8px;
    accent-color: var(--accent-primary);
    background: var(--bg-input);
    border-radius: 5px;
}

.color-picker-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.color-picker-buttons .btn {
    flex: 1;
    min-width: 120px;
}

.brush-size {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 600;
}

.brush-size input {
    width: 120px;
    accent-color: var(--accent-primary);
}

.brush-size span {
    color: var(--text-accent);
    font-size: 1.1rem;
    min-width: 30px;
}


.canvas-container {
    overflow: visible;
    background: #fff;
    display: inline-block;
    flex-shrink: 0;
    margin: 0 auto;
    width: 650px;
    height: 650px;
    position: relative;
}

.draggable-image {
    position: absolute;
    cursor: move;
    border: 2px solid var(--border-primary);
    box-shadow: 0 4px 15px var(--shadow-primary);
    user-select: none;
    z-index: 10;
}

.draggable-image.selected {
    border-color: var(--text-accent);
    box-shadow: 0 0 0 2px var(--shadow-primary), 0 4px 15px var(--shadow-secondary);
}

.draggable-image img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border: 2px solid white;
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 11;
    box-shadow: 0 2px 8px var(--shadow-dark);
}

.resize-handle.bottom-right {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.resize-handle.bottom-left {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.resize-handle.top-right {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.resize-handle.top-left {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.delete-handle {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: var(--color-deep-maroon);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 8px var(--shadow-dark);
}

.delete-handle:hover {
    background: var(--color-bright-red);
    transform: scale(1.1);
}

#drawingCanvas {
    display: block;
    cursor: crosshair;
    background: white;
    touch-action: none; /* Prevent scrolling while drawing */
    -webkit-touch-callout: none; /* Disable iOS callout */
    -webkit-user-select: none; /* Disable selection */
    user-select: none;
}

.controls {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background: var(--bg-button-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.05);
}

.btn-danger {
    background: var(--bg-button-danger);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px) scale(1.05);
}

.btn-success {
    background: var(--bg-button-success);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px) scale(1.05);
}

.btn-secondary {
    background: var(--color-light-periwinkle);
    color: var(--color-dark-slate);
}

.btn-secondary:hover {
    transform: translateY(-2px) scale(1.05);
    background: var(--color-purple);
    color: white;
}

/* Undo/Redo buttons in toolbar - styled as tool buttons */
#undoBtn:disabled,
#redoBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: #ffffff;
    pointer-events: none;
}

.billboard-section {
    background: var(--bg-card);
    border: 3px solid var(--border-primary);
    border-radius: 25px;
    padding: 18px;
    box-shadow: 
        0 0 20px var(--shadow-primary),
        0 10px 40px var(--shadow-dark),
        inset 0 0 20px var(--shadow-secondary);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.billboard-section::-webkit-scrollbar {
    width: 10px;
}

.billboard-section::-webkit-scrollbar-track {
    background: var(--color-light-periwinkle);
    border-radius: 10px;
}

.billboard-section::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 10px;
}

.billboard-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-deep-maroon) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    text-align: center;
    flex-shrink: 0;
}

.messages-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    flex: 1;
    min-height: 0; /* Allows flex child to shrink below content size */
}

.message-card {
    border: 2px solid var(--border-secondary);
    border-radius: 15px;
    padding: 12px;
    background: var(--bg-card);
    transition: all 0.3s;
    box-shadow: 0 4px 15px var(--shadow-secondary);
    flex-shrink: 0;
}

.message-image {
    width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 2px solid var(--border-secondary);
    box-shadow: 0 4px 15px var(--shadow-primary);
}

.message-info {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.message-info strong {
    color: var(--text-accent);
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-accent);
    font-size: 1.1rem;
    font-weight: 600;
}

input[type="text"] {
    padding: 12px 16px;
    border: 2px solid var(--color-dark-slate);
    border-radius: 15px;
    font-size: 1rem;
    width: 220px;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all 0.3s;
}

input[type="text"]::placeholder {
    color: var(--color-light-periwinkle);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--border-primary);
    background: var(--color-dark-slate);
    box-shadow: 0 0 20px var(--shadow-primary);
    color: var(--text-accent);
}

/* Kawaii sparkle animations */
@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

.sparkle {
    display: inline-block;
    animation: sparkle 2s ease-in-out infinite;
}


/* Tablet and below */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
        height: auto;
        gap: 15px;
    }
    
    .drawing-section {
        height: auto;
    }
    
    .billboard-section {
        height: 400px;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }
    
    .header p {
        font-size: 0.9rem;
    }
    
    .main-container {
        grid-template-columns: 1fr;
        gap: 12px;
        height: auto;
    }
    
    .drawing-section {
        padding: 15px;
        height: auto;
    }
    
    .toolbar {
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .tool-btn {
        padding: 10px 14px;
        font-size: 1.1rem;
        min-height: 44px; /* iOS touch target minimum */
    }
    
    .color-btn {
        width: 40px;
        height: 40px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .brush-size {
        font-size: 0.9rem;
    }
    
    .brush-size input {
        width: 100px;
    }
    
    .canvas-container {
        width: 100%;
        max-width: 100%;
    }
    
    #drawingCanvas {
        width: 100%;
        height: auto;
        max-width: 100%;
    }
    
    .controls {
        margin-top: 10px;
        gap: 6px;
        flex-direction: column;
    }
    
    .controls input[type="text"] {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS (must be 16px or larger) */
        -webkit-appearance: none;
        appearance: none;
        border-radius: 15px;
    }
    
    .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 1rem;
        min-height: 44px; /* iOS touch target minimum */
    }
    
    .billboard-section {
        padding: 15px;
        height: 350px;
        max-height: 50vh;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .billboard-title {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }
    
    .messages-grid {
        gap: 10px;
    }
    
    .message-card {
        padding: 10px;
    }
    
    .message-image {
        margin-bottom: 6px;
    }
    
    .message-info {
        font-size: 0.85rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header p {
        font-size: 0.85rem;
    }
    
    .color-picker-content {
        padding: 20px;
        max-width: 90%;
    }
    
    .color-picker-content h3 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
    
    .color-preview {
        width: 60px;
        height: 60px;
    }
    
    .color-hex-display {
        padding: 10px 15px;
    }
    
    .color-hex-display span {
        font-size: 1rem;
    }
    
    .rgb-slider {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .rgb-slider label {
        min-width: auto;
    }
    
    .rgb-slider input[type="range"] {
        width: 100%;
    }
    
    .color-picker-buttons {
        flex-direction: column;
    }
    
    .color-picker-buttons .btn {
        width: 100%;
    }
    
    .drawing-section {
        padding: 12px;
    }
    
    .toolbar {
        gap: 5px;
    }
    
    .tool-btn {
        padding: 8px 12px;
        font-size: 1rem;
    }
    
    .color-btn {
        width: 36px;
        height: 36px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .brush-size {
        font-size: 0.85rem;
    }
    
    .brush-size input {
        width: 80px;
    }
    
    .billboard-section {
        padding: 12px;
        height: 300px;
    }
    
    .billboard-title {
        font-size: 1.1rem;
    }
    
    .message-card {
        padding: 8px;
    }
    
    .message-info {
        font-size: 0.8rem;
    }
}

