@font-face {
    font-family: Alsina;
    src: url(../../assets/font/Alsina.ttf);
}
/* 
@font-face {
    font-family: RAGE;
    src: url(../../assets/font/RAGE.ttf);
}

@font-face {
    font-family: nth;
    src: url(../../assets/font/NothingYouCouldDo-Regular.ttf);
}

@font-face {
    font-family: KTX;
    src: url(../../assets/font/KaTeX_Fraktur-Regular.ttf);
}

@font-face {
    font-family: InstrumentSerif;
    src: url(../../assets/font/InstrumentSerif-Regular.ttf);
}   */

*,
*::before,
*::after {
    box-sizing: border-box;
    transition: all .18s ease-in-out;
}

body {
    margin: 0;
    padding: 0;
    height: 100dvh;
    font-family: Alsina, Arial, Helvetica, sans-serif;
    background: #f4f4f4;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 0.5rem;
    overflow-x: hidden;
    /* prevent page-level horizontal scroll */
}

small.alert-text {
    background-color: rgba(255, 255, 0, 0.45);
    padding: .35rem;
    text-align: center;
    display: block;
}

#canvas-container {
    width: 100%;
    /* allow the container to grow based on content rather than forcing 100% height */
    height: auto;
    min-height: 240px;
    /* ensure visible area on small screens before JS runs */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    overflow: auto;
    /* keep local scroll box for tall/wide canvases */
    -webkit-overflow-scrolling: touch;
}

/* New wrapper: keeps the canvas at the intended logical width but allows downscaling on small screens */
#canvas-wrap {
    width: 100%;
    max-width: 600px;
    /* logical width used by the drawing code; scales down on narrow viewports */
    display: block;
    box-sizing: border-box;
}

canvas {
    display: block;
    /* avoid inline layout quirks */
    width: 100%;
    max-width: 600px;
    /* ensure displayed canvas never exceeds logical width */
    min-height: 220px;
    /* fallback height so user sees something on mobile before rendering */
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: white;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

#controls {
    width: 100%;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: white;
    border-right: 1px solid rgba(0, 0, 0, 0.04);
}

textarea {
    padding: 0.75rem;
    font-size: 1.05rem;
    width: 100%;
    height: 220px;
    border: 1px solid #ddd;
    border-radius: 6px;
    resize: vertical;
}

.controls-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.controls-row label {
    font-size: 0.95rem;
}

.controls-row input[type="number"],
.controls-row input[type="text"] {
    width: 5.5rem;
}

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

button {
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    background: #111;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

button:hover {
    background: #222;
}

#downloadBtn,
#copyBtn {
    display: none;
}

@media screen and (max-width: 900px) {
    body {
        grid-template-columns: 1fr;
    }

    /* Keep DOM order: controls then canvas. Do not swap with CSS order. */
    #canvas-container {
        padding-top: 0.25rem;
        min-height: 320px;
    }

    canvas {
        width: 98%;
        min-height: 320px;
    }
}