:root {
    --bg: #0e1512;
    --bg2: #131d19;
    --surface: #17231e;
    --surface-hi: #1e2d27;
    --line: #26362f;
    --line-hi: #34493f;
    --ink: #e8f0ea;
    --muted: #93a89d;
    --faint: #8aa094;
    --mint: #3ddc97;
    --mint-deep: #1f9e6b;
    --mint-dim: #1a3a2c;
    --amber: #e8b04a;
    --danger: #ef6f5c;
    --danger-bg: #2a1512;
    --radius: 16px;
    --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }
body {
    margin: 0;
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    accent-color: var(--mint);
    background:
        radial-gradient(80vw 60vh ellipse at 50% -10%, #16261f, var(--bg) 70%);
    background-attachment: fixed;
}

[v-cloak] { display: none; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

a.skip {
    position: absolute; left: -9999px; top: 0;
    background: var(--mint); color: #06120c; padding: 0.6rem 1rem; z-index: 50;
    border-radius: 0 0 8px 0; font-weight: 700;
}
a.skip:focus { left: 0; }

.wrap {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.8rem;
}
.home-link { position: relative; display: inline-flex; border-radius: 12px; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5)); }
.home-link img { width: 48px; height: 48px; display: block; transition: transform 0.15s ease; }
.home-link:hover img, .home-link:focus-visible img { transform: rotate(-8deg) scale(1.08); }
.home-link:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
.home-link .tip {
    position: absolute; top: calc(100% + 9px); left: 0;
    background: var(--mint); color: #06120c;
    font-size: 0.78rem; font-weight: 700;
    white-space: nowrap; padding: 0.4rem 0.7rem; border-radius: 8px;
    opacity: 0; transform: translateY(-4px); pointer-events: none;
    transition: opacity 0.15s, transform 0.15s; z-index: 30;
}
.home-link .tip::before { content: ''; position: absolute; top: -4px; left: 18px; width: 8px; height: 8px; background: var(--mint); transform: rotate(45deg); }
.home-link:hover .tip, .home-link:focus-visible .tip { opacity: 1; transform: translateY(0); }

.lock-badge {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
    color: var(--mint); background: var(--mint-dim);
    border: 1px solid #245a42; border-radius: 999px; padding: 0.35rem 0.7rem;
}

h1 {
    font-size: 1.95rem; line-height: 1.15; letter-spacing: -0.02em;
    margin: 0 0 0.5rem; font-weight: 700;
}
.lede { color: var(--muted); font-size: 1rem; line-height: 1.6; margin: 0 0 1.6rem; max-width: 52ch; }

.btn {
    appearance: none; border-radius: 12px; padding: 0.85rem 1.4rem;
    font-size: 0.98rem; font-weight: 700; cursor: pointer; font-family: inherit;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: filter 0.15s, transform 0.1s, border-color 0.15s;
}
.btn:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #46e6a2, #23a774); color: #06120c; border: 1px solid #1c7f57; box-shadow: 0 3px 0 #155f41; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { background: #24332c; color: #6a7d73; border-color: #2b3d34; box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-hi); }
.btn-ghost:hover { border-color: var(--mint); }

button.linkish { appearance: none; border: none; background: none; padding: 0; font-size: 0.88rem; color: var(--muted); text-decoration: underline; cursor: pointer; font-family: inherit; }
button.linkish:hover { color: var(--mint); }
button.linkish:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 4px; }

/* Start menu */
.menu-choices { display: grid; gap: 0.9rem; max-width: 440px; }
.menu-card {
    appearance: none; font-family: inherit; cursor: pointer; text-align: left;
    display: flex; align-items: center; gap: 0.95rem;
    background: linear-gradient(180deg, var(--surface-hi), var(--surface));
    border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
    color: var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,0.35);
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.menu-card:hover { border-color: var(--mint); box-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 0 16px rgba(61, 220, 151, 0.12); }
.menu-card:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.menu-card:active { transform: translateY(1px); }
.menu-card .mc-ico {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    background: var(--mint-dim); border: 1px solid #245a42; color: var(--mint);
    display: inline-flex; align-items: center; justify-content: center;
}
.menu-card .mc-title { display: block; font-weight: 700; font-size: 1.02rem; }
.menu-card .mc-sub { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.45; }

.f-label { display: block; font-weight: 700; font-size: 0.88rem; margin-bottom: 0.35rem; }
input.field, textarea.field {
    width: 100%; border: 1px solid var(--line-hi); border-radius: 11px;
    padding: 0.7rem 0.9rem; font-size: 0.95rem; font-family: inherit;
    color: var(--ink); background: #0f1712; outline: none;
}
input.field::placeholder, textarea.field::placeholder { color: var(--faint); }
input.field:focus, textarea.field:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.15); }
.name-row { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; margin: 1.2rem 0 0; max-width: 440px; }
.name-row > div { flex: 1; min-width: 180px; }

.lobby-card {
    background: linear-gradient(180deg, var(--surface-hi), var(--surface));
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.3rem 1.4rem; max-width: 500px; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.lobby-card h2 { margin: 0 0 0.4rem; font-size: 1.2rem; }
.lobby-card p { color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.invite-row { display: flex; gap: 0.6rem; margin: 0.9rem 0; flex-wrap: wrap; }
.invite-row input { flex: 1; min-width: 200px; font-family: var(--mono); font-size: 0.8rem; }
.pulse-dots::after { content: '…'; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.banner { display: flex; gap: 0.55rem; align-items: flex-start; border-radius: 10px; padding: 0.75rem 0.9rem; font-size: 0.88rem; line-height: 1.5; margin-top: 1rem; max-width: 500px; }
.banner.warn { background: var(--danger-bg); color: #ffb7ab; border: 1px solid #6e2a20; }

/* ===== Chat ===== */
.chat-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
    padding-bottom: 0.9rem; border-bottom: 1px solid var(--line); margin-bottom: 0.9rem;
}
.peer-id { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.peer-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); flex-shrink: 0; }
.peer-dot.off { background: var(--faint); box-shadow: none; }
.peer-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-state { font-size: 0.78rem; color: var(--muted); }

/* Safety phrase */
.safety {
    border: 1px solid var(--line-hi); border-radius: var(--radius);
    background: var(--surface); padding: 1rem 1.1rem; margin-bottom: 0.9rem;
}
.safety.verified { border-color: #245a42; background: linear-gradient(180deg, var(--mint-dim), var(--surface)); }
.safety .s-head { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.95rem; margin: 0 0 0.35rem; }
.safety .s-sub { font-size: 0.83rem; color: var(--muted); line-height: 1.5; margin: 0 0 0.7rem; }
.safety.verified .s-sub { color: #a8d8bf; }
.phrase {
    font-family: var(--mono); font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em;
    color: var(--mint); background: #0d140f; border: 1px dashed var(--line-hi);
    border-radius: 10px; padding: 0.7rem 0.9rem; word-spacing: 0.35em; line-height: 1.7;
}
.safety-actions { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-top: 0.7rem; }
.verified-tag { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--mint); font-weight: 700; font-size: 0.88rem; }

.msg-log {
    flex: 1; min-height: 220px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.4rem 0.1rem; margin-bottom: 0.4rem;
}
.msg-empty { color: var(--faint); text-align: center; margin: auto; font-size: 0.9rem; line-height: 1.6; max-width: 34ch; }
.bubble {
    max-width: 80%; padding: 0.55rem 0.85rem; border-radius: 15px;
    font-size: 0.96rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
    animation: pop 0.16s ease-out;
}
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.bubble.mine { align-self: flex-end; background: linear-gradient(180deg, #2fbc82, #1f9e6b); color: #06120c; border-bottom-right-radius: 5px; }
.bubble.theirs { align-self: flex-start; background: var(--surface-hi); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.system { align-self: center; background: transparent; color: var(--faint); font-size: 0.82rem; text-align: center; max-width: 100%; animation: none; }
.bubble .stamp { display: block; font-size: 0.66rem; margin-top: 0.2rem; opacity: 0.65; }
.bubble.mine .stamp { text-align: right; }

.typing { font-size: 0.8rem; color: var(--muted); min-height: 1.1rem; padding: 0 0.3rem; font-style: italic; }

.composer { display: flex; gap: 0.6rem; align-items: flex-end; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.composer textarea { resize: none; min-height: 46px; max-height: 140px; line-height: 1.4; }
.send-btn {
    appearance: none; border: none; cursor: pointer; flex-shrink: 0;
    width: 46px; height: 46px; border-radius: 12px;
    background: linear-gradient(180deg, #46e6a2, #23a774); color: #06120c;
    display: inline-flex; align-items: center; justify-content: center;
    transition: filter 0.15s, transform 0.1s;
}
.send-btn:hover:not(:disabled) { filter: brightness(1.08); }
.send-btn:active:not(:disabled) { transform: translateY(1px); }
.send-btn:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.send-btn:disabled { background: #24332c; color: #6a7d73; cursor: not-allowed; }

.chat-foot-row { display: flex; justify-content: space-between; align-items: center; margin-top: 0.7rem; gap: 0.5rem 1rem; flex-wrap: wrap; }
.lock-note { font-size: 0.74rem; color: var(--faint); }
.typing-toggle { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.8rem; color: var(--muted); cursor: pointer; }
.typing-toggle input { width: 15px; height: 15px; }
.typing-toggle input:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

/* Rules */
details.rules { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0.25rem 1rem; margin-top: 1.6rem; max-width: 560px; }
details.rules summary { cursor: pointer; font-weight: 700; font-size: 0.9rem; padding: 0.7rem 0.1rem; }
details.rules summary:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
details.rules[open] { padding-bottom: 0.9rem; }
details.rules p, details.rules li { font-size: 0.88rem; color: var(--muted); line-height: 1.6; }
details.rules strong { color: var(--ink); }
details.rules ul { padding-left: 1.2rem; margin: 0.4rem 0; }

.foot { text-align: center; padding: 1.5rem 1rem 1rem; font-size: 0.78rem; color: var(--faint); line-height: 1.6; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--mint); }

@media (prefers-reduced-motion: reduce) {
    .bubble { animation: none; }
    .pulse-dots::after { animation: none; content: '…'; }
    .btn, .menu-card, .home-link img, .home-link .tip, .send-btn { transition: none; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.6rem; }
    .wrap { padding-top: 1.25rem; }
    .bubble { max-width: 88%; }
}
