:root {
    /* Light theme (default) */
    --bg-primary: #fff9ee;
    --bg-secondary: #fef4e2;
    --text-primary: #2c2416;
    --text-secondary: #6b6158;
    --border-color: #e8dcd0;
    --color-text: #cb6d00;
    --link-text: #d97706;
    --link-text-2: rgb(187, 103, 6);
    --link-bg: #fef3e2;
    --link-hover-text: #ffffff;
    --link-hover-bg: #d97706;
    --visited-color: #8b5cf6;
    --visited-bg: #f3e8ff;
    --easy-color: #22c55e;
    --medium-color: #f59e0b;
    --tricky-color: #eab308;
    --hard-color: #ef4444;
    --evil-color: #a855f7;
    --row-color-1: #fff9ee;
    --row-color-2: #f9e9ca;
    --color-positive: #22c55e;
    --color-positive-bg: #22c55e63;
    --color-pending: #c69400;
    --link: rgb(78, 145, 181);
    --link-visited: rgb(129, 69, 185);
}

html[data-theme="dark"] {
    /* Dark theme */
    --bg-primary: #0d1117;
    --bg-secondary: rgb(31, 38, 47);
    --text-primary: #c9d1d9;
    --text-secondary: #c4c7cb;
    --border-color: #30363d;
    --color-text: #58a6ff;
    --link-text: #58a6ff;
    --link-text-2: rgb(151, 196, 248);
    --link-bg: rgba(88, 166, 255, 0.1);
    --link-hover-text: #0d1117;
    --link-hover-bg: #79c1ff;
    --visited-color: #d291ff;
    --visited-bg: #b56aea;
    --easy-color: #3fb950;
    --medium-color: #fb8500;
    --tricky-color: #d29922;
    --hard-color: #ff7b72;
    --evil-color: #d291ff;
    --row-color-1: #0d1117;
    --row-color-2: #1d2737;
    --color-positive: #22c55e;
    --color-pending: #ffe607;
    --link: rgb(78, 159, 181);
    --link-visited: rgb(129, 69, 185);
}

* {
    box-sizing: border-box;
}

body {
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

h2 {
    font-size: 18px;
}

.auth div.error {
    border-radius: 5px;
    border: 1px solid red;
    color: red;
    max-width: 400px;
    margin: 5px auto;
}

div.auth,
div.activate {
    padding: 0px 40px;
    margin: 30px auto;
    max-width: 600px;
    text-align: center;
}

div.activate {
    margin: 150px auto 0px;
    text-align: center;
    padding: 30px;
}

div.activate form button {
    margin: auto;
}

div.auth form {
    max-width: 400px;
    margin: auto;
    text-align: left;
    margin-bottom: 30px;
}

form div {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

form label {
    font-size: 14px;
    font-weight: 600;
}

form input:not([type="checkbox"]) {
    padding: 10px 12px;
    width: 100%;
    font-size: 16px;
}

div.auth label {
    display: inline-block;
}

div.auth input {
    display: inline-block;
}

.auth div.error p {
    margin: 5px;
}

div.content {
    padding: 0px 20px 20px 20px;
    margin: auto;
    text-align: center;
}

div.content-2 {
    max-width: 520px;
    margin: 15px auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0px 20px 20px 20px;
    text-align: center;
}

div.top {
    display: flex;
    justify-content: space-between;
    align-content: center;
    background-color: var(--bg-primary);
    padding: 20px 20px;
    align-items: center;
}

div.top .buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

button {
    justify-content: center;
}

button,
table a,
.completed-button,
a.button-link {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--link-text);
    background-color: var(--link-bg);
    color: var(--link-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    opacity: 0.92;
}

table a {
    justify-content: flex-start;
}

button:not(:disabled):hover,
button:focus,
table a:hover,
table a:focus,
a.button-link:hover:not(.coming-soon) {
    background-color: var(--link-hover-bg);
    color: var(--link-hover-text);
    border-color: var(--link-hover-bg);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    outline: none;
}

table {
    margin: 2px 0px;
    font-family: monospace;
    border-collapse: collapse;
}

.stats {
    margin: 10px 0px 0px 0px;
}

[hidden] {
    display: none !important;
}

.stats table tr {
    display: block;
    float: left;
}

.stats th,
.stats td {
    display: block;
}

th {
    width: 100px;
    padding: 0px 2px;
}

th,
td {
    box-sizing: content-box;
    text-align: left;
    border: none;
    padding: 2px 20px 2px 2px;
}

tr {
    margin: 5px 0px;
    border: none;
}

tr.odd {
    background-color: var(--row-color-1);
}

tr.even {
    background-color: var(--row-color-2);
}

a.logo {
    height: 40px;
}

a.logo img {
    width: 40px;
    height: 40px;
}

img.logo {
    width: 100px;
    height: 100px;
}

div.puzzle-entry,
.puzzle-packs .pack,
.puzzle-group-header {
    display: flex;
    flex-direction: column;
    padding: 10px 10px 10px 10px;
    align-items: left;

    border-radius: 6px;
    border: 1px solid var(--link-text);
    background-color: var(--link-bg);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: left;
    opacity: 0.92;
}

div.puzzle-entry .row {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 0px;
}

div.puzzle-entry .col {
    width: 100%;
}

h5 {
    margin: 5px 0px;
}

div.puzzle-entry .check {
    width: 17px;
    height: 16px;
    margin: 15px 20px 5px 10px;
}

div.puzzle-entry .check.empty {
    border: 1px solid var(--link-text);
    border-radius: 2px;
    opacity: 0.8;
}

div.puzzle-entry div.col > div.row *:nth-child(1) {
    flex: 0 0 40%;
}

div.puzzle-entry div.col > div.row *:nth-child(2) {
    flex: 0 0 60%;
}

p.result {
    text-align: center;
    min-width: 100px;
}

div.puzzle-entry p {
    margin: 0px;
    line-height: 1.5;
}

div.puzzle-entry .date {
    font-weight: bold;
    color: var(--link-text-2);
}

form.link {
    margin: 40px auto;
    max-width: 520px;
    border: dotted 1px var(--link-text);
    padding: 20px;
    border-radius: 6px;
}

form.link button {
    margin: auto;
}

div.archive {
    max-width: 520px;
    margin: 15px auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

span.title {
    font-size: 90%;
    opacity: 0.8;
    margin-right: 5px;
}

.expand-stats {
    cursor: pointer;
}

.my-percentile {
    font-weight: bold;
    text-decoration: underline;
}

.share-grid {
    display: flex;
    flex-direction: column;
    margin-top: 0px;
    margin-bottom: 0px;
    margin-right: 10px;
    filter: drop-shadow(0px 0px 2px var(--shadow-color));
    /* border: 1px solid var(--link-text); */
    border-radius: 2px;
    padding: 1px;
}

.share-grid-row {
    display: flex;
    padding: 0px;
    margin: 0px;
    height: fit-content;
    line-height: 0px;
}

.share-grid-element {
    display: inline-block;
    width: 8px;
    height: 8px;
    padding: 0px;
    margin: 0.5px;
    border-radius: 1px;
    background-color: #a7a7a7;
}

.share-grid-element.correct {
    background-color: #5ac110;
    opacity: 1;
}

.share-grid-element.in-progress {
    opacity: 0.7;
}

.share-grid-element.missing {
    opacity: 0.5;
}
.share-grid-element.empty {
    opacity: 0;
}

.share-grid-element.error {
    background-color: #ffee00;
    border: 1px solid #5ac110;
    border-radius: 0px;
}

.share-grid-element.first-hint {
    background-color: #ffee00;
    border-radius: 100%;
    border: 1px solid #f89d15;
}

.share-grid-element.second-hint {
    background-color: #f89315;
    border-radius: 100%;
}

span.unsolved {
    font-weight: normal;
    font-style: italic;
}

div.puzzle-packs {
    max-width: 520px;
    margin: 15px auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.puzzle-packs .pack {
    display: flex;
    flex-direction: column;
    padding: 20px 10px;
    align-items: center;

    border-radius: 6px;
    border: 1px solid var(--link-text);
    background-color: var(--link-bg);
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: left;
    opacity: 0.92;
}

.puzzle-packs .pack a {
    text-decoration: none;
}

.puzzle-packs .pack h2 {
    margin-top: 0px;
}

.puzzle-packs .pack p {
    margin-top: 0px;
    font-size: 16px;
    text-align: center;
}

div.success {
    border-radius: 5px;
    border: 1px solid var(--color-positive);
    color: var(--color-positive);
    max-width: 400px;
    margin: 5px auto;
    padding: 0px 15px;
}

div.pending {
    border-radius: 5px;
    border: 1px solid var(--color-pending);
    color: var(--color-pending);
    max-width: 400px;
    margin: 5px auto;
    padding: 0px 15px;
}

nav.navigation {
    text-align: center;
    margin: 5px auto 20px auto;
}

nav.navigation a {
    color: var(--color-text);
    margin: 5px;
}

div.puzzle-group-header {
    margin-top: 20px;
    padding: 10px 10px 10px 25px;
    flex-direction: row;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.puzzle-group-header h3 {
    user-select: none;
    -webkit-user-select: none; /* Safari */
}

.completion-calendar {
    width: 100px;
    line-height: 0px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.completion-calendar .share-grid-element {
    width: 9px;
    height: 9px;
}

.puzzle-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left:10px;
}

.puzzle-group-header .arrow {
    padding: 0px 20px 0px 0px;
}

.arrow {
    font-family: monospace;
}

div.box {
    margin: 10px auto;
    max-width: 520px;
    border: dotted 1px var(--link-text);
    padding: 20px;
    border-radius: 6px;
}

div.box-2 {
    margin: 10px auto;
    max-width: 520px;
    min-width: 350px;
    border: solid 1px var(--link-text);
    padding: 20px;
    border-radius: 6px;
}

div.box button,
div.box-2 button {
    margin: 10px auto;
    font-size: 16px;
}

.completed-button {
    margin: 10px auto;
    font-size: 16px;
    display: inline-block;
    border: 1px solid var(--color-positive);
    background-color: var(--link-bg);
    color: var(--color-positive);
}

.completed-button:visited {
    color: var(--color-positive);
}

.completed-button:hover {
    background-color: var(--color-positive-bg);
}

select {
    /* Reset default styles */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* Basic styling */
    padding: 5px 30px 5px 12px;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    background-color: #fff;

    /* Border */
    border: 1px solid #ccc;
    border-radius: 6px;

    /* Remove default outline inconsistencies */
    outline: none;

    /* Custom arrow using background */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg viewBox='0 0 20 20' fill='%23666' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7l5 5 5-5H5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;

    /* Prevent text overlap with arrow */
    background-origin: border-box;
}

/* Optional: focus state */
form.purchase select:focus {
    border-color: #888;
}

/* Optional: disabled state */
form.purchase select:disabled {
    background-color: #f5f5f5;
    color: #999;
}

button:disabled {
    opacity: 0.5;
    cursor: default;
}

div.footer {
    margin: auto;
    margin-top: 30px;
    text-align: center;
}

a {
    color: var(--link);
}

a:visited {
    color: var(--link-visited);
}

a:has(button) {
    text-decoration: none;
}

span.date {
    white-space: nowrap;
    font-weight: bold;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    row-gap: 5px;
    column-gap: 5px;
    justify-content: center;
}

.button-group a.button-link {
    margin: 10px 1px;
    flex: 1 0 auto;
    max-width: 180px;
}

.button-group a button {
    display: inline-flex; /* or flex */
}

.button-group a button {
    display: block;
}

a.button-link {
    color: var(--link-text);
    font-size: 16px;
    margin: 10px auto;
    line-height: normal;
    text-align: center;
    justify-content: center;
    width: fit-content;
    position: relative;
}

:target {
    scroll-margin-top: 200px;
}

a.button-link.coming-soon {
    cursor: default;
    opacity: 0.5;
}

a.button-link.coming-soon::after {
    content: "Coming Soon";
    position: absolute;
    top: 0px;
    font-size: 12px;
    word-wrap: none;
    width: fit-content;
    transform: translate(0px, -50%) scale(0.7,0.7);
    background-color: var(--link-hover-bg);
    color: var(--link-hover-text);
    border-radius: 15px;
    padding: 3px 10px;
}

.archive-links a.button-link {
    font-size: 14px;
    padding: 0.6rem 8px;
}
