:root {
    --background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    --text: #e5e7eb;
    --muted: #9ca3af;
    --primary: #7c3aed;
    --success: #22c55e;
    --danger: #ef4444;
    --card: rgba(31, 41, 55, 0.5); /* Darker, more translucent card */
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --ring: rgba(124, 58, 237, .55);
    --bg-color: #111827;
    --bg-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.08) 1px, transparent 0);
}

body.light-theme {
    --background: #f3f4f6;
    --text: #1f2937; /* Darker text */
    --muted: #6b7280;
    --card: #ffffff; /* Solid white cards */
    --border: #e5e7eb;
    --shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    --ring: rgba(124, 58, 237, .4);
    --bg-color: #f9fafb; /* Lighter background */
    --bg-image: none; /* Remove dot pattern for a cleaner look */
}

body.light-theme h1, body.light-theme h2 {
    color: #374151; /* A dark gray instead of pure black */
}

body.light-theme .btn.ghost {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

body.light-theme .btn.ghost:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

body.light-theme .field {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

body.light-theme .table th {
    background-color: #f9fafb;
}

body.light-theme .table td {
    background-color: #ffffff;
}

body.light-theme .table tbody tr:hover td {
    background-color: #f3f4f6;
}

body.light-theme .field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

body.light-theme .theme-switcher .slider {
    background-color: #ccc;
}

body {
    background-color: var(--bg-color);
    background-image: var(--bg-image);
    background-size: 20px 20px;
    background-attachment: fixed;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    margin: 0;
    padding: 20px;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 15px;
}

h1, h2 {
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.btn {
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,.35);
    border: none;
    color: var(--text); /* Changed to use var(--text) */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    text-align: center;
}

.btn .material-icons {
    font-size: 20px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0,0,0,.45);
}

.btn:active {
    transform: translateY(0px);
    box-shadow: 0 5px 15px rgba(0,0,0,.3);
}

.btn.primary {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.btn.ok {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.btn.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn.ghost {
    background: rgba(255,255,255,.08);
    border: 1px solid var(--border);
}

body.light-theme .btn.ghost {
    color: var(--text);
}

.field {
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

.field label {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 4px;
}

.field input, .field select {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 16px;
    outline: none;
    width: 100%;
    -webkit-appearance: none; /* for select */
    -moz-appearance: none; /* for select */
    appearance: none; /* for select */
}

.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px; /* make space for arrow */
}

/* Custom styles for pages */
.row {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 24px;
}

.col-md-6 {
    flex: 1;
    min-width: 300px; /* Prevent columns from getting too narrow */
}

.matches-table, .standings-table {
    display: flex;
    flex-direction: column;
}

.table {
    width: 100%;
    border-collapse: separate; /* Changed for border-radius */
    border-spacing: 0;
    margin-top: 20px;
}

.table th, .table td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.5px;
    background-color: rgba(0,0,0,0.1);
}

.table td {
    background-color: rgba(255,255,255,0.02);
}

.table th:first-child {
    border-top-left-radius: 8px;
}
.table th:last-child {
    border-top-right-radius: 8px;
}

.table tr:last-child td:first-child {
    border-bottom-left-radius: 8px;
}
.table tr:last-child td:last-child {
    border-bottom-right-radius: 8px;
}

.table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.05);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.score-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 8px;
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.top-right-button {
    position: fixed; /* Changed to fixed */
    right: 20px;
    top: 20px;
    z-index: 1000;
}

.help-button {
    position: fixed;
    right: 20px;
    top: 20px;
    z-index: 1001; /* Above other buttons */
}

footer {
    border-top: 1px solid var(--border);
    text-align: center;
    margin-top: 40px;
    padding: 20px 0;
}

footer p {
    font-size: 14px;
    color: var(--muted);
    margin: 0;
}

footer .footer-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.module-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.qr-code {
    margin-top: 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 180px; /* Adjusted for better visual */
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.qr-code:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,.45);
    border-color: var(--primary);
}

.qr-code canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.qr-code.full-screen {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.2); /* Slightly larger for full screen */
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.9);
    padding: 20px;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: var(--shadow);
}

.qr-code.full-screen canvas {
    width: 100%;
    height: auto;
}

/* Style for range input */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
    padding: 0; /* remove field padding */
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(124, 58, 237, .8);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(124, 58, 237, .8);
}

/* Score Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    max-width: 500px;
    width: 90%;
}

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

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-header #modalTitle {
    margin-bottom: 8px;
}

.modal-subtitle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text);
}

.modal-subtitle .vs {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

/* Theme Switcher Styles */
.theme-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.theme-switcher .material-icons {
    font-size: 20px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--muted);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Tutorial Styles */
.tutorial-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tutorial-step {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.tutorial-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tutorial-icon .material-icons {
    font-size: 28px;
}

.tutorial-content h3 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--text);
}

.tutorial-content p {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--muted);
}

.tutorial-content ul {
    padding-left: 20px;
    margin-bottom: 12px;
    color: var(--muted);
}

/* Scan Mode Styles */
.scan-mode-container {
    text-align: center;
    margin: 40px 0;
}

#all-qrcodes-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
    height: calc(100% - 80px); /* Adjust based on header height */
}

.qr-code-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
}

.qr-code-item canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.qr-code-item-names {
    margin-top: 10px;
    font-size: 14px;
    color: var(--muted);
}


