:root {
    --primary: #ff3e00;
    --bg: #0a0a0a;
    --text: #ffffff;
    --ui-bg: rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
    z-index: 10;
}

header {
    margin-bottom: 15px;
    text-align: left;
}

h1 {
    font-size: 20px;
    letter-spacing: 2px;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(255, 62, 0, 0.5);
    color: white;
    margin-bottom: 2px;
}

.lag-warning {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    color: #ffaa88;
    text-align: left;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    margin-bottom: 10px;
    align-items: flex-start;
}

/* Top control bar: place main buttons in one row */
.controls.top {
    flex-direction: row;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

/* Make each direct child of the top row share equal width so main buttons line up */
.top-row > * {
    flex: 1;
    min-width: 0; /* allow children to shrink on narrow viewports */
}

/* Left column group for Image + Mode: fixed width so mode label changes won't shift sibling buttons */
.image-mode-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    width: auto;   /* allow the column to size with flex */
    flex: 1.4;     /* slightly reduced width so buttons are a bit less wide */
    min-width: 0;  /* allow proper shrinking on small screens */
}

.image-mode-group .image-row {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    justify-content: center;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.control-item label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    outline: none;
    display: block;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 62, 0, 0.5);
}

.btn {
    background: var(--ui-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 14px; /* slightly reduced touch area */
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px; /* slightly reduced text */
    min-height: 42px; /* slightly smaller touch height */
    line-height: 1;
    backdrop-filter: blur(10px);
    transition: background 0.2s;
    width: 100%; /* fill the flex cell for equal widths */
    text-align: center;
    white-space: nowrap; /* keep button labels on a single line */

    /* Ensure long labels never wrap or break across lines on narrow viewports */
    overflow: visible;
    text-overflow: clip;
    word-break: normal;
    -webkit-font-smoothing: antialiased;
}

.btn:active {
    background: var(--primary);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.menu-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.menu-content {
    background: #1a1a1a;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.menu-actions {
    margin-bottom: 20px;
    width: 100%;
}

.upload-btn-full {
    display: block;
    text-align: center;
    width: 100%;
    background: var(--primary);
    border: none;
    font-weight: bold;
}

.menu-header h2 {
    font-size: 18px;
    letter-spacing: 1px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0 10px;
}

.samples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding: 5px;
}

.sample-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    background: rgba(255, 255, 255, 0.05);
}

.sample-thumb:hover {
    transform: scale(1.1);
}

.sample-thumb.active {
    border-color: var(--primary);
}

.hint {
    position: absolute;
    bottom: 72px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 14px;
    opacity: 0.6;
    animation: pulse 2s infinite;
}

/* Footer */
.app-footer {
    position: absolute;
    bottom: 18px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    pointer-events: auto;
}
.app-footer a { color: var(--primary); text-decoration: none; font-weight: 700; }

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Sound settings list */
.sound-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
}

.sound-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.03);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.04);
}

.sound-item .meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sound-item .meta .name {
    font-size: 13px;
    font-weight: 700;
}

.sound-item .meta .desc {
    font-size: 11px;
    opacity: 0.7;
}

.sound-item .actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sound-item .actions .btn {
    padding: 6px 10px;
    font-size: 12px;
}

