/* =====================================================================
   pig.css -- Pig game styles. Every class is prefixed "pig-" and lives
   inside .pig-wrap so nothing collides with sitewide CSS.
   Loaded after includes/head.php (so /stylesheets/style.css is in).
   ===================================================================== */
.pig-header img {
    display: block;
    height: 100px;      /* adjust to taste */
    width: auto;
    margin: 0 auto 4px;
}
.pig-wrap {
    --pig-ink: #111111;          /* site black */
    --pig-muted: #5F6368;
    --pig-pink: #FF3E8E;         /* SimplePig pink */
    --pig-pink-soft: #FFF0F6;
    --pig-line: #E8E8EC;
    --pig-empty: #F1F2F4;
    --pig-bank: #16A34A;         /* game colors: banked = green */
    --pig-bust: #DC2626;         /*              busted = red   */

    max-width: 480px;
    margin: 0 auto;
    padding: 30px 16px 40px;
    color: var(--pig-ink);
    font-family: 'Karla', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-align: center;
    box-sizing: border-box;
}
.pig-wrap *,
.pig-wrap *::before,
.pig-wrap *::after { box-sizing: border-box; }

/* ---- Header ---- */
.pig-header {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
}
.pig-title {
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 40px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--pig-ink);
    text-decoration: none;
}
.pig-title:hover { color: var(--pig-pink); }
.pig-number {
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--pig-muted);
}
.pig-tagline {
    margin: 4px auto 18px;
    font-size: 15px;
    color: var(--pig-muted);
}
.pig-not-ready {
    padding: 60px 20px;
    color: var(--pig-muted);
}

/* ---- Turn slots ---- */
.pig-turns {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
}
.pig-turn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.pig-turn-slot {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    background: var(--pig-empty);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 21px;
    font-weight: 600;
    color: #ffffff;
}
.pig-turn-slot.current { background: #ffffff; box-shadow: inset 0 0 0 2px var(--pig-ink); }
.pig-turn-slot.banked { background: var(--pig-bank); }
.pig-turn-slot.busted { background: var(--pig-bust); font-size: 24px; }
.pig-turn-num {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--pig-muted);
}

/* ---- Play area ---- */
.pig-play-hidden { display: none; }
.pig-turn-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--pig-muted);
    margin-bottom: 12px;
}
.pig-die-stage {
    display: flex;
    justify-content: center;
    padding: 4px 0 18px;
}

/* The die: white with a black outline and offset shadow (site card style) */
.pig-die {
    width: 124px;
    height: 124px;
    padding: 18px;
    border: 3px solid var(--pig-ink);
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 6px 6px 0 var(--pig-ink);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    place-items: center;
    user-select: none;
    -webkit-user-select: none;
}
.pig-pip {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}
.pig-pip.on { background: var(--pig-ink); }
.pig-die-blank {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 54px;
    font-weight: 600;
    color: #D1D5DB;
}
.pig-die-busted {
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: var(--pig-bust);
    background: var(--pig-pink-soft);
    box-shadow: 6px 6px 0 var(--pig-bust);
}
.pig-die-pig { font-size: 66px; line-height: 1; }
.pig-die-rolling { animation: pigTumble 0.28s linear infinite; }
.pig-die-pop { animation: pigPop 0.3s cubic-bezier(.34,1.56,.64,1); }

@keyframes pigTumble {
    0%   { transform: rotate(0deg) translateY(0); }
    25%  { transform: rotate(-9deg) translateY(-4px); }
    75%  { transform: rotate(9deg) translateY(-2px); }
    100% { transform: rotate(0deg) translateY(0); }
}
@keyframes pigPop {
    0% { transform: scale(0.6); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.pig-turn-total {
    font-size: 17px;
    color: var(--pig-muted);
}
.pig-turn-total b {
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 30px;
    font-weight: 600;
    color: var(--pig-ink);
    margin-left: 4px;
}

/* This turn's rolls, small */
.pig-history {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    min-height: 28px;
    margin: 8px auto 0;
    max-width: 360px;
}
.pig-history.faded { opacity: 0.5; }
.pig-mini {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid var(--pig-ink);
    background: #ffffff;
    font-size: 13px;
    font-weight: 700;
    line-height: 22px;
}
.pig-mini.pig { border-color: var(--pig-bust); background: var(--pig-pink-soft); font-size: 14px; }

.pig-msg {
    min-height: 22px;
    margin: 10px 0 14px;
    font-size: 15px;
    font-weight: 700;
    color: var(--pig-muted);
}
.pig-msg-bust { color: var(--pig-bust); }
.pig-msg-bank { color: var(--pig-bank); }
.pig-msg-error { color: var(--pig-bust); }

/* ---- Buttons ---- */
.pig-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}
.pig-btn {
    min-width: 140px;
    padding: 16px 24px;
    border: none;
    border-radius: 999px;
    font-family: 'Karla', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}
.pig-btn:active:not(:disabled) { transform: scale(0.95); }
.pig-btn:focus-visible { outline: 3px solid var(--pig-ink); outline-offset: 3px; }
.pig-btn:disabled { opacity: 0.35; cursor: default; }
.pig-btn-roll { background: var(--pig-pink); }
.pig-btn-roll:hover:not(:disabled) { background: #E62F7C; }
.pig-btn-bank { background: var(--pig-ink); }
.pig-btn-bank:hover:not(:disabled) { background: #333333; }

.pig-total {
    margin-top: 18px;
    font-size: 15px;
    color: var(--pig-muted);
}
.pig-total b { color: var(--pig-ink); font-size: 18px; }

/* ---- End of game ---- */
.pig-end { display: none; }
.pig-end.loading,
.pig-end.error,
.pig-end:not(:empty) { display: block; }
.pig-end.loading { color: var(--pig-muted); padding: 30px 0; }
.pig-end.error { color: var(--pig-bust); font-weight: 700; padding: 20px 0; }
.pig-result-tag {
    display: block;
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 48px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--pig-ink);
}
.pig-end.perfect .pig-result-tag { color: var(--pig-pink); }
.pig-stats-row {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin: 14px 0 6px;
}
.pig-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.pig-stat-circle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 2px solid var(--pig-pink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
}
.pig-stat-label { font-size: 12px; color: var(--pig-muted); }
.pig-perfect-line {
    margin-top: 10px;
    font-size: 16px;
    color: var(--pig-muted);
}
.pig-perfect-line b { color: var(--pig-ink); }

.pig-share-btn {
    display: none;
    margin: 18px auto 26px;
    padding: 14px 36px;
    border-radius: 999px;
    border: none;
    background: var(--pig-pink);
    color: #ffffff;
    font-family: 'Karla', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
}
.pig-share-btn:hover { background: var(--pig-ink); }
.pig-share-btn.visible { display: block; }
.pig-share-confirm {
    display: none;
    margin: -18px 0 20px;
    font-size: 13px;
    font-weight: 700;
    color: var(--pig-bank);
}
.pig-come-back-note {
    display: none;
    margin: 0 0 22px;
    font-size: 14px;
    font-weight: 700;
}
.pig-come-back-note.visible { display: block; }

/* ---- Turn-by-turn breakdown ---- */
.pig-breakdown {
    display: none;
    text-align: left;
    border: 2px solid var(--pig-ink);
    border-radius: 16px;
    padding: 12px 14px 10px;
}
.pig-breakdown.visible { display: block; }
.pig-bd-head {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--pig-muted);
    padding-bottom: 6px;
}
.pig-bd-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--pig-line);
}
.pig-bd-turn {
    flex: 0 0 22px;
    font-weight: 700;
    font-size: 13px;
    color: var(--pig-muted);
}
.pig-bd-dice {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
}
.pig-bd-die {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--pig-ink);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
.pig-bd-die.unseen {
    background: #ffffff;
    color: var(--pig-muted);
    box-shadow: inset 0 0 0 1.5px #C9CBD1;
}
.pig-bd-die.pig { background: var(--pig-bust); font-size: 12px; }
.pig-bd-die.pig.unseen { background: var(--pig-pink-soft); box-shadow: inset 0 0 0 1.5px var(--pig-bust); }
.pig-bd-stop { font-size: 14px; margin: 0 1px; }
.pig-bd-nums {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 15px;
    text-align: right;
}
.pig-bd-you { font-weight: 700; }
.pig-bd-of { color: var(--pig-muted); }
.pig-bd-left {
    display: inline-block;
    min-width: 34px;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--pig-pink-soft);
    color: #C21D66;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.pig-bd-left.ok { background: #E8F6EC; color: var(--pig-bank); }
.pig-bd-left.none { background: var(--pig-empty); color: var(--pig-muted); }
.pig-bd-note {
    padding-top: 8px;
    border-top: 1px solid var(--pig-line);
    font-size: 12px;
    color: var(--pig-muted);
}

/* ---- Stats ---- */
.pig-stats { display: none; margin-top: 22px; }
.pig-stats.visible { display: block; }
.pig-stats-title {
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
.pig-stats-grid {
    display: flex;
    justify-content: center;
    gap: 6px;
}
.pig-stats-item { flex: 1; max-width: 80px; }
.pig-stats-num {
    font-family: 'Fredoka', 'Karla', sans-serif;
    font-size: 26px;
    font-weight: 600;
}
.pig-stats-label { font-size: 11px; color: var(--pig-muted); }

/* ---- FAQ ---- */
.pig-faq { margin: 44px auto 0; text-align: left; }
.pig-faq-q { font-weight: 700; margin: 0 0 4px; }
.pig-faq-a { color: #4b5563; font-size: 14px; line-height: 1.5; margin: 0 0 20px; }

/* ---- Dev-only button (remove before launch) ---- */
.pig-dev-btn {
    display: block;
    margin: 30px auto 0;
    background: #f3f4f6;
    color: var(--pig-muted);
    border: 1px dashed #9ca3af;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}
.pig-dev-btn:hover { background: #e5e7eb; }

@media (max-width: 480px) {
    .pig-wrap { padding: 24px 12px 30px; }
    .pig-turns { gap: 6px; }
    .pig-turn-slot { width: 50px; height: 50px; font-size: 19px; }
    .pig-btn { min-width: 0; flex: 1; max-width: 170px; }
    .pig-stats-row { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .pig-die-rolling, .pig-die-pop, .pig-turn-slot.banked, .pig-turn-slot.busted { animation: none; }
}