* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

button {
    -webkit-appearance: none;
    appearance: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

button * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: radial-gradient(circle at top, #111827, #0b1120 60%);
    color: #f8fafc;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    background: radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.25), transparent 45%),
        radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.18), transparent 40%),
        radial-gradient(circle at 40% 80%, rgba(14, 116, 144, 0.2), transparent 45%);
    opacity: 0.9;
}

body::after {
    background: linear-gradient(120deg, rgba(15, 23, 42, 0.7), rgba(2, 6, 23, 0.9));
    mix-blend-mode: screen;
}

.app {
    width: min(900px, 100%);
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.35s ease;
}

.card {
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(12px);
}

.hero-card {
    border: 1px solid rgba(94, 234, 212, 0.3);
    box-shadow: 0 30px 60px rgba(14, 116, 144, 0.25);
}

.game-card {
    margin-top: 16px;
}

.title {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 12px;
}

.subtitle {
    text-align: center;
    font-size: 1rem;
    color: rgba(248, 250, 252, 0.8);
    margin-bottom: 20px;
}

.progress-card {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 14px;
    margin-bottom: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(148, 163, 184, 0.25);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8, #6366f1);
    transition: width 0.3s ease;
}

.progress-meta {
    margin-top: 8px;
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.8);
    text-align: center;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.ads-controls {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ads-reward-btn {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.35);
}

.primary,
.secondary,
.ghost,
.hint,
.back {
    border: none;
    border-radius: 14px;
    padding: 12px 20px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    min-height: 44px;
    font-size: clamp(14px, 2.6vw, 16px);
    line-height: 1.2;
}

.primary *,
.secondary *,
.ghost *,
.hint *,
.back *,
.fragment-btn *,
.hints-tab *,
.hints-modal-close * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.primary:focus,
.secondary:focus,
.ghost:focus,
.hint:focus,
.back:focus,
.fragment-btn:focus,
.hints-tab:focus,
.hints-modal-close:focus,
.answer-part:focus {
    outline: none;
}

.primary:focus-visible,
.secondary:focus-visible,
.ghost:focus-visible,
.hint:focus-visible,
.back:focus-visible,
.fragment-btn:focus-visible,
.hints-tab:focus-visible,
.hints-modal-close:focus-visible,
.answer-part:focus-visible {
    outline: none;
}

.primary:active,
.secondary:active,
.ghost:active,
.hint:active,
.back:active,
.fragment-btn:active,
.hints-tab:active,
.hints-modal-close:active,
.answer-part:active {
    transform: none;
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled,
.hint:disabled,
.back:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    filter: grayscale(0.2);
}

.primary {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: #0f172a;
    box-shadow: 0 12px 24px rgba(56, 189, 248, 0.35);
}

.secondary {
    background: rgba(148, 163, 184, 0.15);
    color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.ghost {
    background: rgba(30, 41, 59, 0.5);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.hint {
    background: rgba(14, 116, 144, 0.25);
    color: #e2e8f0;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.hint.danger {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

.back {
    margin-top: 16px;
    width: 100%;
    background: rgba(148, 163, 184, 0.15);
    color: #f8fafc;
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.hint:hover,
.back:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.3);
}

.hidden {
    display: none;
}

.info {
    text-align: center;
    color: rgba(226, 232, 240, 0.8);
    font-size: 0.9rem;
}

.hud {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.hud-item {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 12px;
    padding: 10px 12px;
    text-align: center;
    border: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
}

.hud-label {
    font-size: 0.86rem;
    color: rgba(226, 232, 240, 0.78);
    font-weight: 600;
}

.hud-value {
    font-size: 1.06rem;
    font-weight: 800;
    color: #f8fafc;
}

.level-progress {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    margin: 10px 0 16px;
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #fbbf24, #f97316);
    transition: width 0.3s ease;
}

.theme {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #fbbf24;
}

.answer {
    background: rgba(30, 41, 59, 0.7);
    border-radius: 16px;
    padding: 12px;
    text-align: center;
    margin-bottom: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.answer-parts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.answer-part {
    background: rgba(99, 102, 241, 0.25);
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 10px;
    padding: 6px 10px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.answer-part.locked {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.5);
    cursor: default;
}

.answer-part:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(99, 102, 241, 0.25);
}

.answer-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
}

.message {
    min-height: 24px;
    text-align: center;
    margin-bottom: 12px;
    color: #fca5a5;
    font-weight: 600;
}

.fragments-title {
    margin-bottom: 8px;
    text-align: center;
    color: rgba(226, 232, 240, 0.85);
}

.fragments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.fragment-btn {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 44px;
    min-width: 62px;
    font-size: clamp(14px, 2.8vw, 16px);
    line-height: 1.1;
}

.fragment-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.2);
}

.fragment-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.fragment-btn.hidden {
    display: none;
}

.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 12px 0;
    flex-wrap: wrap;
}

.confirm-btn {
    min-width: 180px;
}

.hints-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
    gap: 10px;
    flex-wrap: wrap;
}

.hints-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 20;
}

.hints-modal.hidden {
    display: none;
}

.hints-modal-card {
    width: min(420px, 92vw);
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 30px 70px rgba(2, 6, 23, 0.6);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.rules-card {
    width: min(560px, 94vw);
}

.rules-scroll {
    max-height: min(70vh, 520px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.7) rgba(15, 23, 42, 0.6);
}

.rules-scroll::-webkit-scrollbar {
    width: 8px;
}

.rules-scroll::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 999px;
}

.rules-scroll::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.7);
    border-radius: 999px;
    border: 2px solid rgba(15, 23, 42, 0.6);
}

.rules-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(129, 140, 248, 0.8);
}

.rules-section {
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 14px;
    padding: 12px 14px;
}

.rules-title {
    font-weight: 800;
    margin-bottom: 6px;
    color: #fbbf24;
}

.rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 0;
}

.rules-list li {
    color: rgba(226, 232, 240, 0.9);
}

.hints-tabs {
    display: flex;
    gap: 10px;
    padding: 6px;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 14px;
}

.hints-tab {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 800;
    background: transparent;
    color: rgba(226, 232, 240, 0.8);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    min-height: 42px;
    font-size: clamp(14px, 2.6vw, 15px);
}

.hints-tab.active {
    background: rgba(56, 189, 248, 0.22);
    color: #e2e8f0;
    transform: translateY(-1px);
}

.hints-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hints-section.hidden {
    display: none;
}

.hints-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hints-modal-title {
    font-weight: 800;
    font-size: 1.1rem;
}

.hints-modal-close {
    border: none;
    background: rgba(148, 163, 184, 0.2);
    color: #f8fafc;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    transition: transform 0.2s ease, background 0.2s ease;
}

.hints-modal-close:hover {
    transform: translateY(-1px);
    background: rgba(148, 163, 184, 0.32);
}

.hints {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.hint {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    gap: 10px;
    text-align: left;
}

.hint.bonus {
    background: rgba(56, 189, 248, 0.18);
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.hint:disabled,
.hint.disabled {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(0.2);
}

.hint-cost {
    margin-left: auto;
    font-weight: 800;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 999px;
    padding: 4px 10px;
    min-width: 74px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 700;
    z-index: 30;
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-6px);
}

.toast.error {
    border-color: rgba(248, 113, 113, 0.55);
    background: rgba(127, 29, 29, 0.85);
}

.result-row {
    font-size: 1.1rem;
    margin-bottom: 10px;
    text-align: center;
}

.result-status {
    text-align: center;
    font-weight: 700;
    margin-bottom: 10px;
    color: rgba(251, 191, 36, 0.9);
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .card {
        padding: 18px;
    }

    .title {
        font-size: 1.6rem;
    }

    .answer-text {
        font-size: 1.2rem;
    }
}
