:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #333;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --text-muted: #666;
    --accent-gold: #917D54;
    --accent-gold-bright: #c4a86c;
    --accent-blue: #5C6E8E;
    --cell-bg: #2a3441;
    --cell-hover: #354152;
    --cell-revealed: #3a4a5a;
    --border-color: #3a4a5a;
    --success: #4a7c4a;
    --danger: #7c4a4a;

    --cell-size: 64px;
    --cell-gap: 8px;
    --arrow-size: 40px;
}

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

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

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
}

.back-link {
    display: inline-block;
    color: var(--accent-blue);
    text-decoration: none;
    margin-bottom: 12px;
    font-size: 14px;
}

.back-link:hover {
    text-decoration: underline;
}

h1 {
    font-size: 1.6rem;
    color: var(--accent-gold);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Game Section */
.game-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

/* Hint Area */
.hint {
    text-align: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-gold);
}

.hint-step {
    display: inline-block;
    background: var(--accent-gold);
    color: var(--bg-primary);
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 8px;
}

.hint-text {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Game Board - 5 columns x 4 rows */
.game-board {
    display: grid;
    grid-template-columns: var(--arrow-size) var(--cell-size) var(--cell-size) var(--cell-size) var(--arrow-size);
    grid-template-rows: var(--arrow-size) var(--cell-size) var(--cell-size) var(--cell-size);
    gap: var(--cell-gap);
    justify-content: center;
    margin-bottom: 20px;
}

/* Line Buttons */
.line-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
}

.line-btn.row-arrow {
    height: var(--cell-size);
}

.line-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.line-btn.best {
    background: var(--accent-gold);
}

.line-btn.best .arrow,
.line-btn.best .ev-label {
    color: var(--bg-primary);
}

.line-btn .arrow {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1;
}

.line-btn .ev-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: bold;
    min-height: 1em;
}

/* Empty placeholder */
.empty {
    visibility: hidden;
}

/* Grid Cells */
.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--cell-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-muted);
}

.cell:hover {
    background: var(--cell-hover);
    border-color: var(--accent-blue);
}

.cell.revealed {
    background: var(--cell-revealed);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.cell.highlighted {
    box-shadow: 0 0 12px var(--accent-gold);
}

.cell.suggested {
    border-color: var(--accent-blue);
    box-shadow: 0 0 12px var(--accent-blue);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 8px var(--accent-blue); }
    50% { box-shadow: 0 0 16px var(--accent-blue), 0 0 24px rgba(92, 110, 142, 0.4); }
}

/* Reset Button */
.reset-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.reset-btn:hover {
    background: var(--cell-bg);
}

/* Best Choice Section */
.best-choice {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    text-align: center;
    border: 2px solid var(--accent-gold);
}

.best-choice.hidden {
    display: none;
}

.best-choice h2 {
    font-size: 1rem;
    color: var(--accent-gold);
    margin-bottom: 12px;
}

.best-line-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.best-line-ev {
    font-size: 1rem;
    color: var(--accent-gold-bright);
}

/* Reference Section */
.reference-section {
    margin-bottom: 16px;
}

.reward-table-details {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.reward-table-details summary {
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: background-color 0.15s;
}

.reward-table-details summary:hover {
    background: var(--bg-tertiary);
}

.reward-table-details[open] summary {
    border-bottom: 1px solid var(--border-color);
}

.reward-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.reward-table th,
.reward-table td {
    padding: 8px 12px;
    text-align: center;
}

.reward-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
}

.reward-table td {
    border-top: 1px solid var(--border-color);
}

.reward-table .mgp-high {
    color: var(--accent-gold);
    font-weight: bold;
}

.reward-table .mgp-medium {
    color: var(--accent-blue);
    font-weight: 500;
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 16px 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 280px;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.number-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.number-btn {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
    font-weight: bold;
    background: var(--cell-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.number-btn:hover:not(.used) {
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-color: var(--accent-gold);
}

.number-btn.used {
    opacity: 0.25;
    cursor: not-allowed;
}

.modal-actions {
    display: flex;
    gap: 8px;
}

.clear-btn,
.close-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

.clear-btn {
    background: var(--danger);
    color: var(--text-primary);
}

.clear-btn:hover {
    background: #8c5a5a;
}

.close-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.close-btn:hover {
    background: var(--cell-bg);
}

/* Responsive */
@media (max-width: 400px) {
    :root {
        --cell-size: 56px;
        --cell-gap: 6px;
        --arrow-size: 32px;
    }

    .container {
        padding: 12px;
    }

    h1 {
        font-size: 1.4rem;
    }

    .cell {
        font-size: 1.4rem;
        border-radius: 8px;
    }

    .game-section {
        padding: 16px;
    }

    .line-btn .arrow {
        font-size: 0.9rem;
    }

    .line-btn .ev-label {
        font-size: 0.6rem;
    }
}
