:root {
    --bg: #0b0e14;
    --bg-dot: #131722;
    --panel: #11151c;
    --panel-header: #171c25;
    --border: #232a35;
    --text: #d7dee6;
    --muted: #6b7785;
    --green: #59e3a6;
    --amber: #ffb545;
    --pink: #ff6fae;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent;}
html, body {
    margin: 0;
    height: 100%;
    overflow-x: hidden;
}
body {
    min-height: 100dvh;
    background: radial-gradient(circle at 1px 1px, var(--bg-dot) 1px, transparent 0) 0 0/22px 22px, var(--bg);
    color: var(--text);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    user-select: none;
}

.wordmark {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    display: flex;
    align-items: baseline;
    gap: 2px;
}
.wordmark .dim { color: var(--muted); font-weight: 500;}
.wordmark a {color: inherit; text-decoration: none;}

.card {
    width: 100%;
    max-width: 480px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    background: var(--panel-header);
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
}
.card-header .term-icon {color: var(--green);}
.card-header .fill {flex: 1;}

.card-body {
    padding: 1.6rem 1.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    text-align: center;
}

h1 { font-size: 1.3rem; margin: 0;}
h2 { font-size: 1rem; margin: 0; color: var(--muted); font-weight: 500;}

.stepper {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin: 0.3rem 0;
}

.stepper button {
    width: 46px; height: 46px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-header);
    color: var(--text);
    font-size: 1.4rem;
    font-family: inherit;
    cursor: pointer;
}
.stepper button:active { background: rgba(255, 255, 255, 0.06);}
.stepper .count-input {
    font-size: 2rem;
    font-weight: 700;
    width: 4ch;
    text-align: center;
    background: var(--panel-header);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    padding: 0.2rem 0;
    -moz-appearance: textfield;
}
.stepper .count-input::-webkit-outer-spin-button,
.stepper .count-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.btn {
    width: 100%;
    padding: 0.9rem;
    border-radius: 10px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    color: #0b0e14;
    background: var(--green);
}
.btn:active { filter:brightness(0.9)}
.btn.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn.danger {
    background: var(--pink);
}
.btn-row { display: flex; gap: 0.6rem; width: 100%;}
.btn-row .btn { flex: 1;}

.hint {font-size: 0.8rem; color: var(--muted);}

.player-badge {
    font-size: 0.85rem;
    color: var(--muted);
    letter-spacing: 0.03em;
}

.reveal-box {
    width: 100%;
    min-height: 140 px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 10px;
    border: 1px dashed var(--border);
    padding: 1.2rem;
}
.reveal-box.filled {border-style: solid ;}
.reveal-box .loc { font-size: 1.35rem; font-weight: 700; color: var(--green);}
.reveal-box .role {font-size: 1.05rem; color: var(--text);}
.reveal-box .role-label, .reveal-box .loc-label {font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;}
.reveal-box.agent .agent-title {font-size: 1.4rem; font-weight: 700; color: var(--pink);}
.reveal-box.agent .agent-sub {font-size: 0.85rem; color: var(--muted);}

.resolved-loc { font-size: 1.6rem; font-weight: 700; color: var(--green);}
.resolved-agent { font-size: 1.1rem; color: var(--pink); font-weight: 600;}

footer{
    margin-top: 1.2rem;
    color: var(--muted);
    font-size: 0.72rem;
    text-align: center;
}

@media (max-height: 600px) {
    .card-body { padding: 1rem 1.2rem; gap: 0.8rem;}
    .reveal-box { min-height: 100px;}
}

.loc-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.loc-modal.open { display: flex; }

.loc-modal-panel {
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.loc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--panel-header);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
}
.loc-modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
}
.loc-modal-close:active { color: var(--text); }

.loc-modal-list {
    overflow-y: auto;
    padding: 0.6rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.loc-modal-item {
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    font-size: 0.85rem;
    text-align: center;
}

@media (max-width: 380px) {
    .loc-modal-list { grid-template-columns: 1fr; }
}
