/* =========================================================
   神与我之符文秘境 — UI stylesheet
   Three-column docked layout: sidebar | stage | sidebar
   ========================================================= */

:root {
    --bg-0: #07080c;
    --bg-1: #0e1016;
    --bg-2: #141722;
    --bg-3: #1b1f2e;
    --ink-0: #fff7e3;
    --ink-1: rgba(255, 247, 227, 0.78);
    --ink-2: rgba(255, 247, 227, 0.56);
    --ink-3: rgba(255, 247, 227, 0.32);

    --gold: #f0c84b;
    --gold-soft: #fff0bd;
    --accent: #f0c84b;
    --ally: #79d8ff;
    --enemy: #ff6b6b;

    --line: rgba(255, 246, 223, 0.08);
    --line-strong: rgba(255, 246, 223, 0.16);
    --line-gold: rgba(240, 200, 75, 0.32);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);

    color: var(--ink-0);
    background: var(--bg-0);
    font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

html, body, #root, #app { height: 100%; }

body {
    margin: 0;
    min-width: 320px;
    overflow: hidden;
    background: var(--bg-0);
}

button { font: inherit; }

/* ---------- Layout shell (3 columns) ---------- */

.shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 340px;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 0%, rgba(240, 200, 75, 0.05), transparent 40%),
        linear-gradient(180deg, var(--bg-1), var(--bg-0) 60%);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(14, 16, 22, 0.96), rgba(10, 11, 16, 0.98));
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.sidebar-left { border-right: 1px solid var(--line); }
.sidebar-right { border-left: 1px solid var(--line); }

/* ---------- Brand / header ---------- */

.brand {
    padding: 6px 4px 12px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--gold);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.brand h1 {
    margin: 0;
    font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
    font-size: 30px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--gold-soft);
    letter-spacing: 0.04em;
    text-shadow: 0 0 18px rgba(240, 200, 75, 0.18);
}

.subhead {
    margin: 8px 0 0;
    color: var(--ink-2);
    font-size: 12px;
    line-height: 1.55;
}

/* ---------- Typography primitives ---------- */

h1, h2, p, ol, ul { margin: 0; }

h2 {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
}

p, small, li { line-height: 1.55; }

/* ---------- Metrics ---------- */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.metric {
    position: relative;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    overflow: hidden;
}

.metric span {
    display: block;
    color: var(--ink-2);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 22px;
    line-height: 1;
    font-weight: 700;
    color: var(--ink-0);
    font-variant-numeric: tabular-nums;
}
.metric strong i {
    font-style: normal;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-3);
    margin-left: 2px;
}

.metric.accent {
    border-color: var(--line-gold);
    background:
        linear-gradient(135deg, rgba(240, 200, 75, 0.14), transparent 70%),
        rgba(22, 18, 10, 0.6);
}
.metric.accent strong { color: var(--gold-soft); }

/* ---------- Panels (shared card) ---------- */

.panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0));
    background-color: rgba(10, 12, 18, 0.6);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-title {
    display: block;
    color: var(--gold-soft);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.panel p {
    color: var(--ink-1);
    font-size: 13px;
}

.accent-panel {
    border-color: var(--line-gold);
    background:
        linear-gradient(135deg, rgba(240, 200, 75, 0.12), transparent 60%),
        rgba(18, 15, 8, 0.6);
}

/* ---------- Tags ---------- */

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    white-space: nowrap;
}
.tag-accent { border-color: var(--line-gold); color: var(--gold); background: rgba(240, 200, 75, 0.08); }
.tag-ally   { border-color: rgba(121, 216, 255, 0.4); color: var(--ally); background: rgba(121, 216, 255, 0.08); }
.tag-enemy  { border-color: rgba(255, 107, 107, 0.4); color: var(--enemy); background: rgba(255, 107, 107, 0.08); }

/* ---------- Follower composition ---------- */

.composition {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.composition > div {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.22);
    text-align: center;
}
.composition span {
    display: block;
    color: var(--ink-2);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.composition strong {
    display: block;
    margin-top: 3px;
    color: var(--ink-0);
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- Log panel ---------- */

.log-panel {
    flex: 1 1 auto;
    min-height: 160px;
}
.log-panel ol {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: log;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    max-height: 280px;
}
.log-panel li {
    counter-increment: log;
    position: relative;
    padding: 4px 6px 4px 22px;
    color: var(--ink-1);
    font-size: 12px;
    line-height: 1.5;
    border-left: 1px solid var(--line);
}
.log-panel li::before {
    content: counter(log, decimal-leading-zero);
    position: absolute;
    left: 4px;
    top: 4px;
    color: var(--ink-3);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}
.log-panel li.muted { color: var(--ink-3); font-style: italic; }

/* ---------- Stage (center) ---------- */

.stage {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
    padding: 14px;
    gap: 12px;
    background:
        radial-gradient(circle at 50% 42%, rgba(240, 200, 75, 0.08), transparent 40%),
        var(--bg-0);
}

.stage-frame {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-strong);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), var(--shadow-md);
    background: #07080c;
}
.stage-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5);
}

#game-container { width: 100%; height: 100%; }
#game-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.stage-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.phase-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border: 1px solid var(--line-gold);
    border-radius: 999px;
    background: rgba(22, 18, 10, 0.72);
    color: var(--gold-soft);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}
.phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 10px var(--gold);
    animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.6; transform: scale(0.8); }
}

.stage-bottom {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
}

/* ---------- Buttons ---------- */

.icon-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(22, 24, 32, 0.72);
    color: var(--ink-1);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
    backdrop-filter: blur(10px);
}
.icon-button:hover {
    border-color: var(--gold);
    color: var(--gold-soft);
    transform: translateY(-1px);
}

.primary-button,
.secondary-button,
.choice-button {
    border-radius: var(--radius-md);
    border: 1px solid var(--line-strong);
    color: var(--ink-0);
    background: rgba(22, 24, 32, 0.82);
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.primary-button {
    min-width: 220px;
    min-height: 52px;
    padding: 0 24px;
    border-color: var(--gold);
    background: linear-gradient(180deg, #ffd966, var(--gold));
    color: #1a1406;
    font-weight: 800;
    letter-spacing: 0.08em;
    box-shadow: 0 10px 28px rgba(240, 200, 75, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.primary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(240, 200, 75, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.primary-button:disabled {
    cursor: wait;
    opacity: 0.55;
    background: linear-gradient(180deg, #2a2a2a, #1a1a1a);
    color: var(--ink-2);
    border-color: var(--line-strong);
    box-shadow: none;
}

.secondary-button {
    width: 100%;
    min-height: 34px;
    margin-top: 10px;
    color: var(--ink-1);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--line);
    font-size: 12px;
}
.secondary-button:hover {
    border-color: var(--ally);
    color: var(--ally);
}

/* ---------- Choice list (3 cards) ---------- */

.choice-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: min(900px, 100%);
}

.choice-button {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    min-height: 110px;
    padding: 14px 16px;
    text-align: left;
    position: relative;
    overflow: hidden;
}
.choice-button::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: var(--gold);
    transform: scaleX(0.25);
    transform-origin: left;
    transition: transform 220ms ease;
}
.choice-button:hover:not(:disabled) {
    border-color: var(--gold);
    background: rgba(40, 32, 18, 0.9);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.choice-button:hover:not(:disabled)::before { transform: scaleX(1); }

.choice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.choice-button strong {
    color: var(--gold-soft);
    font-size: 15px;
    font-weight: 700;
}
.choice-button small {
    color: var(--ink-1);
    font-size: 12px;
    line-height: 1.5;
}
.choice-button em {
    flex-shrink: 0;
    padding: 3px 8px;
    border: 1px solid var(--line-gold);
    border-radius: 999px;
    color: var(--gold);
    font-size: 11px;
    font-style: normal;
    font-weight: 600;
    white-space: nowrap;
}
.choice-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    filter: grayscale(0.4);
}

/* ---------- Battle summary ---------- */

.battle-summary {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 18px;
    border: 1px solid var(--line-gold);
    border-radius: var(--radius-md);
    background:
        linear-gradient(135deg, rgba(240, 200, 75, 0.1), transparent 70%),
        rgba(14, 12, 8, 0.85);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    width: min(720px, 100%);
}
.battle-summary-text { flex: 1; min-width: 0; }
.battle-summary h2 { margin-bottom: 4px; }
.battle-summary p {
    color: var(--ink-1);
    font-size: 13px;
}

/* ---------- Status inspector ---------- */

.status-panel {
    border-color: rgba(121, 216, 255, 0.22);
    background:
        linear-gradient(135deg, rgba(121, 216, 255, 0.08), transparent 55%),
        rgba(6, 10, 18, 0.7);
}
.status-panel h2 { color: var(--ally); }

.status-source {
    margin: -2px 0 6px;
    color: var(--ally);
    font-size: 11px;
    letter-spacing: 0.04em;
    opacity: 0.85;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 4px 0 8px;
}
.status-grid span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    border: 1px solid rgba(121, 216, 255, 0.12);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.24);
}
.status-grid i {
    font-style: normal;
    color: var(--ink-3);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.status-grid b {
    color: var(--ink-0);
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.empty-hint {
    padding: 14px 6px;
    text-align: center;
    font-size: 12px;
    line-height: 1.6;
}

/* ---------- Artifacts ---------- */

.artifact-grid {
    display: grid;
    gap: 8px;
}
.artifact-card {
    position: relative;
    padding: 10px 12px;
    border: 1px solid var(--line-gold);
    border-radius: var(--radius-sm);
    background:
        linear-gradient(135deg, rgba(240, 200, 75, 0.06), transparent 70%),
        rgba(18, 15, 8, 0.6);
}
.artifact-card strong {
    display: block;
    color: var(--gold-soft);
    font-size: 13px;
    font-weight: 700;
}
.artifact-card p {
    margin: 4px 0 6px;
    color: var(--ink-1);
    font-size: 11px;
    line-height: 1.5;
}
.artifact-card small {
    display: block;
    color: var(--ink-3);
    font-size: 11px;
    letter-spacing: 0.02em;
}

/* ---------- Keyword pills ---------- */

.keyword-cloud,
.unit-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink-1);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: default;
    position: relative;
    transition: transform 120ms ease, border-color 120ms ease;
}
.keyword-pill b {
    font-weight: 800;
    color: var(--ink-0);
    font-variant-numeric: tabular-nums;
}
.keyword-pill:hover { transform: translateY(-1px); }

.keyword-giant     { border-color: rgba(240, 200, 75, 0.5);  background: rgba(240, 200, 75, 0.12); color: var(--gold-soft); }
.keyword-flying    { border-color: rgba(121, 216, 255, 0.5); background: rgba(121, 216, 255, 0.12); color: #bfecff; }
.keyword-poison    { border-color: rgba(141, 223, 90, 0.5);  background: rgba(141, 223, 90, 0.12); color: #d5f5b8; }
.keyword-fire      { border-color: rgba(255, 122, 56, 0.55); background: rgba(255, 122, 56, 0.14); color: #ffd0b0; }
.keyword-bloodlust { border-color: rgba(225, 78, 101, 0.55); background: rgba(225, 78, 101, 0.14); color: #ffc2ce; }
.keyword-sharp     { border-color: rgba(255, 246, 223, 0.45); background: rgba(255, 246, 223, 0.08); color: var(--ink-0); }

/* ---------- Tooltip ---------- */

.has-tooltip { position: relative; }
.has-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 100;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    padding: 8px 10px;
    border: 1px solid var(--line-gold);
    border-radius: var(--radius-sm);
    background: rgba(10, 10, 14, 0.98);
    color: var(--ink-0);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: normal;
    text-align: left;
    white-space: normal;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

.muted { color: var(--ink-3); }

/* ---------- Utility ---------- */

.panel .muted { font-size: 12px; }

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
    .shell {
        grid-template-columns: 280px minmax(0, 1fr) 300px;
    }
    .brand h1 { font-size: 26px; }
}

@media (max-width: 1024px) {
    body { overflow: auto; }
    .shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(480px, 60vh) auto;
        height: auto;
        min-height: 100vh;
    }
    .sidebar { max-height: none; border: none; border-bottom: 1px solid var(--line); }
    .sidebar-right { border-bottom: none; border-top: 1px solid var(--line); }
    .stage { padding: 10px; }
    .choice-list { grid-template-columns: 1fr; }
    .battle-summary { flex-direction: column; align-items: stretch; }
    .primary-button { width: 100%; }
}
