/* CSS Reset for all elements */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Vanguard CSS Styles */

/* Base styles for both pages */
body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    background-color: var(--systemBackground, #fff);
    color: var(--label, #1c1c1e);
}

/* Home page background */
body.home {
    background-color: var(--secondarySystemBackground, #f2f2f7);
}

/* Success page background */
body.success {
    background-color: var(--tertiarySystemBackground, #f0f8ff);
}

.container {
    background-color: var(--systemBackground, #fff);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 600px;
    width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

h1 {
    color: var(--label, #1c1c1e);
}

p, .checkpoint-text, .info-content p, .joining-message {
    color: var(--secondaryLabel, #3c3c4399);
}

/* Success page specific styles */
#countdownMessage {
    margin: 0px;
    color: var(--label, #1c1c1e);
    font-weight: bold;
}

p {
    margin-top: 10px;
}

/* WebGL cube animation or GIF */
.animation {
    width: 150px;
    height: 150px;
    margin: 20px auto;
    display: none;
    position: relative;
}

.animation canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

body.success .animation {
    display: block;
}

/* Fallback loading GIF for browsers without WebGL */
.fallback-loading {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    justify-content: center;
    align-items: center;
}

.fallback-loading img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Form styles */
form {
    margin-top: 20px;
}

button {
    background-color: var(--AccentColor, #007aff);
    color: var(--systemBackground, #fff);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

button:disabled {
    background-color: var(--quaternaryLabel, #d1d1d6);
    color: var(--tertiaryLabel, #aeaeb2);
}

/* Challenge ID copy functionality */
.checkpoint-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

.checkpoint-text {
    color: #555;
    font-weight: normal;
    white-space: nowrap;
}

.checkpoint-wrapper {
    position: relative;
    display: inline-block;
}

.clickable-checkpoint {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.clickable-checkpoint:hover {
    background-color: #e8f4f8;
}

.copied-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: color-mix(in srgb, var(--AccentColor, #007aff) 90%, transparent);
    color: var(--systemBackground, #fff);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    display: none;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    z-index: 10;
}

.copied-message.fade-out {
    opacity: 0;
    transform: translate(-50%, -70%);
}

@keyframes blink-gentle {
    0% { background-color: transparent; }
    50% { background-color: #cce7ff; }
    100% { background-color: transparent; }
}

.blink-animation {
    animation: blink-gentle 0.2s ease-in-out;
}

/* Error and retry styles */
.error-message {
    color: var(--systemRed, #ff3b30);
    font-weight: bold;
}

a.retry-link {
    color: var(--AccentColor, #007aff);
    text-decoration: none;
    display: inline-block;
    margin-top: 15px;
    padding: 8px 15px;
    border: 1px solid var(--AccentColor, #007aff);
    border-radius: 4px;
}

a.retry-link:hover {
    background-color: var(--AccentColor, #007aff);
    color: var(--systemBackground, #fff);
}

/* Progressive result styles */
.progressive-result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid var(--separator, #ccc);
    color: var(--label, #1c1c1e);
}

.progressive-result.solved-result, .progressive-result.success-result {
    background-color: color-mix(in srgb, var(--systemGreen, #30d158) 10%, transparent);
    border-left-color: var(--systemGreen, #30d158);
}

.progressive-result.error-result {
    color: var(--systemRed, #ff3b30);
    background-color: color-mix(in srgb, var(--systemRed, #ff3b30) 10%, transparent);
    border-left-color: var(--systemRed, #ff3b30);
}

.progressive-result h2 {
    margin-top: 0;
    color: #333;
    font-size: 1.2em;
}

.retry-link {
    background-color: var(--AccentColor, #007aff);
    color: var(--systemBackground, #fff);
    text-decoration: none;
    display: inline-block;
    margin-top: 15px;
    padding: 8px 15px;
    border: 1px solid var(--AccentColor, #007aff);
    border-radius: 4px;
}

.retry-link:hover {
    background-color: #0056b3;
}

/* Monospaced text style for challenge and result */
.monospaced-text {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    color: var(--label, #1c1c1e);
    border: 1px solid var(--separator, #e9ecef);
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
    word-break: break-all;
    word-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    overflow-wrap: break-word;
    hyphens: none;
}

/* Challenge string styling */
#checkpointString {
    display: inline-block;
    word-break: break-all;
    word-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    padding: 8px 12px;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    color: var(--label, #1c1c1e);
    border: 1px solid var(--separator, #e9ecef);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    margin: 5px 0;
    overflow-wrap: break-word;
    hyphens: none;
}

/* Result number style (inherits monospaced-text) */
#resultNumber {
    margin-left: 0.5em;
    font-weight: bold;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    border: 1px solid var(--separator, #e9ecef);
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
}

/* Code elements general styling */
code {
    font-family: 'Courier New', monospace;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    color: var(--label, #1c1c1e);
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid var(--separator, #e9ecef);
}

/* Info section styling */
.info-section {
    margin-top: 30px;
    text-align: center;
}

.info-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--AccentColor, #007aff);
    text-decoration: none;
    margin: 0 auto;
}

.info-toggle:hover {
    color: #66a3ff;
    text-decoration: none;
}

.arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
    color: #333;
}

.info-content {
    padding: 15px;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 5px 5px;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.info-content p {
    margin: 10px 0;
    color: #555;
}

.info-content p:first-child {
    margin-top: 0;
}

.info-content p:last-child {
    margin-bottom: 0;
}

/* Footer styling */
.footer {
    margin-top: 20px;
    text-align: center;
    color: var(--tertiaryLabel, #aeaeb2);
    font-size: 14px;
}

.footer p {
    margin: 15px;
}

.footer-divider {
    border: none;
    border-top: 1px solid var(--separator, #dee2e6);
    margin: 20px auto 20px auto;
    width: 400px;
    /* Embossed divider effect */
    box-shadow:
        0 1px 0 0 #fff,      /* highlight below */
        0 -1px 0 0 #b0b0b0,  /* shadow above */
        0 2px 4px #e0e0e0;   /* soft drop shadow */
}

/* Chat info styling */
.chat-info {
    margin: 20px 0;
    padding: 15px;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    border-radius: 8px;
    border: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.group-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--separator, #dee2e6);
    object-fit: cover;
}

.group-photo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--separator, #dee2e6);
    background-color: #0088cc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.telegram-icon {
    width: 100%;
    height: 100%;
}

.joining-message {
    margin: 0;
    font-size: 16px;
    color: #333;
}

@keyframes cool-progress-shine-move {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Vanguard progress bar (from gotoquiz.com, adapted) */
.vanguard-progress-outer {
    background: var(--quaternaryLabel, #252525);
    border: 1px solid var(--separator, #000);
    border-radius: 8px;
    box-shadow: inset 1px 1px 3px 0 rgba(0, 0, 0, 0.8), 1px 1px 0 0 rgba(255, 255, 255, 0.12);
    height: 14px; /* 2/3 of 21px = 14px */
    width: 85%;
    margin-bottom: 10px;
    position: relative;
    margin-left: auto;
    margin-right: auto;
}

.vanguard-progress-label {
    color: var(--tertiaryLabel, #888);
    font-size: 12px;
    position: absolute;
    right: -32px;
    top: 0;
}

.vanguard-progress-inner {
    background-color: var(--AccentColor, #0A84FF);
    border-right: 1px solid #090909;
    border-radius: 7px;
    height: 100%;
    width: 0%;
    background-size: 100% 100%, 20px 20px, 100% 100%;
    background-image:
        linear-gradient(to bottom,
                        rgba(255, 255, 255, 0.33) 0,
                        rgba(255, 255, 255, 0.08) 50%,
                        rgba(0, 0, 0, 0.25) 50%,
                        rgba(0, 0, 0, 0.1) 100%),
        linear-gradient(45deg,
                        rgba(255, 255, 255, 0.16) 25%,
                        rgba(0, 0, 0, 0) 25%,
                        rgba(0, 0, 0, 0) 50%,
                        rgba(255, 255, 255, 0.16) 50%,
                        rgba(255, 255, 255, 0.16) 75%,
                        rgba(0, 0, 0, 0) 75%,
                        rgba(0, 0, 0, 0)),
        linear-gradient(to right, #007AFF, #0A84FF);
    box-shadow: inset 0 1px 1px 0px rgba(255, 215, 215, 0.5),
                inset 0 -1px 1px 0px rgba(255, 255, 255, 0.25),
                1px 1px 3px 0 rgba(0,0,0,0.33);
    animation: progress-shine-reverse 0.4s linear infinite;
    transition: none;
}

.vanguard-progress-inner.vanguard-progress-error {
    background-color: var(--systemRed, #ff3b30);
    background-image: linear-gradient(to bottom,
                        rgba(255, 255, 255, 0.33) 0,
                        rgba(255, 255, 255, 0.08) 50%,
                        rgba(0, 0, 0, 0.25) 50%,
                        rgba(0, 0, 0, 0.1) 100%),
        linear-gradient(45deg,
                        rgba(255, 255, 255, 0.16) 25%,
                        rgba(0, 0, 0, 0) 25%,
                        rgba(0, 0, 0, 0) 50%,
                        rgba(255, 255, 255, 0.16) 50%,
                        rgba(255, 255, 255, 0.16) 75%,
                        rgba(0, 0, 0, 0) 75%,
                        rgba(0, 0, 0, 0)),
        linear-gradient(to right, #FF3B30, #FF453A);
    animation: none !important;
}

.vanguard-progress-inner.vanguard-progress-success {
    background-color: var(--systemGreen, #30d158);
    background-image: linear-gradient(to bottom,
                        rgba(255, 255, 255, 0.33) 0,
                        rgba(255, 255, 255, 0.08) 50%,
                        rgba(0, 0, 0, 0.25) 50%,
                        rgba(0, 0, 0, 0.1) 100%),
        linear-gradient(45deg,
                        rgba(255, 255, 255, 0.16) 25%,
                        rgba(0, 0, 0, 0) 25%,
                        rgba(0, 0, 0, 0) 50%,
                        rgba(255, 255, 255, 0.16) 50%,
                        rgba(255, 255, 255, 0.16) 75%,
                        rgba(0, 0, 0, 0) 75%,
                        rgba(0, 0, 0, 0)),
        linear-gradient(to right, #5cb85c, #3e8e41);
    border-right: 1px solid #3e8e41;
}

@keyframes progress-shine-reverse {
    0% {
        background-position:
            0 0, /* vertical shine */
            20px 0, /* diagonal shine at right edge of repeat */
            0 0;
    }
    100% {
        background-position:
            0 0,
            0 0, /* diagonal shine at left edge of repeat */
            0 0;
    }
}

#infoBoxContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
}

.info-box {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--secondarySystemBackground, #f2f2f7);
    color: var(--label, #1c1c1e);
    border: 1px solid var(--separator, #e9ecef);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    cursor: default;
    word-break: break-all;
    padding: 10px;
    margin: 5px;
    line-height: 1.5;
    letter-spacing: 0;
}

.info-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 2px;
    line-height: 1;
    min-height: 0;
    font-size: 14px;
}

.info-col-left, .info-col-right {
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    white-space: pre-wrap;
}

.info-col-right {
    text-align: right;
    flex: 0 0 auto;
    min-width: 60px;
    margin-left: 16px;
}