:root {
    --bg-a: #0b1022;
    --bg-b: #151b3a;
    --text: #eef2ff;
    --muted: #b6bfdc;
    --accent: #6ee7ff;
    --accent-2: #a78bfa;
    --success: #34d399;
    --danger: #fb7185;
    --card: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, #1b2354 0%, var(--bg-a) 45%, #090d1a 100%);
}

.app-shell {
    width: min(1100px, 94vw);
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.intdex-home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    transition: background 0.15s ease, transform 0.15s ease;
}

.intdex-home-link img {
    width: 28px;
    height: 28px;
    display: block;
}

.intdex-home-link:hover {
    background: rgba(255, 255, 255, 0.09);
    transform: translateY(-1px);
}

.version-tag {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.85em;
}

.hero {
    text-align: center;
    margin-bottom: 1.5rem;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    color: #101428;
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.hero h1 {
    margin: 0.9rem 0 0.6rem;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.hero-copy {
    margin: 0;
    color: var(--muted);
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.1rem;
    backdrop-filter: blur(10px);
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

#joinForm {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.6rem;
}

label {
    font-weight: 600;
}

input {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(9, 13, 26, 0.8);
    color: var(--text);
    padding: 0.7rem;
}

input:focus {
    outline: 2px solid rgba(110, 231, 255, 0.5);
    border-color: transparent;
}

textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(9, 13, 26, 0.8);
    color: var(--text);
    padding: 0.7rem;
    resize: vertical;
}

textarea:focus {
    outline: 2px solid rgba(110, 231, 255, 0.5);
    border-color: transparent;
}

.btn {
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 700;
}

.btn-primary {
    color: #111827;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.welcome-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.score-box {
    text-align: right;
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 12px;
    padding: 0.6rem 0.9rem;
}

.score-box span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.score-box strong {
    font-size: 1.45rem;
    color: var(--success);
}

.players-panel {
    margin-top: 0.8rem;
    background: rgba(17, 24, 39, 0.45);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
}

.treasury-panel {
    margin-top: 0.9rem;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(250, 204, 21, 0.42);
    background: radial-gradient(circle at 18% 18%, rgba(250, 204, 21, 0.15), rgba(167, 139, 250, 0.16) 42%, rgba(10, 14, 31, 0.92) 100%);
    box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.16) inset, 0 10px 28px rgba(2, 6, 23, 0.45);
}

.treasury-panel h3 {
    margin: 0.6rem 0 0.35rem;
    color: #fde68a;
    letter-spacing: 0.02em;
}

.treasury-row {
    display: grid;
    gap: 0.6rem;
    grid-template-columns: 1fr auto;
    align-items: center;
}

.treasury-row .btn {
    white-space: nowrap;
}

.treasury-keep {
    display: grid;
    grid-template-columns: 62px 1fr 62px;
    gap: 0.5rem;
    align-items: end;
}

.keep-tower,
.keep-gate-wrap {
    position: relative;
    border: 1px solid rgba(250, 204, 21, 0.45);
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.28), rgba(30, 41, 59, 0.8));
}

.keep-tower {
    height: 78px;
    border-radius: 10px 10px 6px 6px;
}

.keep-gate-wrap {
    height: 96px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.12) inset;
}

.keep-banner {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #fde68a;
    background: rgba(124, 58, 237, 0.35);
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid rgba(250, 204, 21, 0.25);
}

.keep-gate {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 88px;
    height: 58px;
    border: 2px solid rgba(250, 204, 21, 0.65);
    border-bottom: 0;
    border-radius: 50px 50px 0 0;
    background: repeating-linear-gradient(
        90deg,
        rgba(71, 85, 105, 0.8) 0 6px,
        rgba(15, 23, 42, 0.95) 6px 12px
    );
}

.treasury-reveal-fx {
    margin-top: 0.6rem;
    text-align: center;
    font-weight: 700;
    color: #fde68a;
    letter-spacing: 0.04em;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px dashed rgba(250, 204, 21, 0.48);
    background: rgba(124, 58, 237, 0.18);
}

.treasury-reveal-fx.wake {
    animation: vaultPulse 0.52s ease-in-out 2;
}

.treasury-answer-row {
    opacity: 0;
    transform: translateY(6px);
    animation: treasureReveal 0.35s ease forwards;
}

@keyframes treasureReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes vaultPulse {
    0% { transform: scale(0.99); }
    50% { transform: scale(1.015); }
    100% { transform: scale(1); }
}

@media (max-width: 700px) {
    .treasury-row {
        grid-template-columns: 1fr;
    }

    .treasury-row .btn {
        width: 100%;
    }
}

.players-title {
    margin: 0 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.players-toggle {
    border: 1px solid var(--border);
    background: rgba(99, 102, 241, 0.2);
    color: var(--text);
    border-radius: 8px;
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.players-panel.collapsed .players-list {
    display: none;
}

.players-list {
    display: grid;
    gap: 0.45rem;
}

.player-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 0.6rem;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.45rem 0.6rem;
    background: rgba(110, 231, 255, 0.08);
}

.player-rank {
    color: var(--accent);
    font-weight: 700;
}

.player-name {
    font-weight: 600;
}

.player-score {
    color: var(--success);
    font-weight: 700;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.9rem;
}

.game-card {
    background: linear-gradient(155deg, rgba(167, 139, 250, 0.16), rgba(110, 231, 255, 0.11));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.9rem;
}

.game-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.meta {
    color: var(--muted);
    font-size: 0.86rem;
}

.game-card p {
    color: #e5e7eb;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.8rem;
}

.tag {
    font-size: 0.78rem;
    color: var(--muted);
}

.completed {
    border-color: rgba(52, 211, 153, 0.8);
    box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.5) inset;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(3, 5, 12, 0.72);
    padding: 1rem;
    z-index: 20;
}

.modal-card {
    width: min(720px, 100%);
    background: #0f1530;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.4rem;
    right: 0.6rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.question {
    font-weight: 600;
}

.hint {
    color: #c4b5fd;
}

.feedback {
    min-height: 1.2rem;
    font-weight: 600;
}

.feedback.success {
    color: var(--success);
}

.feedback.error {
    color: var(--danger);
}

.challenge-content {
    margin-top: 0.8rem;
}

.engine-wrap {
    display: grid;
    gap: 0.8rem;
}

.option-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.workflow-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0.65rem;
    border: 1px solid rgba(110, 231, 255, 0.28);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.45);
}

.workflow-block {
    border: 1px solid rgba(167, 139, 250, 0.5);
    background: linear-gradient(145deg, rgba(76, 29, 149, 0.55), rgba(30, 64, 175, 0.38));
    color: var(--text);
    border-radius: 9px;
    padding: 0.45rem 0.62rem;
    cursor: pointer;
    font-weight: 600;
}

.workflow-block.selected {
    border-color: rgba(250, 204, 21, 0.9);
    box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.65) inset, 0 0 12px rgba(250, 204, 21, 0.34);
}

.workflow-pyramid {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.1rem;
    padding: 0.7rem;
    border-radius: 12px;
    border: 1px solid rgba(250, 204, 21, 0.35);
    background: radial-gradient(circle at top, rgba(250, 204, 21, 0.16), rgba(30, 41, 59, 0.74) 40%, rgba(2, 6, 23, 0.9));
}

.workflow-tier {
    display: flex;
    justify-content: center;
}

.workflow-slot {
    width: min(100%, calc(220px + (var(--tier) * 40px)));
    min-height: 40px;
    border-radius: 10px;
    border: 1px dashed rgba(148, 163, 184, 0.65);
    background: rgba(15, 23, 42, 0.58);
    color: #cbd5e1;
    cursor: pointer;
    font-weight: 600;
    padding: 0.5rem 0.65rem;
    text-align: center;
}

.workflow-slot.filled {
    border-style: solid;
    border-color: rgba(52, 211, 153, 0.7);
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.22), rgba(59, 130, 246, 0.2));
    color: #ecfeff;
}

.option-btn,
.chip-btn {
    border: 1px solid var(--border);
    background: rgba(17, 24, 39, 0.8);
    color: var(--text);
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    cursor: pointer;
}

.option-btn.selected,
.chip-btn.selected {
    background: rgba(110, 231, 255, 0.2);
    border-color: var(--accent);
}

.form-grid {
    display: grid;
    gap: 0.8rem;
}

.match-row,
.research-row,
.slider-row {
    display: grid;
    gap: 0.35rem;
}

select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(9, 13, 26, 0.8);
    color: var(--text);
    padding: 0.6rem;
}

.source-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.source-link:hover {
    text-decoration: underline;
}

.snippet-list {
    margin: 0;
    padding-left: 1.1rem;
    color: #d6dbf0;
}

.insight-list {
    background: rgba(17, 24, 39, 0.55);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.9rem 0.7rem 1.5rem;
}

.block-board {
    display: grid;
    grid-template-columns: repeat(8, 34px);
    gap: 4px;
    justify-content: start;
    background: rgba(10, 14, 31, 0.8);
    padding: 0.55rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.block-cell {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.block-cell.wall {
    background: rgba(251, 113, 133, 0.24);
}

.block-cell.chip {
    color: #fde047;
}

.block-cell.player {
    background: rgba(110, 231, 255, 0.35);
    color: #0b1022;
    font-weight: 700;
}

.ethics-board {
    display: grid;
    grid-template-columns: repeat(7, 36px);
    gap: 6px;
    justify-content: start;
    background: radial-gradient(circle at 25% 20%, rgba(110, 231, 255, 0.22), rgba(37, 99, 235, 0.18) 36%, rgba(10, 14, 31, 0.95) 80%);
    padding: 0.8rem;
    border-radius: 14px;
    border: 1px solid rgba(110, 231, 255, 0.35);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 12px 28px rgba(2, 8, 23, 0.45);
}

.ethics-cell {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.ethics-cell.island {
    background: linear-gradient(145deg, rgba(56, 189, 248, 0.18), rgba(96, 165, 250, 0.12));
    border-color: rgba(110, 231, 255, 0.35);
    color: #f8fafc;
    font-weight: 700;
}

.ethics-cell.ship {
    background: linear-gradient(145deg, rgba(56, 189, 248, 0.95), rgba(99, 102, 241, 0.88));
    color: #0b1022;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.32);
}

.ethics-flags {
    margin: 0.3rem 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    padding: 0.6rem;
}

.ethics-flag-list {
    margin: 0.35rem 0 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.25rem;
}

.ethics-flag-item {
    color: var(--text);
    font-size: 0.92rem;
}

.app-footer {
    max-width: 1100px;
    margin: 0 auto 1.2rem;
    padding: 0 1rem;
}

.app-footer a {
    display: inline-block;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px dashed rgba(226, 232, 240, 0.4);
    font-size: 0.9rem;
}

.app-footer a:hover,
.app-footer a:focus-visible {
    color: var(--text);
    border-bottom-color: rgba(226, 232, 240, 0.9);
}

.cookie-notice {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    max-width: 420px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 10px 25px rgba(2, 8, 23, 0.4);
}

.cookie-notice p {
    margin: 0;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.35;
}

.cookie-notice.hidden {
    display: none;
}

@media (max-width: 640px) {
    .cookie-notice {
        left: 0.8rem;
        right: 0.8rem;
        max-width: none;
    }
}

.slider-row input[type="range"] {
    width: 100%;
}

.node-map {
    display: grid;
    grid-template-columns: repeat(4, minmax(70px, 1fr));
    gap: 0.5rem;
}

.node-btn {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--text);
    padding: 0.55rem;
    cursor: pointer;
}

.rating-metrics {
    display: grid;
    gap: 0.35rem;
    background: rgba(17, 24, 39, 0.55);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
}

.metric-row.final {
    padding-top: 0.35rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
}

.target-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.55rem;
}

.shooting-arena {
    position: relative;
    cursor: none;
}

.target-btn {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: linear-gradient(140deg, rgba(17, 24, 39, 0.95), rgba(67, 56, 202, 0.24));
    color: var(--text);
    padding: 0.65rem;
    text-align: left;
    cursor: none;
    min-height: 72px;
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 0.45rem;
    align-items: center;
    animation-name: targetFloat;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}

.target-btn:disabled {
    cursor: none;
    opacity: 0.95;
}

.target-hit-wrong {
    border-color: rgba(52, 211, 153, 0.9);
    background: rgba(52, 211, 153, 0.2);
}

.target-hit-correct {
    border-color: rgba(251, 113, 133, 0.9);
    background: rgba(251, 113, 133, 0.2);
}

.target-icon {
    font-size: 1.05rem;
}

.target-shot {
    animation: targetShotPulse 0.35s ease-out;
}

.arrow-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.myth-gun {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(110, 231, 255, 0.65);
    background: rgba(11, 16, 34, 0.85);
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 10px rgba(110, 231, 255, 0.35);
}

.myth-arrow {
    position: absolute;
    transform: translate(-50%, -50%) rotate(var(--arrow-rot));
    transform-origin: left center;
    color: #f59e0b;
    font-weight: 800;
    text-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
    animation: arrowShoot 0.28s linear forwards;
}

@keyframes targetFloat {
    0% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(4px) translateY(-2px); }
    50% { transform: translateX(-3px) translateY(1px); }
    75% { transform: translateX(2px) translateY(-1px); }
    100% { transform: translateX(0) translateY(0); }
}

@keyframes targetShotPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes arrowShoot {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--arrow-rot)) translateX(0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--arrow-rot)) translateX(var(--arrow-dist));
    }
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    background: #111827;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    max-width: min(380px, 90vw);
    z-index: 30;
}

@media (max-width: 640px) {
    .welcome-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
