:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --primary: #6d5dfc;
    --primary-dark: #5645e0;
    --accent: #0ea5e9;
    --success: #10b981;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e2e8f0;
    --soft: #f8fafc;
    --shadow: 0 25px 45px rgba(15, 23, 42, 0.08);
    --radius: 18px;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

.page-wrapper {
    max-width: 1180px;
    margin: 0 auto;
    padding: 36px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.page-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.page-header h1 {
    
    font-size: clamp(2rem, 4vw, 3rem);
    letter-spacing: -0.02em;
}

.hero-subtitle {
    color: var(--muted);
    font-size: 1.05rem;
}

.header-actions {
    margin-top: 8px;
    display: flex;
    justify-content: center;
}

.link-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(109, 93, 252, 0.1);
    color: var(--primary);
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card-header {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: -5px;
}

.records-container > .card-header {
    text-align: center;
    align-items: center;
    
}

.card h2 {
    font-size: 1.35rem;
    margin-bottom: 6px;
}

.card-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
}

.solver-form label {
    font-weight: 600;
    color: var(--muted);
}

#board-grid {
    display: grid;
    grid-template-columns: repeat(4, 60px);
    gap: 12px;
    margin: 14px 0 24px;
}

#board-grid input {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-size: 1.4rem;
    text-align: center;
    text-transform: uppercase;
    background: var(--soft);
    font-weight: 600;
    transition: border 0.2s, transform 0.2s, box-shadow 0.2s;
}

#board-grid input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(109, 93, 252, 0.15);
    transform: translateY(-1px);
}

button {
    border: none;
    border-radius: 999px;
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-start;
    box-shadow: 0 20px 30px rgba(109, 93, 252, 0.25);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 25px 35px rgba(109, 93, 252, 0.3);
}

.results-card {
    min-height: 320px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.stat-pill {
    background: var(--soft);
    border-radius: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
    display: block;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.results-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 6px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--soft);
}

.result-item .word {
    font-weight: 600;
    letter-spacing: 0.06em;
}

.result-item .points {
    color: var(--success);
    font-weight: 600;
}

.notice {
    color: var(--muted);
    text-align: center;
    padding: 20px 0;
}

.word-filter {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
}

.word-length-form fieldset {
    border: none;
}

.length-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.length-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--soft);
    cursor: pointer;
    transition: border 0.2s, background 0.2s;
}

.length-checkboxes input {
    accent-color: var(--primary);
}

.length-checkboxes label:hover {
    border-color: var(--primary);
}

.filter-actions {
    margin-top: 18px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.reset-link {
    color: var(--muted);
    font-weight: 600;
}

.reset-link:hover {
    color: var(--primary);
}

.records-container {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 0;
    box-shadow: var(--shadow);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f1f2f9;
}

th, td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

tbody tr:hover {
    background: #f9fafc;
}

.rank {
    font-weight: 700;
    color: var(--primary);
    width: 70px;
    text-align: center;
}

.board-display {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 600;
    letter-spacing: 0.12em;
    font-size: 0.95rem;
    color: var(--text);
}

.score {
    font-weight: 700;
    color: var(--accent);
    text-align: right;
}

.records-info {
    margin: 0;
    padding: 18px;
    text-align: center;
    color: var(--muted);
    font-weight: 500;
}

.no-records {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 1rem;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-link {
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
}

.pagination-link:hover:not(.disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-link.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.page-info {
    font-weight: 600;
    color: var(--muted);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.05);
    text-decoration: none;
    font-weight: 600;
    color: var(--text);
}

.back-link:hover {
    background: rgba(15, 23, 42, 0.1);
}

@media (max-width: 600px) {
    #board-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    #board-grid input {
        width: 100%;
    }

    .card {
        padding: 18px;
    }
}