/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #242C39;
    color: #F2E9D9;
    user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    color: #F2E9D9;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

h2 {
    font-size: 14px;
    font-weight: 600;
    color: #BE9E54;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.subtitle {
    text-align: center;
    color: rgba(242, 233, 217, 0.5);
    font-size: 13px;
    margin-bottom: 30px;
    letter-spacing: 0.3px;
}

/* ===== BUTTONS ===== */
.btn {
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    letter-spacing: 0.3px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #BE9E54;
    color: #242C39;
}

.btn-primary:active {
    background: #a88a47;
}

.btn-secondary {
    background: rgba(242, 233, 217, 0.08);
    color: #F2E9D9;
    border: 1px solid rgba(190, 158, 84, 0.25);
}

.btn-secondary:active {
    background: rgba(242, 233, 217, 0.15);
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-top: 20px;
    border-radius: 10px;
}

.btn-full {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    background: rgba(242, 233, 217, 0.06);
    color: #F2E9D9;
    margin-bottom: 6px;
    border: 1px solid rgba(190, 158, 84, 0.1);
}

.btn-full:active {
    background: rgba(190, 158, 84, 0.15);
}

.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 20px;
    background: rgba(242, 233, 217, 0.08);
    color: #BE9E54;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(190, 158, 84, 0.2);
}

.btn-icon:disabled {
    opacity: 0.25;
    cursor: default;
}

.btn-icon:disabled:active {
    transform: none;
}

/* ===== SCREEN 1: CONFIG ===== */
.config-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.size-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.size-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.size-group label {
    font-size: 11px;
    color: #BE9E54;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
}

.stepper {
    display: flex;
    align-items: center;
    background: rgba(242, 233, 217, 0.06);
    border-radius: 10px;
    border: 1px solid rgba(190, 158, 84, 0.2);
    overflow: hidden;
}

.stepper-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    color: #BE9E54;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.1s;
}

.stepper-btn:active {
    background: rgba(190, 158, 84, 0.15);
}

.stepper input {
    width: 50px;
    height: 48px;
    text-align: center;
    border: none;
    background: transparent;
    color: #F2E9D9;
    font-size: 22px;
    font-weight: 700;
    -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.size-separator {
    font-size: 28px;
    font-weight: 300;
    color: rgba(190, 158, 84, 0.4);
    margin-top: 20px;
}

.preview-size {
    text-align: center;
    color: rgba(242, 233, 217, 0.4);
    font-size: 13px;
    margin-bottom: 10px;
}

/* ===== SCREEN 2: LABELS ===== */
.labels-form {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
}

.labels-section {
    margin-bottom: 24px;
}

.labels-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.label-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.label-index {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(190, 158, 84, 0.15);
    color: #BE9E54;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.label-input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(190, 158, 84, 0.15);
    border-radius: 8px;
    background: rgba(242, 233, 217, 0.04);
    color: #F2E9D9;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.label-input-row input:focus {
    border-color: #BE9E54;
    background: rgba(242, 233, 217, 0.07);
}

.label-input-row input::placeholder {
    color: rgba(242, 233, 217, 0.25);
}

.nav-buttons {
    display: flex;
    gap: 10px;
    padding: 16px 0;
    margin-top: auto;
}

.nav-buttons .btn {
    flex: 1;
}

/* ===== SCREEN 3: GRID ===== */
.grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(190, 158, 84, 0.12);
    margin-bottom: 12px;
}

.grid-header h1 {
    font-size: 16px;
    text-align: left;
    letter-spacing: 0.3px;
}

.grid-actions {
    display: flex;
    gap: 6px;
}

.grid-wrapper {
    flex: 1;
    overflow: auto;
    min-height: 0;
    display: flex;
    align-items: stretch;
}

.grid-container {
    display: grid;
    gap: 3px;
    width: 100%;
    /* grid-template-columns set dynamically via JS */
}

/* Corner cell (top-left) */
.grid-corner {
    background: transparent;
}

/* Column header cells */
.grid-col-header {
    background: rgba(190, 158, 84, 0.12);
    color: #BE9E54;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 4px;
    text-align: center;
    border-radius: 6px 6px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Row header cells */
.grid-row-header {
    background: rgba(190, 158, 84, 0.12);
    color: #BE9E54;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 6px 0 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Event buttons */
.grid-cell {
    min-height: 54px;
    border: none;
    border-radius: 6px;
    background: rgba(242, 233, 217, 0.05);
    color: #F2E9D9;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.15s ease;
    border: 1px solid rgba(190, 158, 84, 0.08);
}

.grid-cell:active {
    background: #BE9E54;
    color: #242C39;
}

.grid-cell.flash {
    background: #BE9E54;
    color: #242C39;
    transition: none;
}

.grid-cell .cell-count {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
}

.grid-cell .cell-count.zero {
    color: rgba(242, 233, 217, 0.18);
}

/* ===== FOOTER ===== */
.grid-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 0;
    font-size: 12px;
    color: rgba(242, 233, 217, 0.4);
    flex-shrink: 0;
    border-top: 1px solid rgba(190, 158, 84, 0.12);
    margin-top: 12px;
}

.last-event {
    font-style: italic;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== OVERLAY / MENU ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.2s ease;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: #2d3545;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    border-top: 2px solid rgba(190, 158, 84, 0.3);
}

.overlay-content h2 {
    text-align: center;
    color: #F2E9D9;
    font-size: 18px;
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.overlay-content hr {
    border: none;
    border-top: 1px solid rgba(190, 158, 84, 0.12);
    margin: 10px 0;
}

/* ===== ANIMATIONS ===== */
@keyframes flashCell {
    0% { background: #BE9E54; color: #242C39; }
    100% { background: rgba(242, 233, 217, 0.05); color: #F2E9D9; }
}
