/* The game and tools, on top of cairn-ui.css. */
html, body { height: 100%; }
body { margin: 0; overscroll-behavior: none; }
body.cairn { min-height: 100%; }

.screen { max-width: 560px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 0 calc(110px + env(safe-area-inset-bottom)); }
.top-brand { padding-top: 4px; letter-spacing: 0.02em; }
.lead { padding: 2px 20px 18px; color: var(--sub); font-size: 14px; line-height: 1.6; }
.sec { padding: 22px 20px 8px; font-size: 13px; font-weight: 700; color: var(--sub); display: flex; justify-content: space-between; align-items: baseline; }
.sec .val { font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
.sec .val.over { color: var(--red); }
.pad { padding: 0 20px; }
.foot { text-align: center; color: var(--sub); font-size: 11px; padding: 28px 0 0; }

/* menu rows on the home screen: no cards, straight on the paper */
.m-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 20px; text-align: left; transition: transform 0.12s; }
.m-row:active { transform: scale(0.98); opacity: 0.7; }
.m-row .shape { width: 18px; height: 18px; flex-shrink: 0; color: var(--fg); }
.m-row .grow { flex: 1; }
.m-title { font-size: 16.5px; }
.m-sub { font-size: 12px; color: var(--sub); margin-top: 2px; }
.chev-r { color: var(--sub2); font-size: 15px; }

/* lobby */
.code-big { text-align: center; font-size: clamp(40px, 13vw, 54px); font-weight: 300; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; padding: 8px 0 0; }
.code-hint { text-align: center; color: var(--sub); font-size: 12px; }
.preview { display: block; width: calc(100% - 40px); margin: 0 20px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-card); }
.row-line { display: flex; align-items: center; gap: 12px; padding: 10px 20px; }
.row-line .grow { flex: 1; min-width: 0; }
.row-line .val { color: var(--sub); font-size: 13.5px; }
.chip { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 11px; background: rgba(0, 0, 0, 0.06); color: var(--fg); }
.theme-dark .chip { background: rgba(255, 255, 255, 0.09); }
.chip.enemy { color: var(--red); background: rgba(229, 72, 77, 0.1); }
.chip.ai { color: var(--sub); }
.you { color: var(--sub); font-size: 12px; margin-left: 6px; }
.c-check.on { background: var(--accent, var(--fg)); border-color: var(--accent, var(--fg)); color: var(--bg); }

.army-row { display: flex; align-items: center; gap: 12px; padding: 9px 20px; }
.army-row .shape { width: 16px; height: 16px; flex-shrink: 0; }
.army-row .grow { flex: 1; min-width: 0; }
.a-name { font-size: 16px; }
.a-cost { font-size: 12px; color: var(--sub); margin-left: 6px; font-variant-numeric: tabular-nums; }
.a-note { font-size: 12px; color: var(--sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; font-size: 19px; display: grid; place-items: center; transition: transform 0.12s; }
.stepper button:active { transform: scale(0.85); background: rgba(0, 0, 0, 0.06); }
.stepper button:disabled { opacity: 0.25; }
.stepper .n { min-width: 26px; text-align: center; font-variant-numeric: tabular-nums; font-size: 16px; }

.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 20px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.bottom-bar > * { max-width: 520px; margin: 0 auto; }
.c-btn-primary:disabled { opacity: 0.35; }

/* battle */
.battle { position: fixed; inset: 0; overflow: hidden; background: var(--bg); touch-action: none; user-select: none; -webkit-user-select: none; }
.battle canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.b-top { position: absolute; left: 0; right: 0; top: 0; padding-top: max(6px, env(safe-area-inset-top)); background: linear-gradient(var(--bg), transparent); pointer-events: none; }
.b-top .c-header { min-height: 48px; padding-top: 2px; }
.b-top .c-title { font-size: 22px; pointer-events: auto; }
.b-top .c-header-pill, .b-top .c-brand { pointer-events: auto; }
.b-top .c-brand { font-variant-numeric: tabular-nums; }
.b-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 18px calc(14px + env(safe-area-inset-bottom)); pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.b-bottom .c-toolbar { pointer-events: auto; width: min(100%, 420px); }
.b-sel { font-size: 12px; color: var(--sub); text-align: center; text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg); }
.c-toolbar button:active { transform: scale(0.9); }
.tb-label { position: absolute; bottom: 3px; left: 0; right: 0; font-size: 9px; color: rgba(255, 255, 255, 0.75); text-align: center; }

/* dialogs, menus and toasts sit on a dim layer */
.dim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.28); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade 0.18s; }
.dim.clear { background: transparent; display: block; padding: 0; }
.dim.clear .c-menu { position: fixed; }
.c-dialog { width: min(330px, 100%); }
.c-dialog .big { font-size: 27px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.c-dialog .stat { text-align: center; color: var(--sub); font-size: 13px; margin-bottom: 4px; }
.toast-box { position: fixed; left: 0; right: 0; bottom: calc(110px + env(safe-area-inset-bottom)); display: flex; justify-content: center; z-index: 60; pointer-events: none; }
@keyframes fade { from { opacity: 0; } }

.loading { text-align: center; color: var(--sub); padding: 80px 20px; font-size: 14px; }

/* cairn-ui.css resets ".cairn button" (font, background), which is stronger than a single
   class; these buttons need their own look back */
.cairn .c-title { font-size: 27px; font-weight: 800; }
.cairn .b-top .c-title { font-size: 22px; }
.cairn .c-btn-primary { background: var(--fg); color: var(--bg); }
.cairn .chip { background: rgba(0, 0, 0, 0.06); }
.cairn.theme-dark .chip { background: rgba(255, 255, 255, 0.09); }
.cairn .chip.enemy { background: rgba(229, 72, 77, 0.1); }
.cairn .c-set-row:disabled { color: inherit; }

/* campaign text reads like a journal */
.story { padding: 6px 20px 14px; font-size: 16px; line-height: 1.9; color: var(--fg); white-space: normal; }
.story.small { padding: 10px 0 4px; font-size: 13.5px; line-height: 1.8; text-align: left; max-height: 40vh; overflow: auto; }
.m-row.locked { opacity: 0.4; }
.m-row .c-check { margin-top: 0; }
.vet { font-size: 11px; color: var(--sub); margin-left: 6px; }
.side-tag { font-size: 10.5px; color: var(--sub); margin-left: 6px; border: 1px solid var(--sub2); border-radius: 999px; padding: 0 6px; }
.army-row > .n { font-variant-numeric: tabular-nums; font-size: 16px; }
.help { font-size: 13.5px; line-height: 1.8; text-align: left; }
.help b { display: inline-block; min-width: 3.2em; }

/* 3D battlefield extras */
.b-turn { position: absolute; right: 18px; top: calc(max(6px, env(safe-area-inset-top)) + 64px); flex-direction: column; }
.cairn .b-turn button { color: #fff; font-size: 18px; }
.sel-box { position: absolute; display: none; border: 1px dashed #f2f2ef; background: rgba(242, 242, 239, 0.08); pointer-events: none; }
.b-top { background: linear-gradient(rgba(242, 242, 239, 0.85), transparent); }
.theme-dark .b-top { background: linear-gradient(rgba(22, 22, 24, 0.85), transparent); }
.b-sel { color: #f2f2ef; text-shadow: 0 0 4px rgba(0, 0, 0, 0.8); }
