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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #17202a;
    color: #111;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

h1, h1 a, h1 a:hover {
    text-align: center;
    margin-bottom: 0;
    color: #fff;
    text-decoration: none;
}

.form-section {
    background: #ffe;
    padding: 20px 25px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h2 {
    margin-bottom: 15px;
    color: #777;
}

h3 {
    color: #777;
}

.btn,
.upload-label {
    display: inline-block;
    padding: 12px 24px;
    background-color: #444;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn:hover,
.upload-label:hover {
    background-color: #888;
}

#photo-upload {
    display: none;
}

.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.gallery-photo {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-photo:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.gallery-photo.selected {
    border: 3px solid #3498db;
}


textarea {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 5px;
    resize: vertical;
    min-height: 250px;
}

.char-count {
    text-align: right;
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 14px;
}

.postcard-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.postcard-side h3 {
    margin-bottom: 10px;
    color: #777;
    font-size: 16px;
}

.postcard-preview {
    width: 100%;
    height: auto;
    min-height: auto;
    aspect-ratio: 3/2;
    border: 2px solid #ddd;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    position: relative;
    background-color: white;
}

.postcard-preview p {
    color: #7f8c8d;
    text-align: center;
}

.postcard-back {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
}

.address-section {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #ddd;
}

.message-section {
    flex: 1;
    padding: 20px;
    display: flex;
}

.stamp-area {
    align-self: flex-end;
    border: 2px solid #ddd;
    padding: 10px;
    margin-bottom: 20px;
    font-size: 12px;
    color: #7f8c8d;
}

.address-lines {
    margin-top: auto;
}

.address-lines p {
    margin: 5px 0;
    color: #555;
    font-size: 14px;
    text-align: left;
}

#message-preview {
    color: #333;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .postcard-container {
        grid-template-columns: 1fr;
    }
}

#checkout-button {
    width: 100%;
    padding: 15px;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#checkout-button:hover:not(:disabled) {
    background-color: #219a52;
}

#checkout-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.success-container {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.success-icon {
    font-size: 80px;
    color: #27ae60;
    margin-bottom: 20px;
}

.button {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 24px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.button:hover {
    background-color: #2980b9;
}

.footer-text {
    text-align: center;
    color: #5a7086;
}

.footer-text a {
    color: #5a7086;
}

.photo-options {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* .drawing-section, .upload-section, .gallery-section {
    padding: 0 0 20px 0;
} */

.button-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

#try-again-button:hover {
    cursor: pointer;
}

.upload-section {
    padding-top: 20px;
}

.upload-section h3 {
    margin-bottom: 15px;
}

.canvas-container {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* 3:2 ratio = 66.67% */
    background-color: white;
    border: 2px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 15px;
}

#drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: block;
}

.drawing-controls {
    margin-top: 15px;
    margin-bottom: 40px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
}

.color-controls {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    margin-bottom: 3px;
}

.size-control {
    display: flex;
    align-items: center;
    gap: 10px;
}


#bg-color,
#brush-color {
    width: 40px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

#brush-size {
    width: 100px;
}

#brush-size-display {
    font-weight: 500;
    color: #555;
    min-width: 30px;
}

.tool-controls {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.tool-controls button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.tool-controls button:hover {
    background-color: #f0f0f0;
}

#undo-drawing {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

#undo-drawing:hover {
    background-color: #2980b9;
}

#undo-drawing:disabled {
    background-color: #95a5a6;
    border-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.6;
}

#clear-canvas {
    background-color: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

#clear-canvas:hover {
    background-color: #c0392b;
}

#use-drawing {

}

#use-drawing:hover {
}

@media (max-width: 768px) {
    #drawing-canvas {
        width: 100%;
        max-width: 100%;
    }
    
    .drawing-controls {
        flex-direction: column;
        align-items: stretch;
    }

}