/* Pixies Calculator — v0.1.0 */

:root {
    --bg:         #F5F0E8;
    --bg-card:    #FFFFFF;
    --header-bg:  #2C1F3D;
    --header-fg:  #F5F0E8;
    --accent:     #7B4FA6;
    --accent-dk:  #5B2D8E;
    --text:       #2C1810;
    --text-muted: #7A6A60;
    --border:     #D9D0C4;
    --shadow:     0 2px 8px rgba(0,0,0,0.10);

    /* Card game colors */
    --green:  #3A8C4C;
    --blue:   #1A6FA8;
    --yellow: #C49A00;
    --red:    #C0392B;

    --green-bg:  #E8F5EC;
    --blue-bg:   #E3F0FA;
    --yellow-bg: #FFF8DC;
    --red-bg:    #FDECEA;

    --radius: 12px;
    --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Confirm dialog ─────────────────────────────────────── */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.confirm-overlay.active { display: flex; }
.confirm-dialog {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
}
.confirm-dialog__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.confirm-dialog__msg {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}
.confirm-dialog__btns {
    display: flex;
    gap: 10px;
}

/* ─── Header ─────────────────────────────────────────────── */
.app-header {
    background: var(--header-bg);
    color: var(--header-fg);
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-header__inner {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-header__logo {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.app-header__sub {
    font-size: 0.85rem;
    opacity: 0.75;
}
.btn-new-game {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--header-fg);
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.btn-new-game:active { opacity: 0.7; }

/* ─── Main ────────────────────────────────────────────────── */
.app-main {
    flex: 1;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ─── Footer ──────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* ─── Card panels ─────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}
.card__title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--border);  color: var(--text); }
.btn-danger    { background: var(--red);      color: #fff; }
.btn-success   { background: var(--green);    color: #fff; }
.btn-full      { width: 100%; }
.btn-lg        { padding: 16px 24px; font-size: 1.1rem; }
.btn-sm        { padding: 8px 14px; font-size: 0.85rem; }

/* ─── Setup form ──────────────────────────────────────────── */
.setup-intro {
    text-align: center;
    margin-bottom: 24px;
}
.setup-intro h1 {
    font-size: 1.6rem;
    margin-bottom: 6px;
}
.setup-intro p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.player-count-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}
.player-count-btn {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    -webkit-tap-highlight-color: transparent;
}
.player-count-btn.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.player-inputs { display: flex; flex-direction: column; gap: 10px; }

.input-group { display: flex; flex-direction: column; gap: 4px; }
.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.input-group input {
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
}
.input-group.hidden { display: none; }

/* ─── Score wizard ────────────────────────────────────────── */
.wizard-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}
.wizard-progress__dot {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    transition: background .2s;
}
.wizard-progress__dot.done    { background: var(--accent); }
.wizard-progress__dot.current { background: var(--accent); opacity: 0.5; }

.wizard-player-label {
    text-align: center;
    margin-bottom: 20px;
}
.wizard-player-label__name {
    font-size: 1.4rem;
    font-weight: 700;
}
.wizard-player-label__round {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.step { display: none; }
.step.active { display: block; }

.step-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.step-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.4;
}

/* ─── Tap grid ────────────────────────────────────────────── */
.tap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
.tap-btn {
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .1s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
.tap-btn:active {
    transform: scale(0.92);
}
.tap-btn.selected {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.tap-btn.selected:active {
    background: var(--accent-dk);
    border-color: var(--accent-dk);
}

.tap-running {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.tap-running__total {
    font-size: 1.3rem;
    font-weight: 700;
}
.tap-running__label { font-size: 0.8rem; color: var(--text-muted); }

.tap-history {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-height: 22px;
    margin-bottom: 10px;
}

/* ─── Stepper ─────────────────────────────────────────────── */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: 180px;
    margin: 0 auto;
}
.stepper__btn {
    width: 56px;
    height: 56px;
    border: none;
    background: var(--bg);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .1s;
    flex-shrink: 0;
}
.stepper__btn:active { background: var(--border); }
.stepper__val {
    flex: 1;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--bg-card);
    padding: 10px 0;
    min-width: 60px;
}

.stepper-label {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ─── Bonus cards ─────────────────────────────────────────── */
.bonus-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }

.bonus-entry {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    background: var(--bg);
    position: relative;
}
.bonus-entry__remove {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 2px;
}
.bonus-entry__row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.bonus-entry__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 100%;
    margin-bottom: 4px;
}
.bonus-entry__result {
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 700;
    margin-top: 6px;
}

/* Color chips */
.color-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.color-chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid transparent;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all .1s;
    color: #fff;
}
.color-chip[data-color="green"]  { background: var(--green); }
.color-chip[data-color="blue"]   { background: var(--blue); }
.color-chip[data-color="yellow"] { background: var(--yellow); }
.color-chip[data-color="red"]    { background: var(--red); }
.color-chip.selected { outline: 3px solid var(--text); outline-offset: 2px; }

.mini-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.mini-stepper__btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.mini-stepper__btn:active { background: var(--border); }
.mini-stepper__val {
    width: 40px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    background: var(--bg-card);
    padding: 6px 0;
}

/* ─── Round summary ───────────────────────────────────────── */
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}
.summary-row:last-child { border-bottom: none; }
.summary-row__label { color: var(--text-muted); }
.summary-row__val   { font-weight: 700; }
.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0 4px;
    font-size: 1.15rem;
    font-weight: 700;
}

/* ─── Scoreboard ──────────────────────────────────────────── */
.scoreboard { width: 100%; border-collapse: collapse; }
.scoreboard th, .scoreboard td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.scoreboard th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg);
}
.scoreboard td:first-child { text-align: left; font-weight: 600; }
.scoreboard tr.leader td   { color: var(--accent); }
.scoreboard .total-col     { font-weight: 700; }

/* ─── Winner screen ───────────────────────────────────────── */
.winner-banner {
    text-align: center;
    padding: 30px 20px;
}
.winner-banner__trophy { font-size: 4rem; margin-bottom: 10px; }
.winner-banner__name   { font-size: 2rem; font-weight: 700; margin-bottom: 6px; }
.winner-banner__score  { font-size: 1.1rem; color: var(--text-muted); }

/* ─── Nav buttons ─────────────────────────────────────────── */
.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.btn-row .btn { flex: 1; }

/* ─── Edit link in scoreboard ────────────────────────────── */
.edit-link {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}
.edit-link:active { opacity: 0.6; }

/* ─── Utility ─────────────────────────────────────────────── */
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
