/* css/style.css */
:root {
    --primary-color: #0066cc;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --border-color: #ddd;
    --text-color: #333;
    --input-bg: #f9f9f9;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    padding-bottom: 80px;
    /* Space for sticky footer */
}

h1,
h2,
h3 {
    margin: 0;
    font-weight: 600;
}

.container {
    max-width: 100%;
    margin: 0 auto;
}

/* Header */
.app-header {
    background: var(--card-bg);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    font-size: 1.1rem;
}

.back-link {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.9rem;
}

/* Sections */
.section {
    background: var(--card-bg);
    margin-bottom: 12px;
    padding: 12px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.section-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

/* Form Elements */
.form-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    align-items: center;
}

.form-label {
    flex: 1;
    font-size: 0.95rem;
}

.form-input {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    font-size: 1rem;
}

input[type="date"] {
    width: 140px;
}

select {
    padding: 8px;
    background: white;
}

/* Player columns */
/* Player columns */
.players-grid {
    display: grid;
    /* First col is auto-sized header, rest are player columns */
    grid-template-columns: max-content repeat(var(--player-count, 2), minmax(70px, 1fr));
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.player-col-header {
    text-align: center;
    font-weight: bold;
    margin-bottom: 8px;
}

.player-input-cell {
    margin-bottom: 8px;
}

.player-input-cell input {
    width: 100%;
    text-align: center;
}

.player-input-cell select {
    width: 100%;
}

/* Dense inputs for scoring */
.score-input {
    width: 100%;
    padding: 6px 2px;
    font-size: 1.1rem;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.row-label {
    grid-column: 1;
    position: sticky;
    left: 0;
    z-index: 10;
    background: var(--card-bg);

    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;

    font-size: 0.85rem;
    color: #555;
    font-weight: 500;
    text-align: right;
    border-right: 1px solid #eee;
    margin: 0;
    margin-bottom: 8px;
    /* match input cell margin */
    border-bottom: none;
    padding-bottom: 0;
}

/* Combo Card Logic */
.combo-card-row {
    margin-bottom: 16px;
    padding: 8px;
    background: #fcfcfc;
    border: 1px solid #eee;
    border-radius: 6px;
}

.combo-select {
    width: 100%;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* Sticky Footer */
.footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 12px 16px;
    border-top: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:active {
    opacity: 0.9;
}

.status-text {
    font-size: 0.8rem;
    color: #666;
}

.btn-secondary {
    background: #e4e6eb;
    color: #333;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Modal / Overlay for complex logic (Ice Dragon) */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.dialog-overlay.active {
    display: flex;
}

.dialog-card {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.dialog-title {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.dialog-actions {
    margin-top: 20px;
    text-align: right;
}

/* Totals Row */
.total-score-display {
    text-align: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: #444;
    background-color: cyan;
    /* User said "cyan-colored". If headers are cyan BG, maybe total should match? */
    /* "Make the final total number a larger font, centered in the cell, and cyan-colored" */
    /* Let's try cyan bg, dark text. Matches the headers request. */
    border-radius: 4px;
    padding: 8px 0;
}

/* Scoring Headers */
.row-label-score {
    background-color: cyan !important;
    color: #000;
    font-weight: 700;
}

/* Stepper Controls */
.stepper-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
}

.btn-stepper {
    background: #e4e6eb;
    border: 1px solid #ccc;
    color: #333;
    width: 24px;
    height: 32px;
    /* Match input height roughly */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: sans-serif;
    /* Ensure unicode minus renders well */
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.btn-stepper:active {
    background: #d0d2d6;
}

.btn-stepper.left {
    border-radius: 4px 0 0 4px;
    border-right: none;
}

.btn-stepper.right {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.score-input.stepper-input {
    border-radius: 0;
    text-align: center;
    flex: 1;
    min-width: 0;
    /* Allow shrinking */
}

/* Rich Input Display */
.input-display-container {
    flex: 1;
    position: relative;
    height: 32px;
    /* Match stepper height */
    background: #f9f9f9;
    border-top: 1px solid #ccc;
    /* Match input borders */
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: text;
    overflow: hidden;
}

.input-display-container input.score-input {
    /* When input is visible, it fills the container */
    width: 100%;
    height: 100%;
    border: none;
    /* Container has border */
    background: transparent;
    padding: 0;
}

.display-view {
    width: 100%;
    text-align: center;
    font-size: 1.1rem;
    line-height: 32px;
    user-select: none;
    pointer-events: none;
    /* Let clicks pass to container */
}

.mult-prefix {
    font-size: 0.7em;
    /* 70% size */
    color: #666;
    margin-right: 1px;
    vertical-align: 1px;
    /* Slight lift */
}

/* Hide helper */
.hidden {
    display: none !important;
}

/* Rounds Stepper */
.rounds-stepper {
    display: flex;
    align-items: center;
}

.rounds-stepper .btn-stepper {
    width: 26px;
    height: 28px;
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
}

.rounds-stepper .rounds-input {
    width: 38px;
    height: 28px;
    padding: 2px;
    text-align: center;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    margin: 0;
    font-size: 0.95rem;
    background: var(--input-bg);
}

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

.rounds-stepper input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}