@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Rajdhani:wght@300;400;500;600&display=swap');

/* ── CSS Variables (Google-style palette) ───────────────────────── */
:root {
    --bg: #ffffff;
    --surface: #f8f9fa;
    --card: #ffffff;
    --border: #dadce0;
    --border2: #e8eaed;
    --blue: #4285F4;
    --blue-light: #e8f0fe;
    --green: #34A853;
    --green-light: #e6f4ea;
    --red: #EA4335;
    --red-light: #fce8e6;
    --yellow: #FBBC05;
    --text: #202124;
    --text-dim: #5f6368;
    --text-faint: #80868b;
    --s1: #4285F4;
    --s2: #34A853;
    --s3: #EA4335;
    --s4: #FBBC05;
    --s5: #4285F4;
    --s6: #34A853;
    --s7: #EA4335;
    --s8: #FBBC05;
    --gold: var(--blue);
}

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

html {
    font-size: 15px;
}

body {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f4fc 25%, #fef9f0 50%, #f5f0ff 75%, #f0fff4 100%);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    font-weight: 400;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Background texture ─────────────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(66, 133, 244, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(234, 67, 53, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 50% 35% at 10% 90%, rgba(52, 168, 83, 0.08) 0%, transparent 45%),
        radial-gradient(ellipse 40% 30% at 95% 20%, rgba(251, 188, 5, 0.07) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* ── Layout ─────────────────────────────────────────────────────── */
.app {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* ── Header ─────────────────────────────────────────────────────── */
.header {
    text-align: center;
    padding: 28px 0 20px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(232, 240, 254, 0.8) 50%, rgba(230, 244, 234, 0.6) 100%);
    border-radius: 12px;
    padding: 24px 20px;
    border: 1px solid rgba(66, 133, 244, 0.2);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.1);
}

.header-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #4285F4, #34A853);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-sub {
    font-size: 0.78rem;
    letter-spacing: 0.3em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-top: 4px;
}

/* ── Card ────────────────────────────────────────────────────────── */
.card {
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 14px;
}

.card:nth-child(4) { border-left-color: var(--green); }
.card:nth-child(5) { border-left-color: var(--red); box-shadow: 0 2px 8px rgba(234, 67, 53, 0.06); }
.card:nth-child(6) { border-left-color: var(--yellow); box-shadow: 0 2px 8px rgba(251, 188, 5, 0.08); }
.card:nth-child(7) { border-left-color: #9b59b6; box-shadow: 0 2px 8px rgba(155, 89, 182, 0.08); }
.card:nth-child(8) { border-left-color: #e67e22; box-shadow: 0 2px 8px rgba(230, 126, 34, 0.06); }
.card:nth-child(9) { border-left-color: var(--green); }

.card-title {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    background: linear-gradient(90deg, var(--blue), var(--text-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--border2), transparent);
}

/* ── Table Type Selector ─────────────────────────────────────────── */
.table-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-btn {
    flex: 1;
    min-width: 110px;
    padding: 10px 8px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text-dim);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.table-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.table-btn.active {
    background: linear-gradient(135deg, #e8f0fe 0%, #d2e3fc 100%);
    border-color: var(--blue);
    color: var(--blue);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.35), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* ── Rotation control ────────────────────────────────────────────── */
.rotation-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.rotation-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.rotation-input {
    width: 60px;
    padding: 5px 8px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--blue);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
}

.rotation-input:focus {
    outline: none;
    border-color: var(--blue);
}

/* ── Number Grid ─────────────────────────────────────────────────── */
.number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 5px;
}

.num-btn {
    aspect-ratio: 1;
    border-radius: 4px;
    border: 1px solid transparent;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.num-btn.red {
    background: linear-gradient(180deg, #fce8e6 0%, #fad2d0 100%);
    color: var(--red);
    border-color: rgba(234, 67, 53, 0.5);
    box-shadow: 0 2px 4px rgba(234, 67, 53, 0.2);
}

.num-btn.black {
    background: linear-gradient(180deg, #e8eaed 0%, #dadce0 100%);
    color: #1a1a2e;
    border-color: var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.num-btn.green {
    background: linear-gradient(180deg, #e6f4ea 0%, #ceead6 100%);
    color: var(--green);
    border-color: rgba(52, 168, 83, 0.5);
    box-shadow: 0 2px 4px rgba(52, 168, 83, 0.2);
}

.num-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.5);
    z-index: 2;
}

.num-btn:active {
    transform: translateY(0);
}

.num-btn .sdot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    opacity: 0.8;
}

/* ── Spin History ────────────────────────────────────────────────── */
.history-scroll {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 6px;
    min-height: 64px;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

.history-empty {
    color: var(--text-faint);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    align-self: center;
    padding: 8px 0;
}

.spin-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.spin-chip {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.spin-chip.red {
    background: linear-gradient(135deg, #fce8e6 0%, #f5c6c3 100%);
    color: var(--red);
    border-color: var(--red);
    box-shadow: 0 2px 6px rgba(234, 67, 53, 0.25);
}

.spin-chip.black {
    background: linear-gradient(135deg, #e8eaed 0%, #d1d5db 100%);
    color: #1a1a2e;
    border-color: #9ca3af;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.spin-chip.green {
    background: linear-gradient(135deg, #e6f4ea 0%, #b8e6c8 100%);
    color: var(--green);
    border-color: var(--green);
    box-shadow: 0 2px 6px rgba(52, 168, 83, 0.25);
}

.spin-stag {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 1px 4px;
    border-radius: 2px;
    background: var(--surface);
}

.spin-arrow {
    align-self: center;
    color: var(--text-faint);
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: -18px;
}

.arc-pill {
    font-size: 0.58rem;
    padding: 2px 5px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: center;
    margin-top: -18px;
}

.arc-pill.match {
    background: var(--green-light);
    border-color: var(--green);
    color: var(--green);
}

.arc-pill.miss {
    background: var(--red-light);
    border-color: var(--red);
    color: var(--red);
}

.arc-pill.outlier {
    background: rgba(251, 188, 5, 0.15);
    border-color: var(--yellow);
    color: #b8860b;
    text-decoration: line-through;
    opacity: 0.7;
}

/* ── Control buttons ─────────────────────────────────────────────── */
.ctrl-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.ctrl-btn {
    padding: 7px 16px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--text-dim);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s;
}

.ctrl-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: linear-gradient(135deg, #e8f0fe 0%, #d2e3fc 100%);
    box-shadow: 0 2px 6px rgba(66, 133, 244, 0.2);
}

.spin-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-dim);
    align-self: center;
}

/* ── Sector Legend ───────────────────────────────────────────────── */
.sector-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 6px;
}

.legend-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.legend-header {
    padding: 4px 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.legend-nums {
    padding: 5px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.legend-num {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 2px;
}

.legend-num.red {
    background: var(--red-light);
    color: var(--red);
}

.legend-num.black {
    background: var(--surface);
    color: var(--text);
}

.legend-num.green {
    background: var(--green-light);
    color: var(--green);
}

/* ── Transition Matrix ───────────────────────────────────────────── */
.matrix-wrap {
    overflow-x: auto;
}

.matrix-table {
    border-collapse: collapse;
    font-size: 0.72rem;
    min-width: 100%;
}

.matrix-table th {
    font-family: 'Cinzel', serif;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    padding: 6px 8px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
}

.matrix-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    position: relative;
}

.matrix-table tr:hover td {
    background: var(--surface);
}

.matrix-cell-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    opacity: 0.12;
    border-radius: 0 3px 3px 0;
    transition: width 0.4s ease;
}

.matrix-from {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    font-weight: 600;
}

.matrix-to {
    font-size: 0.68rem;
    font-weight: 600;
}

.matrix-pct {
    font-size: 0.7rem;
    font-weight: 600;
}

.matrix-cnt {
    font-size: 0.6rem;
    color: var(--text-dim);
}

.no-data-row {
    color: var(--text-faint);
    font-size: 0.78rem;
    padding: 16px 0;
    text-align: center;
}

/* ── Prediction Panel ────────────────────────────────────────────── */
.prediction-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 560px) {
    .prediction-panel {
        grid-template-columns: 1fr;
    }
}

.pred-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 12px;
}

.pred-block-title {
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.pred-sector-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid;
    margin-bottom: 10px;
}

.pred-sector-name {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.pred-confidence {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.pred-confidence strong {
    color: var(--blue);
}

.pred-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.pred-num-chip {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.78rem;
    font-weight: 700;
}

.pred-num-chip.red {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid rgba(234, 67, 53, 0.4);
}

.pred-num-chip.black {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.pred-num-chip.green {
    background: var(--green-light);
    color: var(--green);
    border: 1px solid rgba(52, 168, 83, 0.4);
}

/* Confidence bars */
.conf-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.conf-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conf-label {
    font-family: 'Cinzel', serif;
    font-size: 0.62rem;
    font-weight: 600;
    width: 28px;
    flex-shrink: 0;
}

.conf-bar-bg {
    flex: 1;
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
}

.conf-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(.4, 0, .2, 1);
}

.conf-pct {
    font-size: 0.68rem;
    font-weight: 600;
    width: 34px;
    text-align: right;
    flex-shrink: 0;
}

.conf-cnt {
    font-size: 0.58rem;
    color: var(--text-dim);
    width: 28px;
    flex-shrink: 0;
}

/* ── Wheel Strip ─────────────────────────────────────────────────── */
.wheel-strip {
    display: flex;
    height: 18px;
    border-radius: 9px;
    overflow: hidden;
    gap: 1px;
    margin-top: 12px;
    border: 1px solid var(--border);
}

.ws-slot {
    flex: 1;
    height: 100%;
    transition: opacity 0.3s;
    position: relative;
}

.ws-slot.predicted::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--blue);
}

/* ── Arc Panel ───────────────────────────────────────────────────── */
.arc-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.arc-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
}

.arc-stat-label {
    font-size: 0.62rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    margin-bottom: 3px;
}

.arc-stat-val {
    font-size: 1rem;
    font-weight: 600;
    color: var(--blue);
    font-family: 'Cinzel', serif;
}

/* ── Status strip ────────────────────────────────────────────────── */
.status-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f8f9fa 0%, #eef2f7 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--blue);
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.status-text {
    color: var(--text);
}

.status-sub {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 0.7rem;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 2px;
}

/* ── Fade-in animation ───────────────────────────────────────────── */
.card {
    animation: fadeUp 0.4s ease both;
}

.card:nth-child(1) {
    animation-delay: 0.05s;
}

.card:nth-child(2) {
    animation-delay: 0.1s;
}

.card:nth-child(3) {
    animation-delay: 0.15s;
}

.card:nth-child(4) {
    animation-delay: 0.2s;
}

.card:nth-child(5) {
    animation-delay: 0.25s;
}

.card:nth-child(6) {
    animation-delay: 0.3s;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
