.tasks .container:has(.submit-task-form),
.tasks .container:has(.attempt) {
    padding-bottom: 0;
}

.tasks .answer-file-label {
    padding: 8px 5px;
    width: calc(100% - 22px);
    background-color: white;
    border-width: 1px;
    border-style: solid;
    font-size: 13px;
    color: #999;
    cursor: pointer;
}
.tasks .answer-file-label + input[type="file"] {
    display: none;
}

.small-comment {
    font-size: 14px;
    line-height: 18px;
}

.api-helpers-popup,
.skip-level-popup,
.white-popup {
    position: relative;
    color: black;
    background: #ffffffee;
    padding: 30px;
    width: auto;
    max-width: 1200px;
    margin: 20px auto;
}
.skip-level-popup {
    max-width: 600px;
}
.checker-output-popup {
    max-width: 800px;
}

@media (max-width: 1365px) {
    .api-helpers-popup {
        max-width: 800px;
    }
}

@media (max-width: 570px) {
    .api-helpers-popup,
    .skip-level-popup,
    .white-popup {
        max-width: 100vw;
    }
}

.white-popup .mfp-close {
    color: rgba(0, 0, 0, 0.8) !important;
    width: 60px;
    height: 60px;
}

.api-helpers-popup h2,
.skip-level-popup h2,
.white-popup h2 {
    margin-top: -5px;
    margin-bottom: 20px;
    margin-left: 0;
}

.white-popup .transparent-button:hover {
    background-color: black;
    color: white;
    border-color: white;
    opacity: initial;
}

.api-helpers-popup > * {
    margin-left: 18px;
}

@media (max-width: 570px) {
    .api-helpers-popup > * {
        margin-left: 0;
    }
}

.api-helpers-popup p.index {
    text-indent: -1em;
}

.api-helpers-popup code {
    overflow-x: scroll;
}

@media (max-width: 570px) {
    .api-helpers-popup code {
        word-break: break-all;
    }
}

.api-helpers-popup pre {
    white-space: pre-wrap;
    overflow-x: scroll;
    font-weight: 300;
}

.api-helpers-popup pre .important {
    font-weight: 700;
}

.api-helpers-popup .curl-request {
    font-weight: 600;
    font-size: 16px;
}
.api-helpers-popup .curl-request:has(+.small-comment) {
    margin-bottom: 0;
}

.api-helpers-popup .small-comment {
    color: #999;
    margin-top: 4px;
    font-weight: 300;
    margin-left: 18px;
    margin-bottom: 14px;
}

@media (max-width: 570px) {
    .api-helpers-popup .small-comment {
        margin-left: 0;
    }
}

.api-helpers-popup .important {
    color: #008247;
}

.api-helpers-popup .important.important-red {
    color: #e4111e;
}

.api-helpers-popup table td {
    width: 50%;
}
.api-helpers-popup table td:first-child {
    width: 30%;
}

@media (max-width: 570px) {
    .api-helpers-popup table td,
    .api-helpers-popup table td:first-child {
        display: block;
        width: 100%;
    }
}

.open-api-helpers-popup-link {
    text-decoration: none;
}

.open-api-helpers-popup-link .text {
    border-bottom: 1px dashed var(--orange);
    padding-bottom: 2px;
}

.open-api-helpers-popup-link .question-mark {
    font-family: IBM Plex Mono, monospace;
    color: black;
    background-color: white;
    width: 20px;
    height: 20px;
    display: inline-block;
    border-radius: 100%;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    margin-left: 8px;
}

.open-api-helpers-popup-link:hover .question-mark {
    background-color: var(--red);
    color: white;
}

.open-api-helpers-popup-link:hover .text {
    border-color: var(--red);
}

.submit-task-form {
    display: flex;
    flex-direction: row;
    position: relative;
    font-size: 16px;
    padding: 20px 0 40px;
}

.submit-task-form > * {
    flex: 1 1 0;
}

@media (max-width: 570px) {
    .submit-task-form {
        display: block;
        flex-direction: column;
        margin-left: 0;
        margin-right: 0;
    }
}

.submit-task-form:has(+ .attempt) {
    padding-bottom: 20px;
}

.submit-task-form h2 {
    color: #fff;
}

.submit-task-form .code-tag {
    color: #6d6d6d;
    position: absolute;
    top: 16px;
    right: 16px
}

.submit-task-form form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 500px;
    max-width: 100%;
}

@media (max-width: 570px) {
    .submit-task-form form > input[type="text"],
    .submit-task-form form > textarea,
    .submit-task-form form > label {
        margin-top: 0;
    }
}

.submit-task-form form label div {
    font-weight: 600;
    margin-bottom: 10px;
}

.submit-task-form form label input + div,
.submit-task-form form label select + div {
    font-weight: 400;
    margin-top: 10px;
    margin-bottom: 0;
}

.submit-task-form form label input + div.error,
.submit-task-form form label select + div.error {
    color: #ff747d;
}

.submit-task-form form input,
.submit-task-form form textarea {
    padding: 8px 10px;
    width: calc(100% - 24px);
    height: 25px;
}

.submit-task-form form textarea {
    height: 100px;
}

.submit-task-form form select {
    padding: 8px 10px;
    width: calc(100% - 24px);
    -webkit-border-radius: 0;
}

/* Fix for mobile Safari browser */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    select {
        -webkit-appearance: menulist-button !important;
        height: 35px !important;
        padding-left: 15px;
        color: black !important;
    }
}

@media (max-width: 570px) {
    .submit-task-form form button {
        font-size: 14px;
    }
}

.submit-task-form form button:hover {
    opacity: 0.6;
}

h2:has(+.level-info) {
    margin-bottom: 0;
}

h2 + .level-info {
    margin-top: -5px;
    margin-bottom: 15px;
}

@media (max-width: 570px) {
    h2 + .level-info {
        margin-top: 5px;
    }
}

.level-info .current-level {
    font-weight: 600;
}

.level-info .levels-count {
    font-weight: 600;
}

/* This and the next one for make clickable area bigger */
.tasks .code-tag {
    top: 45px;
    right: 20px;
    position: absolute;
}

.tasks .code-tag > a {
    display: inline-block;
    padding: 16px;
}

.tasks-page__task .code-tag {
    top: 50px;
    right: 35px;
    position: absolute;
}

@media (max-width: 570px) {
    .tasks-page__task .code-tag {
        top: 37px;
        font-size: 14px;
    }
    .tasks .code-tag {
        top: 20px;
        font-size: 14px;
    }
}

.tasks-page__task .task-description {
    padding-top: 20px;
}

.attempt {
    background-color: #ff42424a;
    color: #ffffff;
    padding: 10px 20px 10px 50px;
    margin-top: 10px;
    margin-left: -50px;
    margin-right: -50px;
}

@media (max-width: 570px) {
    .attempt {
        padding-left: 30px;
        margin-left: -30px;
        margin-right: -30px;
    }
}

.attempt + .attempt {
    margin-top: 0;
}

.attempt:last-child {
    margin-bottom: 40px;
}

.tasks-page__task .attempt:last-child {
    margin-bottom: 0;
}

.attempt.not-checked {
    background-color: rgba(197, 162, 46, 0.29);
}

.attempt.correct {
    background-color: transparent;
}

.attempt + .submit-task-form {
    margin-top: 0;
}

.attempt .score-change {
    font-weight: 600;
    float: right;
    margin-left: 3px;
}

.attempt .score-change img {
    /* https://isotropic.co/tool/hex-color-to-css-filter/ */
    filter: invert(81%) sepia(61%) saturate(1%) hue-rotate(103deg) brightness(116%) contrast(101%);
    width: 15px;
    position: relative;
    top: 2px;
}

.attempt .checker-output-link {
    color: white;
    text-decoration: underline;
    text-decoration-style: dashed;
}

.attempt .checker-output-link:hover,
.attempt .checker-output-link:active {
    text-decoration: none;
}

.checker-output-popup h2:has(+ .attempt-id) {
    margin-bottom: 0;
}
.checker-output-popup h2 + .attempt-id {
    color: #666;
    margin-top: -2px;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 300;
}

.checker-output-popup .checker-output-details {
    font-size: 16px;
    font-family: 'IBM Plex Mono', monospace;
    margin-left: 20px;
}

.checker-output-popup .checker-output-details:not(:has(td)) {
    display: none;
}

.checker-output-popup .checker-output-details td:first-child {
    width: 10px;
    padding-right: 10px;
}

.checker-output-popup .attempt-answer {
    overflow-wrap: break-word;
    white-space-collapse: preserve-breaks;
}

.checker-output-popup .checker-error {
    color: #e03c3c;
}

.checker-output-popup p + p {
    margin-top: 10px;
}

.tasks .scoring {
    text-align: left;
    padding-left: 20px;
    flex: 0.5 1 0;
}

@media (max-width: 570px) {
    .tasks .scoring {
        padding-left: 0;
        padding-top: 20px;
    }
}

.tasks .scoring img,
img.white-coins {
    filter: invert(81%) sepia(61%) saturate(1%) hue-rotate(103deg) brightness(116%) contrast(101%);
    width: 15px;
    position: relative;
    top: 2px;
}

.tasks .scoring > div {
    font-size: 14px;
    line-height: 1.5;
}

.tasks .scoring > div .plus {
    font-weight: 600;
    color: #1de188;
}
.tasks .scoring > div .plus + img {
    filter: invert(89%) sepia(71%) saturate(4820%) hue-rotate(72deg) brightness(94%) contrast(87%);
}

.tasks .scoring > div .minus {
    font-weight: 600;
    color: #f75d67;
}
.tasks .scoring > div .minus + img {
    filter: invert(60%) sepia(79%) saturate(4613%) hue-rotate(324deg) brightness(107%) contrast(94%);
}

.task-description table {
    width: auto;
    text-wrap: pretty;
    margin-top: 16px;
    border-collapse: collapse;
    font-size: 16px;
}

@media (max-width: 570px) {
    .task-description table {
        display: block;
        overflow-x: scroll;
    }
}

.task-description table td,
.task-description table th {
    padding: 3px 10px;
    border: 1px solid white;
}

.task-description table th {
    font-weight: 700;
}

.task-description ol {
    font-size: 18px;
    font-weight: 300;
}

.task-description ol:last-child {
    margin-bottom: 0;
}

@media (max-width: 570px) {
    .task-description ol {
        margin-left: -20px;
    }
}

.task-description blockquote {
    border-left: 4px solid #ccc;
    padding: 10px;
    margin-top: 5px;
    margin-bottom: 5px;
}

@media (max-width: 570px) {
    .task-description blockquote {
        margin-left: 20px;
    }
}

.task-description .hljs-copy-wrapper code {
    font-size: 14px;
}

.task-description a code {
    cursor: pointer;
}

.fully-solved .hide-if-fully-solved {
    display: none;
}

.skip-level-popup-link {
    display: inline-block;
    margin-top: 20px;
    text-decoration: none;
}

.skip-level-form form button {
    width: calc(100%);
    margin-top: 20px;
    color: inherit;
    box-shadow: inset 0 0 0 1px black;
}

@media (max-width: 768px) {
    .skip-level-form form button {
        font-size: 14px;
    }
}

.current-score {
    margin-left: 10px;
    font-weight: 600;
    color: white;
    margin-top: 5px;
}
.current-score img {
    width: 13px;
    filter: invert(99%) sepia(1%) saturate(806%) hue-rotate(230deg) brightness(115%) contrast(100%);
    position: relative;
    top: 2px;
}

.scoreboard table {
    margin: 0;
    width: 100%;
    font-size: 16px;
}
.scoreboard table:not(.full-width) {
    max-width: 800px;
}

@media (max-width: 570px) {
    .scoreboard table {
        margin: 0;
        width: 100%;
    }
}

body:not(.safari) .scoreboard table thead th {
    position: sticky;
    top: 90px;
    background: transparent;
    padding: 0;
}

/* To match the background during scroll */
body:not(.safari) .scoreboard table thead th .sticky-wrapper {
    position: relative;
    display: block;
    padding: 10px;
    height: 45px;
}

body:not(.safari) .scoreboard table thead th .sticky-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("../images/background.png"), linear-gradient(to right, #22433d, #1c3528);
    background-attachment: fixed;
}

.scoreboard table th {
    white-space: nowrap;
}

.scoreboard table td,
.scoreboard table th {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.scoreboard table tr > th:nth-child(4),
.scoreboard table tr > td:nth-child(4) {
    border-left: 1px solid #ccc;
}

.scoreboard table tbody tr.medal-0 {
    background-color: #d4af37;
    color: white;
}

.scoreboard table tbody tr.medal-1 {
    background-color: #c0c0c0;
    color: white;
}

.scoreboard table tbody tr.medal-2 {
    background-color: #cd7f32;
    color: white;
}

.scoreboard tr.current-user {
    font-weight: 800;
}

.scoreboard th {
    vertical-align: top;
}

.scoreboard th img {
    width: 13px;
    position: relative;
    top: 2px;
}

@media (max-width: 570px) {
    .scoreboard th > img {
        display: none;
    }
}

.scoreboard .max-task-score {
    font-size: 12px;
    font-weight: 300;
}

.scoreboard .max-task-score img {
    width: 10px;
    top: 1px;
}

.scoreboard td .current-level {
    font-size: 12px;
}

.scoreboard tr > .score {
    text-align: right;
}

.scoreboard tr > .score .frozen {
    color: #999;
}

.scoreboard .scoreboard-upsolving-message {
    max-width: 800px;
    margin-bottom: 20px;
}

@media (max-width: 570px) {
    .scoreboard .table-wrapper {
        overflow: auto;
        height: 600px;
    }

    body:not(.safari) .scoreboard table thead th {
        top: 0;
        z-index: 3;
    }

    .scoreboard table tr th:nth-child(2),
    .scoreboard table tr td:nth-child(2) {
        position: sticky;
        left: 0;
        padding: 0;
        z-index: 2;
        background: transparent;
    }

    body:not(.safari) .scoreboard table tr th:nth-child(2) {
        z-index: 4;
    }

    .scoreboard table tr th:nth-child(2) .sticky-wrapper,
    .scoreboard table tr td:nth-child(2) .sticky-wrapper {
        display: block;
        padding: 10px 10px 10px 0;
    }

    /* To match the background during scroll */
    .scoreboard table th:nth-child(2) .sticky-wrapper::before,
    .scoreboard table td:nth-child(2) .sticky-wrapper::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background: url("../images/background.png"), linear-gradient(to right, #22433d, #1c3528);
      background-attachment: fixed;
      /*background-repeat: no-repeat;*/
    }

    /*.scoreboard table thead::before {*/
    /*    background-attachment: fixed;*/
    /*}*/

    /* Fix Safari misbehaviour */
    body.safari .scoreboard table th:nth-child(2) .sticky-wrapper::before,
    body.safari .scoreboard table td:nth-child(2) .sticky-wrapper::before {
        top: 0.5px;
        bottom: 0.5px;
    }
}

.scoreboard table a {
    color: white;
}

.scoreboard table a:hover {
    text-decoration: none;
}

@media (min-width: 1220px) {
    section.attempts-table .container {
        width: 100%;
    }
}

section.attempts-table table {
    margin: 10px 0;
    width: 100%;
}

section.attempts-table .attempt {
    border-width: 0;
}

section.attempts-table .attempt td {
    padding: 10px;
}

section.attempts-table .attempt td.score-change {
    width: 50px;
    text-align: right;
}

section.attempts-table .paging-links {
    display: flex;
}
section.attempts-table .paging-links > a {
    flex: 1;
}
section.attempts-table .paging-links .next-page {
    text-align: right;
}

section.attempts-table table a {
    color: inherit;
}

section.attempts-table .attempt.skip {
    background-color: #808080a6;
}
section.attempts-table .attempt.not-counted {
    background-color: #ccc;
}
section.attempts-table .attempt.not-checked {
    background-color: #f79a3d;
    color: black;
}
section.attempts-table .attempt.upsolving {
    opacity: 0.6;
}
section.attempts-table .attempt.upsolving > td:first-child > span {
    font-size: 80%;
}

pre code.hljs {
    background: #f3f3f3;
}

.admin-impersonated-return {
    position: fixed;
    bottom: 0;
    z-index: 0;
    width: 100%;
    display: block;
    background-color: #eb6b6b;
    color: white;
    font-size: 14px;
    padding: 20px 50px;
    border-top: 1px solid #ff5d5d;
}

.admin-impersonated-return a {
    color: inherit;
}

.tasks-page__task .levels-map {
    display: flex;
    flex-flow: row wrap;
    gap: 0px;
}

.tasks-page__task .levels-map .level-marker {
    width: 10px;
    height: 10px;
    background-color: white;
}

.tasks-page__task .levels-map .level-marker-passed {
    background-color: rgba(23, 172, 104, 0.8);
}

.tasks-page__task .levels-map .level-marker-not-passed {
    background-color: rgba(247, 93, 103, 0.8);
}

.tasks-page__task .levels-map .level-marker-skipped {
    background-color: rgb(221 216 49 / 80%);
}

.tasks-page__task .levels-map .level-marker-current {
    background-color: #fff;
    border: 2px solid rgb(186 186 186);
    margin: -2px;
    z-index: 1;
}

.tasks-page__task .levels-map .level-marker-not-opened {
    background-color: rgba(128, 127, 127, 0.8);
}

.tasks-page__task .levels-map .level-marker-arrow {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;

    border-left: 7px solid rgba(128, 127, 127, 0.8);
    background-color: transparent;
}

@media (max-width: 570px) {
    .tasks-page__task .levels-map .level-marker {
        width: 6px;
        height: 6px;
    }

    .tasks-page__task .levels-map .level-marker-current {
        border-width: 1px;
        margin: -1px;
    }

    .tasks-page__task .levels-map .level-marker-arrow {
        display: none;
    }
}


.tasks-page__task .solve-task-button {
    margin-top: 30px;
    width: 200px;
}

.levels-table a {
    color: inherit;
    text-decoration: none;
}

.levels-table .level {
    display: flex;
    padding: 8px 0;
}

.levels-table .level:not(.levels-table-title) {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.levels-table .levels-table-title {
    font-weight: 700;
}

.levels-table .level:not(.level-unavailable):not(.levels-table-title):hover {
    background-color: #eeeeeec7;
    cursor: pointer;
    color: black;
}

.levels-table .level.level-passed {
    color: #a1f1ccc9;
}

.levels-table .level.level-skipped {
    color: rgb(247 195 143 / 80%)
}

.levels-table .level.level-not-passed {
    color: #f6bbc7cc;
}

.levels-table .level.level-unavailable {
    color: #bbb;
}

.levels-table .level-number {
    min-width: 20px;
    text-align: right;
    padding-right: 20px;
}

.levels-table .level-score {
    width: 100px;
    font-weight: 600;
}

.levels-table .level-score img {
    width: 15px;
}

.levels-table .level-comment {
    width: 600px;
    padding: 0 20px;
}

.levels-table .level-status {
    text-align: right;
    position: absolute;
    right: 60px;
}

@media (max-width: 768px) {
    .levels-table .level-status {
        display: none;
    }
}

.task-links {
    margin-bottom: 30px;
}

@media (max-width: 570px) {
    .task-links {
        margin-left: 30px;
    }

    .task-links .task-current-link {
        margin-right: 60px;
    }
}

.task-links .container {
    display: flex;
    justify-content: space-between;
}

.task-links .task-current-link {
    text-align: right;
}

code.checker-output {
    font-size: 15px;
}

.first-level-manual {
    background-color: #4b793acc;
    margin: 20px -50px -5px;
    padding: 10px 50px;
}
