/* =========================================================================
   WW2 Dashboard
   ========================================================================= */

/* Override global overflow:hidden on html,body (style.css:58-61) */
html, body.ww2-page {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
}

.ww2-dashboard {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 120px;
}

/* Header — full-width band breaking out of .ww2-dashboard container */
.ww2-header {
    text-align: center;
    padding: 32px 16px 24px;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-top: -16px;
    margin-bottom: 24px;
    background: var(--color-primary-light);
}

.ww2-header__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--color-primary-light);
    color: var(--color-primary);
    margin-bottom: 12px;
}

.ww2-header__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

/* Sections */
.ww2-section {
    margin-bottom: 36px;
}

.ww2-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ww2-section__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

/* =========================================================================
   Dice Cards Grid
   ========================================================================= */
.ww2-dice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 120px);
    justify-content: center;
    gap: 12px;
}

.ww2-dice-card {
    width: 120px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.ww2-dice-card--selectable {
    cursor: pointer;
    position: relative;
}

.ww2-dice-card__add-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(124, 58, 237, 0.75);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.ww2-dice-card__add-overlay svg {
    width: 32px;
    height: 32px;
    color: white;
}

.ww2-dice-card--selectable:hover .ww2-dice-card__add-overlay {
    opacity: 1;
}

.ww2-dice-card:hover {
    box-shadow: var(--shadow-card);
    transform: translateY(-2px);
}

.ww2-dice-card--selectable:hover {
    border-color: var(--color-primary-medium);
}

.ww2-dice-card--added {
    animation: ww2-cardPulse 0.4s ease-out;
}

@keyframes ww2-cardPulse {
    0% { transform: scale(1); box-shadow: none; }
    30% { transform: scale(0.92); box-shadow: 0 0 0 3px var(--color-primary-medium); }
    100% { transform: scale(1); box-shadow: none; }
}

.ww2-dice-card__preview {
    width: 64px;
    height: 64px;
    margin: 0 auto 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    container-type: inline-size;
    flex-shrink: 0;
    background: white;
}

.ww2-dice-card__name {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

.ww2-dice-card__actions {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: auto;
}

.ww2-dice-card__btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 7px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ww2-dice-card__btn:hover {
    background: var(--color-primary-light);
}

.ww2-dice-card__btn--delete:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--color-danger);
}

/* "Create new die" card */
.ww2-dice-card--create {
    border: 1.5px dashed var(--color-border);
    background: transparent;
    cursor: pointer;
    justify-content: center;
    min-height: 120px;
}

.ww2-dice-card--create:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary-medium);
}

.ww2-dice-card--create .ww2-dice-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
}

.ww2-dice-card--create .ww2-dice-card__label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-primary);
}

/* =========================================================================
   Selection Tray
   ========================================================================= */
.ww2-selection {
    background: var(--color-surface);
    border: 1.5px solid var(--color-primary-medium);
    border-radius: var(--radius-md);
    padding: 12px;
}

.ww2-selection__tray {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 52px;
    align-items: center;
}

.ww2-selection__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    color: var(--color-text-light);
    font-size: 13px;
}

.ww2-selection__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--color-primary-light);
    border-radius: var(--radius-sm);
    font-size: 10px;
    position: relative;
}

.ww2-selection__preview {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
    container-type: inline-size;
    flex-shrink: 0;
    background: white;
}

.ww2-selection__label {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    padding: 3px 8px;
    background: var(--color-text);
    color: white;
    font-weight: 500;
    font-size: 10px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    border-radius: var(--radius-sm);
    z-index: 10;
}

.ww2-selection__item:hover .ww2-selection__label {
    display: block;
}

.ww2-selection__remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-light);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ww2-selection__remove:hover {
    color: white;
    background: var(--color-danger);
    border-color: var(--color-danger);
}

/* =========================================================================
   Players
   ========================================================================= */
.ww2-players {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.ww2-players__controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.ww2-players__field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text);
}

.ww2-players__field input {
    width: 56px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
    font-family: inherit;
    background: var(--color-bg);
    color: var(--color-text);
}

.ww2-players__field input:focus {
    outline: none;
    border-color: var(--color-primary-medium);
    box-shadow: 0 0 0 3px var(--color-primary-bg);
}

/* Player quick-select buttons */
.ww2-player-buttons {
    display: flex;
    gap: 4px;
}

.ww2-player-buttons__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ww2-player-buttons__btn:hover {
    border-color: var(--color-primary-medium);
    background: var(--color-primary-light);
}

.ww2-player-buttons__btn--active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.ww2-player-buttons__btn--active:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

/* Clickable avatar */
.ww2-player-row__avatar--clickable {
    cursor: pointer;
    transition: transform var(--transition-fast);
    border-radius: 50%;
}

.ww2-player-row__avatar--clickable:hover {
    transform: scale(1.2);
    background: var(--color-primary-light);
}

/* Avatar picker popover */
.ww2-avatar-picker {
    position: absolute;
    z-index: 150;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    padding: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.ww2-avatar-picker__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    transition: all var(--transition-fast);
}

.ww2-avatar-picker__item:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary-medium);
}

.ww2-avatar-picker__item--active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

/* Player table */
.ww2-players__table {
    margin-top: 12px;
}

.ww2-players__table:empty {
    margin-top: 0;
}

.ww2-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border);
}

.ww2-player-row:last-child {
    border-bottom: none;
}

.ww2-player-row__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    user-select: none;
}

.ww2-player-row__num {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-light);
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.ww2-player-row__input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: var(--color-text);
}

.ww2-player-row__input:hover {
    background: var(--color-bg);
}

.ww2-player-row__input:focus {
    outline: none;
    border-color: var(--color-primary-medium);
    background: var(--color-bg);
    box-shadow: 0 0 0 2px var(--color-primary-bg);
}

/* =========================================================================
   Roll Button
   ========================================================================= */
.ww2-roll-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(transparent, var(--color-bg) 30%);
    z-index: 100;
    display: flex;
    justify-content: center;
}

.ww2-roll-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg), 0 0 24px rgba(124, 58, 237, 0.3);
}

.ww2-roll-btn:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 32px rgba(124, 58, 237, 0.4);
}

.ww2-roll-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ww2-roll-btn__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
}

/* =========================================================================
   Dialog
   ========================================================================= */
.ww2-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: ww2-fadeIn 0.2s ease-out;
}

.ww2-dialog {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    max-width: 380px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: ww2-scaleIn 0.25s ease-out;
}

.ww2-dialog__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 8px;
}

.ww2-dialog__text {
    font-size: 13px;
    color: var(--color-text-light);
    margin: 0 0 20px;
    line-height: 1.5;
}

.ww2-dialog__buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.ww2-dialog__btn {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid var(--color-border);
    transition: all var(--transition-fast);
}

.ww2-dialog__btn--cancel {
    background: var(--color-surface);
    color: var(--color-text);
}

.ww2-dialog__btn--cancel:hover {
    background: var(--color-bg);
}

.ww2-dialog__btn--primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.ww2-dialog__btn--primary:hover {
    background: var(--color-primary-hover);
}

@keyframes ww2-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ww2-scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 480px) {
    .ww2-dashboard {
        padding: 12px;
        padding-bottom: 100px;
    }

    .ww2-header {
        padding: 20px 12px 16px;
        margin-top: -12px;
        margin-bottom: 16px;
    }

    .ww2-header__title {
        font-size: 20px;
    }

    .ww2-dice-grid {
        grid-template-columns: repeat(auto-fill, 100px);
        gap: 8px;
    }

    .ww2-dice-card {
        width: 100px;
        padding: 8px;
    }

    .ww2-dice-card__preview {
        width: 52px;
        height: 52px;
    }

    .ww2-dice-card__btn svg {
        width: 12px;
        height: 12px;
    }

    .ww2-selection__preview {
        width: 36px;
        height: 36px;
    }

    .ww2-player-buttons {
        flex-wrap: wrap;
    }

    .ww2-player-buttons__btn {
        min-width: 32px;
        height: 28px;
        padding: 0 8px;
        font-size: 12px;
    }

    .ww2-roll-btn {
        padding: 14px 36px;
        font-size: 16px;
    }
}
