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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Chalkboard canvas */
#chalkboard {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
    /* Green chalkboard gradient */
    background: radial-gradient(ellipse at center, #2d5a3d 0%, #1a3d28 50%, #0f2818 100%);
}

#chalkboard.text-mode {
    cursor: text;
}

#chalkboard.eraser-mode {
    cursor: cell;
}

/* Text layer overlays canvas */
#text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* Text elements */
.chalk-text {
    position: absolute;
    pointer-events: auto;
    cursor: move;
    padding: 8px 12px;
    font-family: 'Comic Sans MS', 'Chalkboard', cursive;
    white-space: nowrap;
    user-select: none;
    transform-origin: center center;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s;
    /* Chalk effect */
    text-shadow:
        0 0 2px currentColor,
        1px 1px 1px rgba(0,0,0,0.3);
}

.chalk-text:hover {
    border-color: rgba(255,255,255,0.3);
}

.chalk-text.selected {
    border-color: rgba(255,255,255,0.6);
}

.chalk-text.editing {
    cursor: text;
}

/* Resize handle */
.chalk-text .resize-handle {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 14px;
    height: 14px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.15s;
}

.chalk-text.selected .resize-handle {
    opacity: 1;
}

/* Rotate indicator */
.chalk-text .rotate-hint {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}

.chalk-text.selected .rotate-hint {
    opacity: 1;
}

/* Toolbar */
#toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(30, 30, 30, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tool-group.separator {
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,0.15);
}

.tool-group.right {
    margin-left: auto;
}

/* Tool buttons */
.tool {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.tool svg {
    width: 22px;
    height: 22px;
}

.tool:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.tool.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.tool.primary {
    width: auto;
    padding: 0 16px;
    gap: 8px;
    background: #4a7c59;
    color: #fff;
}

.tool.primary:hover {
    background: #5a9c6a;
}

.tool.primary span {
    font-size: 14px;
    font-weight: 500;
}

/* Color buttons */
#colors {
    display: flex;
    gap: 6px;
}

.color {
    width: 26px;
    height: 26px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
}

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

.color.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

/* Size buttons */
#sizes {
    display: flex;
    gap: 6px;
    align-items: center;
}

.size {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.size span {
    background: rgba(255,255,255,0.7);
    border-radius: 50%;
    display: block;
}

.size:hover {
    background: rgba(255,255,255,0.1);
}

.size:hover span {
    background: #fff;
}

.size.active {
    background: rgba(255,255,255,0.2);
}

.size.active span {
    background: #fff;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    z-index: 200;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#toast.success {
    background: #4a7c59;
}

#toast.error {
    background: #c0392b;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 12px;
    min-width: 300px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #1a1a1a;
    color: #fff;
    font-size: 16px;
    outline: none;
}

.modal-content input:focus {
    border-color: #4a7c59;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

.modal-buttons button:first-child {
    background: #444;
    color: #fff;
}

.modal-buttons button:first-child:hover {
    background: #555;
}

.modal-buttons button.primary {
    background: #4a7c59;
    color: #fff;
}

.modal-buttons button.primary:hover {
    background: #5a9c6a;
}

/* Responsive */
@media (max-width: 600px) {
    #toolbar {
        bottom: 10px;
        padding: 8px 12px;
        gap: 6px;
        flex-wrap: wrap;
        max-width: calc(100% - 20px);
        justify-content: center;
    }

    .tool-group.separator {
        padding-left: 8px;
    }

    .tool {
        width: 36px;
        height: 36px;
    }

    .tool svg {
        width: 20px;
        height: 20px;
    }

    .color {
        width: 22px;
        height: 22px;
    }

    .size {
        width: 28px;
        height: 28px;
    }

    .tool.primary span {
        display: none;
    }

    .tool.primary {
        width: 40px;
        padding: 0;
    }
}
