:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-hover: #252830;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #666;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --border: #1e2130;
    --green: #4ade80;
    --red: #f87171;
    --amber: #fbbf24;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 16px;
    position: relative;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Super Header ──────────────────────────────────────────────────────── */

.super-header {
    position: absolute;
    top: 16px;
    left: 16px;
    text-decoration: none;
}

.super-logo {
    height: 64px;
    transition: opacity 0.15s;
}

.super-header:hover .super-logo {
    opacity: 0.7;
}

/* ── Header ────────────────────────────────────────────────────────────── */

header {
    text-align: center;
    margin-bottom: 24px;
    padding-top: 72px;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

.info-link {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 8px;
}

.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 4px;
    color: var(--accent);
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.15s;
    vertical-align: middle;
}

.info-btn:hover {
    color: var(--accent-hover);
}

/* ── Calculator Layout ─────────────────────────────────────────────────── */

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.calc-panel,
.results-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
}

/* ── Form Inputs ───────────────────────────────────────────────────────── */

.input-group {
    margin-bottom: 16px;
}

.input-group > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
}

.input-prefix {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-weight: 600;
}

.input-suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-weight: 600;
}

input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-wrapper input {
    padding-left: 28px;
}

.input-wrapper input.has-suffix {
    padding-left: 12px;
    padding-right: 28px;
}

input[type="number"]:focus {
    border-color: var(--accent);
}

input[type="number"]::placeholder {
    color: var(--text-muted);
}

.input-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Radio Buttons (Kelly Fraction) ────────────────────────────────────── */

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.radio-option:hover {
    background: var(--bg-hover);
}

.radio-option.selected {
    border-color: var(--accent);
    background: rgba(96, 165, 250, 0.08);
}

.radio-option input[type="radio"] {
    margin-right: 10px;
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.radio-text {
    font-size: 0.875rem;
}

.radio-label {
    font-weight: 600;
}

.radio-desc {
    color: var(--text-secondary);
}

.radio-option.selected .radio-label {
    color: var(--accent);
}

/* ── Calculate Button ──────────────────────────────────────────────────── */

.calc-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}

.calc-btn:hover {
    background: var(--accent-hover);
}

.calc-btn:active {
    transform: scale(0.98);
}

/* ── Keyboard Shortcut Hint ────────────────────────────────────────────── */

.shortcut-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
}

kbd {
    padding: 2px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.7rem;
}

/* ── Error Box ─────────────────────────────────────────────────────────── */

.error-box {
    margin-top: 16px;
    padding: 12px;
    background: rgba(248, 113, 113, 0.1);
    border-left: 4px solid var(--red);
    border-radius: 6px;
}

.error-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--red);
    margin-bottom: 2px;
}

.error-box p:last-child {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* ── Formula Section ───────────────────────────────────────────────────── */

.formula-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

details summary {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: color 0.15s;
}

details summary:hover {
    color: var(--accent);
}

details[open] summary {
    margin-bottom: 12px;
}

.formula-content {
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.formula-equation {
    font-family: monospace;
    text-align: center;
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--accent);
}

.formula-vars {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.formula-vars p {
    margin-bottom: 2px;
}

.formula-vars .var {
    font-family: monospace;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Clear Data ────────────────────────────────────────────────────────── */

.clear-data {
    margin-top: 16px;
    text-align: center;
}

.clear-data button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
}

.clear-data button:hover {
    color: var(--text-secondary);
}

/* ── Results Panel ─────────────────────────────────────────────────────── */

.results-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.results-card {
    animation: slideIn 0.5s ease-out;
}

/* ── Primary Result ────────────────────────────────────────────────────── */

.primary-result {
    text-align: center;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.result-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-amount {
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.result-percent {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Risk-Level Styling ────────────────────────────────────────────────── */

.bet-safe {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.bet-moderate {
    background: rgba(96, 165, 250, 0.1);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.bet-risky {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.bet-dangerous {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.bet-no-edge {
    background: rgba(102, 102, 102, 0.1);
    border: 1px solid rgba(102, 102, 102, 0.3);
}

/* ── Variants Grid ─────────────────────────────────────────────────────── */

.variants-section {
    margin-bottom: 20px;
}

.variants-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.variants-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.variant {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.variant-highlight {
    border-color: var(--accent);
    background: rgba(96, 165, 250, 0.06);
}

.variant-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.variant-highlight .variant-name {
    color: var(--accent);
    font-weight: 600;
}

.variant-amount {
    font-size: 1.1rem;
    font-weight: 700;
}

.variant-highlight .variant-amount {
    color: var(--accent);
}

.variant-percent {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.variant-highlight .variant-percent {
    color: var(--accent);
}

/* ── Interpretation Box ────────────────────────────────────────────────── */

.interpretation-box {
    padding: 16px;
    border-left: 4px solid var(--border);
    border-radius: 6px;
    margin-bottom: 16px;
}

.interpretation-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.interpretation-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.interpretation-safe {
    border-left-color: var(--green);
    background: rgba(74, 222, 128, 0.05);
}

.interpretation-moderate {
    border-left-color: var(--accent);
    background: rgba(96, 165, 250, 0.05);
}

.interpretation-risky {
    border-left-color: var(--amber);
    background: rgba(251, 191, 36, 0.05);
}

.interpretation-dangerous {
    border-left-color: var(--red);
    background: rgba(248, 113, 113, 0.05);
}

.interpretation-no-edge {
    border-left-color: var(--text-muted);
    background: rgba(102, 102, 102, 0.05);
}

/* ── Warning Box ───────────────────────────────────────────────────────── */

.warning-box {
    padding: 12px;
    border-radius: 8px;
}

.warning-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.warning-text {
    font-size: 0.8rem;
    line-height: 1.5;
}

.warning-moderate {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: var(--amber);
}

.warning-critical {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--red);
}

/* ── Placeholder ───────────────────────────────────────────────────────── */

.placeholder-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9rem;
}

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow-y: auto;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-container {
    display: flex;
    min-height: 100%;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 640px;
    width: 100%;
    padding: 28px;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-body {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.modal-body > * + * {
    margin-top: 16px;
}

.modal-body h4 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-body ol,
.modal-body ul {
    margin-left: 20px;
}

.modal-body li {
    margin-bottom: 4px;
}

.modal-callout {
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
}

.callout-info {
    background: rgba(96, 165, 250, 0.08);
    border-left-color: var(--accent);
}

.callout-info h4 {
    color: var(--accent);
}

.callout-warning {
    background: rgba(251, 191, 36, 0.08);
    border-left-color: var(--amber);
}

.callout-warning h4 {
    color: var(--amber);
}

.check-list {
    list-style: none;
    margin-left: 0;
}

.check-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.check {
    color: var(--green);
    font-weight: 700;
}

.modal-bottom-line {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    font-style: italic;
    font-size: 0.85rem;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.modal-got-it {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.modal-got-it:hover {
    background: var(--accent-hover);
}

/* ── Animations ────────────────────────────────────────────────────────── */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pulse-warning {
    animation: pulse 2s infinite;
}

html {
    scroll-behavior: smooth;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .container {
        padding: 12px 8px;
    }

    header {
        padding-top: 60px;
    }

    header h1 {
        font-size: 1.35rem;
    }

    .calculator-grid {
        grid-template-columns: 1fr;
    }

    .calc-panel,
    .results-panel {
        padding: 20px 16px;
    }

    .result-amount {
        font-size: 2rem;
    }

    .placeholder-card {
        min-height: 200px;
    }

    .super-logo {
        height: 48px;
    }
}
