* {
    box-sizing: border-box;
}

[hidden] {
    display: none;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: #111827;
    color: #f8fafc;
    font-family: Arial, Helvetica, sans-serif;
}

body {
    padding: 0;
}

button {
    min-height: 38px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #172033;
    color: #dbeafe;
    font: inherit;
    cursor: pointer;
}

button:hover,
button:focus {
    border-color: #64748b;
    outline: none;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.app-shell {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px;
    border-radius: 0;
    background: #111827;
}

.app-header {
    display: table;
    width: 100%;
    margin-bottom: 14px;
}

.header-main {
    display: table-cell;
    width: auto;
    padding-right: 16px;
    vertical-align: top;
}

.app-kicker {
    margin: 0 0 3px 0;
    color: #8fb8ff;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-transform: uppercase;
}

.app-header h1 {
    margin: 0 0 6px 0;
    font-size: 28px;
    line-height: 1.1;
}

.app-header p {
    margin: 0;
    color: #9fb0c8;
    font-size: 14px;
}

.room-info-link {
    color: #bfdbfe;
    text-decoration: none;
    white-space: nowrap;
}

.room-info-link:hover,
.room-info-link:focus {
    color: #ffffff;
    text-decoration: underline;
}

.qr-slot {
    position: relative;
    display: table-cell;
    width: 132px;
    height: 146px;
    overflow: hidden;
    vertical-align: top;
}

.rcRoomQrCodeLink,
.rcRoomQrCodeLink * {
    box-sizing: content-box;
}

.rcRoomQrCodeLink {
    position: absolute;
    top: 0;
    right: 0;
    display: block;
    width: 150px;
    border: solid 8px #ffffff;
    border-radius: 8px;
    color: #ffffff;
    background-color: #ffffff;
    box-shadow: 0 0 0 1px #ffffff;
    text-align: center;
    text-decoration: none;
    transform: scale(0.58);
    transform-origin: top right;
}

.rcTechLabel {
    margin: 0 0 8px 0;
    padding: 4px;
    background-color: #000000;
    color: #ffffff;
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.2em;
}

.rcRoomQrCode {
    width: 150px;
    height: 150px;
}

.rcRoomId {
    margin: 8px 0 0 0;
    padding: 4px;
    background-color: #000000;
    color: #ffffff;
    font-family: monospace;
    font-size: 16px;
    letter-spacing: 0.25em;
}

.board-panel {
    margin-top: 0;
}

.toolbar {
    margin-bottom: 12px;
    font-size: 0;
}

.action-row {
    width: 520px;
    max-width: 560px;
    margin-bottom: 20px;
    font-size: 0;
}

.app-header .toolbar {
    margin-top: 20px;
}

.toolbar button {
    margin: 0 8px 8px 0;
    padding: 0 14px;
    font-size: 14px;
}

.action-row button {
    display: inline-block;
    width: 122px;
    margin: 0 8px 8px 0;
    padding: 0 8px;
    font-size: 14px;
    white-space: nowrap;
}

.primary-button {
    border-color: #4f46e5;
    background: #4f46e5;
    color: #ffffff;
}

.toggle-button.is-active {
    border-color: #991b1b;
    background: #7f1d1d;
    color: #ffffff;
}

#fileInput,
#importInput {
    display: none;
}

.recording-panel {
    margin: 0 0 12px 0;
    padding: 10px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0b1220;
}

.recording-panel span {
    display: inline-block;
    margin-right: 12px;
    color: #fecaca;
    font-weight: bold;
}

.recording-panel button {
    margin-right: 8px;
    padding: 0 12px;
}

.sound-grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -5px 22px -5px;
}

.sound-tile,
.add-tile {
    position: relative;
    width: 25%;
    min-width: 170px;
    height: 154px;
    padding: 5px;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.tile-inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    font-weight: bold;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

.sound-tile.is-playing .tile-inner {
    transform: scale(0.97);
}

.tile-label {
    position: relative;
    z-index: 2;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1;
    display: block;
    width: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.26);
}

.sound-tile.is-playing .progress-fill {
    height: 100%;
}

.sound-tile.progress-unknown .progress-fill {
    width: 38% !important;
    animation: progressPulse 1.1s linear infinite;
}

@keyframes progressPulse {
    0% {
        left: -38%;
    }

    100% {
        left: 100%;
    }
}

.sound-tile.has-error .tile-inner {
    opacity: 0.42;
    filter: grayscale(65%);
}

.sound-tile.has-error .tile-inner:hover,
.sound-tile.has-error .tile-inner:focus {
    opacity: 0.62;
}

.error-badge {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 3;
    width: 26px;
    height: 26px;
    border: 2px solid #ffffff;
    border-radius: 15px;
    background: #991b1b;
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    line-height: 22px;
    text-align: center;
    text-shadow: none;
}

.drag-handle {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 3;
    width: 34px;
    min-height: 28px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.18);
    cursor: move;
    touch-action: none;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.drag-handle:before,
.drag-handle:after {
    content: "";
    position: absolute;
    left: 9px;
    right: 9px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.76);
}

.drag-handle:before {
    top: 9px;
}

.drag-handle:after {
    top: 16px;
}

.drag-placeholder {
    opacity: 1;
}

.drag-placeholder-inner {
    width: 100%;
    height: 100%;
    border: 2px dashed #64748b;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.drag-ghost {
    position: fixed;
    z-index: 40;
    min-width: 0;
    pointer-events: none;
    opacity: 0.94;
    transform: rotate(1deg) scale(1.02);
}

.drag-ghost .options-menu {
    display: none;
}

body.is-reordering {
    overflow: hidden;
    position: fixed;
    width: 100%;
    user-select: none;
    touch-action: none;
}

.menu-button {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    min-height: 28px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.18);
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
    line-height: 28px;
}

.options-menu {
    position: absolute;
    top: 48px;
    right: 14px;
    z-index: 4;
    width: 116px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: #0b1220;
}

.options-menu button {
    display: block;
    width: 100%;
    min-height: 34px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: #dbeafe;
    text-align: left;
}

.options-menu button:hover,
.options-menu button:focus {
    background: #1f2937;
}

.add-tile button {
    display: block;
    width: 100%;
    height: 100%;
    border: 2px dashed #4b5563;
    border-radius: 12px;
    background: #151d2e;
    color: #9ca3af;
    font-weight: bold;
}

.add-symbol {
    display: block;
    margin-bottom: 14px;
    font-size: 34px;
    line-height: 1;
}

.notice {
    margin: 4px 0 0 0;
    padding: 12px 14px;
    border: 1px solid #164e63;
    border-radius: 8px;
    background: #082f3a;
    color: #cce7f3;
    font-size: 14px;
    line-height: 1.35;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    padding: 18px;
    background: rgba(0, 0, 0, 0.58);
}

.modal-panel {
    width: 100%;
    max-width: 380px;
    margin: 18vh auto 0 auto;
    padding: 18px;
    border: 1px solid #334155;
    border-radius: 10px;
    background: #111827;
    color: #f8fafc;
}

.modal-panel h2 {
    margin: 0 0 10px 0;
    font-size: 22px;
    line-height: 1.15;
}

.modal-panel p {
    margin: 0 0 14px 0;
    color: #cbd5e1;
    line-height: 1.35;
}

.modal-panel input {
    display: block;
    width: 100%;
    min-height: 40px;
    margin: 0 0 16px 0;
    padding: 0 10px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #0b1220;
    color: #f8fafc;
    font: inherit;
}

.modal-panel input[hidden] {
    display: none;
}

.color-palette {
    margin: 0 0 16px 0;
    font-size: 0;
}

.color-swatch {
    display: inline-block;
    width: 34px;
    min-height: 34px;
    margin: 0 7px 7px 0;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-radius: 17px;
}

.color-swatch.is-selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.modal-actions {
    text-align: right;
}

.modal-actions button {
    min-width: 92px;
    margin-left: 8px;
    padding: 0 14px;
}

@media (min-width: 1200px) {
    .sound-tile,
    .add-tile {
        width: 16.6666%;
    }
}

@media (max-width: 760px) {
    body {
        padding: 0;
        background: #111827;
    }

    .app-shell {
        min-height: 100vh;
        border-radius: 0;
        padding: 14px;
    }

    .app-header {
        display: table;
        min-height: 0;
        padding-right: 0;
    }

    .header-main {
        display: table-cell;
        padding-right: 10px;
        vertical-align: top;
    }

    .app-header h1 {
        font-size: 23px;
    }

    .qr-slot {
        display: table-cell;
        width: 104px;
        height: 104px;
        vertical-align: top;
    }

    .rcRoomQrCodeLink {
        transform: scale(0.43);
    }

    .toolbar button {
        min-width: 74px;
        min-height: 36px;
        margin-right: 6px;
        padding: 0 10px;
        font-size: 14px;
    }

    .action-row {
        width: auto;
        max-width: none;
        margin-left: -3px;
        margin-right: -3px;
    }

    .action-row button {
        width: calc(50% - 6px);
        margin: 0 3px 8px 3px;
        font-size: 14px;
    }

    .sound-tile,
    .add-tile {
        width: 50%;
        min-width: 0;
        height: 136px;
    }
}

@media (max-width: 390px) {
    .sound-tile,
    .add-tile {
        height: 122px;
    }
}
