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

html, body {
    height: -webkit-fill-available;
    font-family: 'Segoe UI', sans-serif;
}

body {
    min-height: var(--vhpx);
    margin: 0;
    display: grid;
    place-items: center;
    background: white;
    overscroll-behavior: contain;
}

table td,
table th {
    padding: 4px 8px;
}

table ol,
table ul {
    margin-left: 1.2em;
    padding-left: 1.2em;
    list-style-position: outside;
}

ol, ul {
    margin-left: 1.2em;
    padding-left: 1.2em;
    list-style-position: outside;
}


table {
    width: 90%;
}

.rotate-hint {
    position: absolute;
    margin: auto;
    inset: 0;
    place-items: center;
    padding: 2rem;
    text-align: center;
    font: 500 18px system-ui;
    background: rgba(255, 255, 255);
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: block;
}

@media (orientation: landscape) {
    .rotate-hint { display: none; }
}

@media (orientation: portrait) {
    .rotate-hint { display: block; }
}

.application-container {
    width: min(100vw, 1000px);
    aspect-ratio: 4 / 3;
    max-height: min(var(--vhpx), calc(min(100vw, 1000px) * 0.75));
    height: min(var(--vhpx), calc(min(100vw, 1000px) * 0.75));
    background: #fdfaf5;
    box-sizing: border-box;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    position: relative;
}

.login-screen-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.login-screen-card {
    margin: auto;
    background: url('../img/back.png') repeat;
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    width: 90%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.6s ease;
}

.login-screen-card input {
    padding: 0.8rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 0.8rem;
    width: 100%;
}

.login-screen-card input:focus {
    outline: none;
    border-color: #ffe0b2;
    scale: 1.05;
}

.login-screen-card button {
    padding: 0.9rem;
    background: #ffa726;
    color: white;
    font-size: 1.1rem;
    border: none;
    border-radius: 0.8rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.login-screen-card button:hover {
    background: #fb8c00;
}

button.login-screen-card-button-low {
    scale: 0.8;
    background: #d7c09e;
}

.login-screen-remember-link {
    display: block;
    text-align: right;
    font-size: 0.9em;
    margin: 0;
    padding: 0;
    color: #007bff;
    cursor: pointer;
}

.captcha-block { margin: 10px 0; }
.captcha-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.captcha-image { height: 56px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.captcha-controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.loading-overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.loading-overlay-spinner {
    border: 5px solid #eee;
    border-top: 5px solid #ffa726;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}


.authentificated-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: 66px 1fr;
}

.main-menu {
    width: 66px;
    height: 100%;
    background: #ffe0b2;
    border-right: 2px solid #ffa726;
    display: grid;
    grid-template-rows: 120px 1fr 250px;
    align-items: center;
}

.main-menu-top{
    display: grid;
    gap: 10px;
    width: 100%;
    height: 120px;
    padding: 12px;
    justify-items: center;
    vertical-align: top;
}

.main-menu-bottom{
    margin-top: auto;
    display: grid;
    gap: 10px;
    width: 100%;
    justify-items: center;
    vertical-align: bottom;
    padding-bottom: 10px;
}

.main-menu-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-menu-btn img {
    width: 40px;
    height: 40px;
}

.attention {
    animation: pop-in 0.8s ease-out;
}

@keyframes pop-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
    60% {
        transform: scale(1.3);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

.screen-container {
    width: 100%;
    min-height: 0;
    background: url('../img/back.png') repeat;
}

.question-layout {
    width: 100%;
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) 60px;
}

.question-content {
    grid-row: 1;
    overflow-x: hidden;
    overflow-y: auto;
    background: transparent;
    padding: 0.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
    min-height: 0;
}

.question-answer-input-box {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
    font-size: 1.2rem;
    width: 1.3em;
    min-width: 1.3em;
    height: 48px;
    min-height: 48px;
    padding: 2px;
    border: 1px solid #ffa726;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    background: #eee;
    color: black;
    margin-left: 6px;
}

.question-answer-input-box-active {
    border: 2px solid #ffa726;
}

.question-answer-box-holder {
    display: flex;
    width: 100%;
    vertical-align: center;
    align-items: center;
}

.question-answer {
    height: 60px;
    grid-row: 2;
    display: grid;
    grid-template-columns: auto 60px;
    gap: 0.5rem;
    background: #ffe0b2;
    border-top: 1px solid #eee;
}

.question-answer input {
    margin: 6px;
    height: 48px;
    padding: 0.4rem;
    font-size: 1rem;
    border: 2px solid #ffa726;
    border-radius: 0.75rem;
    outline: none;
}

.question-answer button {
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 20%;
    font-size: 1.1rem;
    cursor: pointer;
    margin: auto;
}

.answer-result-card {
    position: absolute;
    left: 50%;
    bottom: 0;

    margin: 0 auto;
    width: 95%;
    max-height: 85%;
    height: auto;

    max-width: 850px;

    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-sizing: border-box;
    border-radius: 6px 6px 0 0;

    background: linear-gradient(180deg, #FDF6EC 0%, #FAEEDD 100%);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
    z-index: 500;

    transform: translate(-50%, 100%);
    opacity: 0;

    transition: transform 0.35s ease, opacity 0.35s ease;
    will-change: transform, opacity;

    overflow: hidden;
}

.answer-result-card.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

.answer-result-card.correct { border-top: 5px solid #22c55e; }
.answer-result-card.incorrect { border-top: 5px solid #ef4444; }

.answer-result-card-explanation {
    overflow-y: scroll;
}

.answer-result-card-line {
    padding: 1vh;
}

.answer-result-card-next-btn-holder {
    display: block;
    width: 44px;
    height: 44px;
    position: absolute;
    top: 8px;
    right: 8px;
}

.answer-result-card-explain-btn-holder {
    width: 100%;
    text-align: right;
    position: absolute;
    bottom: 10px;
    right: 10px;
}

.answer-result-card-explain-btn {
    background: #ffa726;
    border: none;
    color: white;
    height: 32px;
    border-radius: 3px;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 1rem;
}

.answer-result-card-result-body {
    padding: 1vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.answer-result-card-result-header {
    padding: 1vh;
    min-height: 20px;
    box-sizing: border-box;
}

.profile-layout {
    display: grid;
    grid-template-columns: 25% 40% 35%;
    height: 100%;
}

.profile-left {
    align-items: center;
    display: flex;
    justify-content: center;
}

.profile-center {
    align-items: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.profile-right {
    align-items: center;
    display: flex;
    justify-content: center;
}

.profile-awards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 300px;
    height: 100%;
    grid-auto-rows: 1fr;
    padding: 2rem;
}

.profile-award-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.profile-award-icon-locked {
    filter: blur(10px);
}

.profile-avatar img {
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    border: 3px solid #ffc27c;
    margin-bottom: 1rem;
}

.profile-name input {
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    border-radius: 0.8rem;
    border: 2px solid #ffa726;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.profile-link {
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
    font-size: 1.2rem;
}

.profile-link input {
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 1.2rem;
    width: 220px;
}

.profile-link button {
    background: #ffa726;
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 1.2rem;
    cursor: pointer;
}

.profile-link button:hover {
    background: #fb8c00;
}

.profile-logout {
    display: flex;
    flex-direction: column;
    margin-top: 1.5rem;
}

.profile-logout button {
    background: #f70726;
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.profile-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-stat {
    display: flex;
    flex-direction: column;
}

.profile-stat .label {
    display: block;
    text-align: left;
    font-size: 16px;
    font-weight: 600;
    color: #ffa726;
}

.profile-stat .value {
    display: block;
    text-align: right;
    font-weight: 600;
    font-size: 16px;
    color: #555;
}

.popup-simple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 1rem 2rem;
    border: 2px solid #ffa726;
    border-radius: 1rem;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    font-size: 1.2rem;
    z-index: 100;
}

.avatar-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.avatar-modal-overlay-gallery {
    background: #fffefc;
    padding: 1rem;
    border-radius: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, 80px);
    gap: 1rem;
    max-width: 600px;
}

.avatar-modal-overlay-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.2s;
}

.avatar-modal-overlay-avatar:hover {
    border-color: #ffa726;
}

.profile-name-input-wrapper {
    display: flex;
    gap: 0.5rem;
    position: relative;
}

.profile-name-input-wrapper input {
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    border-radius: 0.8rem;
    border: 2px solid #ffa726;
    flex: 1;
}

.profile-name-changed-warning {
    color: red;
    display: block;
}

.profile-save-name-button,
.profile-save-name-button img
{
    border: none;
    cursor: pointer;
    height: 3em;
    width: 3em;
    background: none;
}

.keyboard-overlay {
    position: absolute;
    bottom: 64px;
    right: 4px;
}

table.num-keyboard {
    table-layout: fixed;
    border-collapse: collapse;
    margin: auto;
    font-family: sans-serif;
    font-size: 18px;
    border-spacing: 0;
}

table.num-keyboard td {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #ffa726;
    cursor: pointer;
    user-select: none;

    background: #f9f9f9;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: background 0.2s, transform 0.1s;
}

table.num-keyboard td:hover {
    background: #eee;
}

table.num-keyboard td:active {
    background: #ddd;
    transform: scale(0.95);
}

table.num-keyboard td:empty {
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: default;
}

table.num-keyboard td.wide {
    width: 60px !important;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
}

.modal-content-small {
    background: #ffe0b2;
    border-radius: 12px;
    max-width: 600px;
    min-width: 200px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-content-small-icon {
    max-height: 45vh;
}

.modal-content-small-text {
    text-align: center;
    font-weight: bold;
    padding: 1vh;
}

.modal-content-small-small-text {
    text-align: center;
    font-weight: normal;
    padding: 1vh;
}

.modal-close {
    position: absolute;
    top: 0.15rem;
    right: 1.85rem;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    cursor: pointer;
    color: #444;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.modal-content {
    background: #fdfaf5;
    border: 2px solid #ffc27c;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.leaderboard-layout {
    display: grid;
    grid-template-columns: 66px 1fr;
    width: 100%;
    min-height: 0;
    height: 100%;
}

.leaderboard-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px;
    height: 100%;
}

.leaderboard-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.leaderboard-btn img {
    display: block;
    width: 44px;
}

.leaderboard-btn-chosen {
    scale: 1.05;
}

.leaderboard {
    padding: 10px;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: 28px 1fr;
    box-sizing: border-box;
}

.leaderboard-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}

.leaderboard-rows {
    display: grid;
    grid-template-rows: repeat(10, minmax(0, 1fr));
    overflow: hidden;
    width: 80%;
    margin: 0 auto;
    min-height: 0;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid #ddd;
    transition: transform 0.2s ease;
}

.leaderboard-row:last-child { border-bottom: none; }

.col.pos {
    width: 40px;
    text-align: center;
}

.col.user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.col.score {
    width: 80px;
    text-align: right;
}

.leaderboard-row .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.leaderboard-row.first {
    border-bottom: 2px solid rgb(255, 215, 0);
}

.leaderboard-row.second {
    border-bottom: 2px solid rgb(192, 192, 192);
}

.leaderboard-row.third {
    border-bottom: 2px solid rgb(205, 127, 50);
}

.achievements-screen-layout {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.achievements-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.achievements-table td {
    padding: 0;
    width: 11.1111%;
    height: 33.3333%;
    text-align: center;
    vertical-align: middle;
}

.achievement-cell {
    position: relative;
}

.achievement-cell-float-info {
    position: absolute;
    top: 20%;
    right: 20%;
    font-weight: bolder;
    color: black;
    z-index: 20;
    text-shadow:
            -1px -1px 0 #fff,
            1px -1px 0 #fff,
            -1px  1px 0 #fff,
            1px  1px 0 #fff;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

.icon-stack.highlight {
    animation: pulse 2.0s infinite ease-in-out;
    filter: drop-shadow(0 0 8px #fb8c00);
}

.hidden-sized {
     opacity: 0;
}

.achievement-icon {
    max-height: 90%;
    max-width: 90%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.icon-stack {
    position: relative;
    width: 100%;
    height: 100%;
}

.icon-stack .icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90%;
    max-width: 90%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.icon.list-grayscale {
    filter: grayscale(1);
    z-index: 1;
}

.icon.color-progress {
    z-index: 2;
    mask-image: linear-gradient(to top, black var(--progress), transparent var(--progress));
    -webkit-mask-image: linear-gradient(to top, black var(--progress), transparent var(--progress));
    transition: mask-image 0.3s ease, -webkit-mask-image 0.3s ease;
}

.single-achievement-layout {
    width: 100%;
    height: 100%;
}

.single-achievement-image-scaler {
    max-height: 100vh;
    max-width: 100%;
    display: flex;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.single-achievement-image-wrapper {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
}

.single-achievement-main-image,
.single-achievement-grayscale-layer,
.single-achievement-overlay-mask {
    position: absolute;
    inset: 0;
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.single-achievement-main-image {
    z-index: 0;
}

.single-achievement-grayscale-layer,
.single-achievement-overlay-mask {
    z-index: 1;
    pointer-events: none;
}

.single-achievement-grayscale-layer {
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;

    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
}

.grayscale {
    filter: grayscale(100%);
}

.table-of-contents-layout {
    width: 100%;
    min-height: 0;
    height: 100%;
    overflow-y: scroll;
    margin: auto;
}

.table-of-contents-header {
    width: 100%;
    text-align: center;
    vertical-align: middle;
    padding: 10px;
    color: #ef4444;
    font-weight: bolder;
}

.toc {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.toc-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.toc-section {
    width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    border-color: #ffa726;
    border-style: solid;
    border-width: 2px;
    background: transparent;
    color: #000;
    font-size: 16px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-section:hover {
    border-color: #ff7799;
}

.toc-section-text {
    flex: 1;
    word-wrap: break-word;
    white-space: normal;
}

.toc-section-icon {
    flex: 0 0 auto;
}

.toc-section-icon-image {
    width: auto;
    height: 25px;
}

.toc-sublist {
    list-style: none;
    padding: 8px 0 0 24px;
    margin: 0;
    width: 80%;
}

.toc-sublist-item-inactive {
    display: block;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: transparent;
    transition: background 0.2s;
    border-radius: 8px;
    border: none;
}

.toc-sublist-item-active{
    display: block;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
    border-color: #ffa726;
    border-style: solid;
    border-width: 2px;
}

.welcome-screen {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url('../img/back.png') repeat;
}

.welcome-screen-card {
    padding: 20px 30px;
    border-radius: 12px;
    background: transparent;
    max-width: 600px;
    text-align: center;
    color: #9c4409;
}

.welcome-screen-card h1, p {
    padding-bottom: 20px;
}

.welcome-screen-card button {
    padding: 0.9rem;
    background: #ffa726;
    color: white;
    font-size: 1.1rem;
    border: none;
    border-radius: 0.8rem;
    cursor: pointer;
    transition: background 0.3s ease;
}