:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --card-active: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden; /* Prevent scrolling */
    user-select: none;
    -webkit-user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    color: transparent;
    letter-spacing: 1px;
}

.hidden-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.1; /* Almost invisible, only parents know to press it */
    transition: opacity 0.3s;
    padding: 10px;
}

.hidden-button:active {
    opacity: 0.5;
}

/* Grid */
.communication-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 1.5rem;
    padding: 0 2rem 2rem 2rem;
    flex: 1;
    height: calc(100vh - 80px);
}

.cell {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-soft);
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.2s, background 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Debounce State */
.cell.disabled {
    pointer-events: none;
    opacity: 0.6;
    filter: grayscale(80%);
}

.cell.playing {
    border-color: var(--accent);
    transform: scale(0.96);
    background: var(--card-active);
}

.cell.empty {
    visibility: hidden; /* Takes up space but invisible */
    pointer-events: none;
}

/* Cell Content */
.cell-emoji {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    /* Add a subtle drop shadow to emojis */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.cell-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Custom Image */
.cell-image {
    width: 100%;
    height: 60%;
    object-fit: contain;
    margin-bottom: 0.5rem;
    border-radius: 8px;
}

.file-input {
    background: var(--card-active);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px dashed var(--text-secondary);
    width: 100%;
    cursor: pointer;
}

/* Admin Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.overlay.hidden {
    display: none;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.btn-close {
    background: var(--card-bg);
    border: none;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.admin-card {
    background: var(--card-active);
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border: 1px solid transparent;
}
.admin-card:hover { border-color: var(--accent); }

.admin-card.is-empty {
    opacity: 0.5;
    border: 1px dashed var(--text-secondary);
}


/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 { margin-bottom: 1.5rem; }

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

input[type="text"], select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--text-secondary);
    background: var(--bg-color);
    color: white;
    font-family: inherit;
}

/* Switch styling */
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-color); border-radius: 34px; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; border-radius: 50%; transition: .4s; }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(26px); }


/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    color: white;
    font-family: inherit;
}
.btn-primary { background: var(--accent); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-secondary { background: var(--text-secondary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

.audio-recorder {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.recorder-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.recorder-controls .btn {
    padding: 0.5rem 1rem;
    flex: 1;
}

.status-msg { margin-top: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); }
