/* =============================================================
   恐龙快跑 —— 界面层样式
   黑白极简：只用一条实线做层级，靠字号与留白区分，不用颜色。
   ============================================================= */

:root {
    --ink: #111;
    --paper: #f7f7f7;
    --paper-2: #fff;
    --line: #111;
    --line-soft: #c9c9c9;
    --text: #111;
    --text-dim: #6f6f6f;
    --text-mute: #9a9a9a;
    --radius: 0px;
    --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    touch-action: manipulation;
}

body {
    position: fixed;
    inset: 0;
    width: 100%;
}

#stage {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    touch-action: none;
}

.hidden {
    display: none !important;
}

/* ---------------- 启动画面 ---------------- */

.boot {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 20px;
    background: var(--paper);
    transition: opacity .4s ease, visibility .4s;
}

.boot--done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.boot__mark {
    display: flex;
    gap: 5px;
}

.boot__mark i {
    width: 10px;
    height: 10px;
    background: var(--ink);
    animation: boot-hop .9s steps(2, end) infinite;
}

.boot__mark i:nth-child(2) {
    animation-delay: .12s;
}

.boot__mark i:nth-child(3) {
    animation-delay: .24s;
}

.boot__text {
    margin: 0;
    font-size: 12px;
    letter-spacing: .3em;
    color: var(--text-mute);
}

@keyframes boot-hop {

    0%,
    100% {
        transform: translateY(4px);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* ---------------- 界面容器 ---------------- */

.ui {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    display: grid;
    overflow: hidden;
}

.panel {
    grid-area: 1 / 1;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* safe center：内容比屏幕高时不会把顶部裁掉 */
    justify-content: safe center;
    gap: 14px;
    padding: calc(14px + var(--safe-t)) 16px calc(14px + var(--safe-b));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    animation: panel-in .22s ease;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.panel__scrim {
    position: absolute;
    inset: 0;
    background: rgba(247, 247, 247, .84);
    z-index: -1;
}

/* ---------------- 标题 ---------------- */

.title {
    text-align: center;
    margin: 0;
    line-height: 1;
    display: grid;
    justify-items: center;
    gap: 10px;
}

/* 标题上那只大鸡王：游戏里正在跑的那一帧原样放大，不是另画的宣传图 */
.hero {
    display: block;
    line-height: 0;
}

.hero canvas {
    image-rendering: pixelated;
    /* 窄屏按比例缩下去，别把下面的按钮挤出屏幕 */
    max-width: min(42vw, 150px);
    height: auto;
}

.title__main {
    display: block;
    font-size: clamp(34px, 9vw, 62px);
    font-weight: 800;
    letter-spacing: .18em;
    text-indent: .18em;
    color: var(--ink);
}

.title__sub {
    display: block;
    font-size: 11px;
    letter-spacing: .5em;
    text-indent: .5em;
    color: var(--text-mute);
    padding-top: 9px;
    /* 上下两条细线把副标题夹住，比光秃秃一行字更收得住 */
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 9px;
}

/* ---------------- 卡片 ---------------- */

.card {
    width: min(560px, 100%);
    background: var(--paper-2);
    border: 1px solid var(--ink);
    padding: 14px 16px;
}

.card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line-soft);
}

.card__title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .22em;
    color: var(--ink);
}

.card__hint {
    font-size: 12px;
    color: var(--text-mute);
}

/* 数据行 */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 1px;
    background: var(--line-soft);
}

.stats--3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat {
    background: var(--paper-2);
    padding: 9px 10px;
}

.stat__k {
    display: block;
    font-size: 11px;
    color: var(--text-mute);
    letter-spacing: .1em;
}

.stat__v {
    display: block;
    margin-top: 2px;
    font-family: var(--mono);
    font-size: 19px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.stat__v--gold,
.stat__v--hot {
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
}

/* 列表（任务 / 勋章） */
.list {
    display: grid;
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--line-soft);
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    background: var(--paper-2);
}

.row__icon {
    flex: none;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-soft);
    font-size: 14px;
    line-height: 1;
}

.row__body {
    flex: 1 1 auto;
    min-width: 0;
}

.row__name {
    font-size: 13px;
    font-weight: 600;
}

.row__desc {
    font-size: 11px;
    color: var(--text-mute);
    margin-top: 1px;
}

.row--done {
    background: #fff;
}

.row--done .row__name::after {
    content: " ✓";
    color: var(--ink);
}

.row--locked {
    opacity: .45;
}

.bar {
    flex: none;
    width: 68px;
    height: 4px;
    background: var(--line-soft);
}

.bar__fill {
    height: 100%;
    background: var(--ink);
}

.bar__fill--ok {
    background: var(--ink);
}

/* 皮肤 */
.skins {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    gap: 8px;
}

.skin {
    border: 1px solid var(--line-soft);
    background: var(--paper-2);
    padding: 9px 6px 7px;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    display: grid;
    justify-items: center;
    gap: 5px;
    transition: border-color .15s ease, transform .12s ease;
}

.skin__chip {
    width: 26px;
    height: 26px;
    border: 1px solid var(--line-soft);
}

.skin__name {
    font-size: 12px;
    letter-spacing: .08em;
}

.skin__cost {
    font-size: 10px;
    color: var(--text-mute);
    font-family: var(--mono);
}

.skin--on {
    border-color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.skin--locked {
    opacity: .42;
    cursor: not-allowed;
}

/* ---------------- 按钮 ---------------- */

.btn {
    appearance: none;
    border: 1px solid var(--ink);
    background: var(--paper-2);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    letter-spacing: .12em;
    padding: 12px 22px;
    cursor: pointer;
    transition: transform .1s ease, background .15s ease, color .15s ease;
    touch-action: manipulation;
}

.btn:hover {
    background: #ececec;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.btn--primary {
    background: var(--ink);
    color: var(--paper-2);
}

.btn--primary:hover {
    background: #2b2b2b;
}

.btn--hot {
    background: var(--paper-2);
    border-style: dashed;
}

.btn--hot:hover {
    background: var(--ink);
    color: var(--paper-2);
    border-style: solid;
}

.btn--ghost {
    background: transparent;
    border-color: var(--line-soft);
    color: var(--text-dim);
}

.btn--sm {
    padding: 7px 12px;
    font-size: 12px;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.actions .btn {
    width: min(320px, 100%);
}

.actions .btn-row .btn {
    width: auto;
    flex: 1 1 auto;
    min-width: 108px;
}

/* ---------------- 键位提示 ---------------- */

.keys {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 5px 9px;
    max-width: 460px;
    font-size: 11px;
    color: var(--text-mute);
}

.keys kbd {
    font-family: var(--mono);
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid var(--line-soft);
    color: var(--text-dim);
}

.tip {
    margin: 0;
    font-size: 11px;
    color: var(--text-mute);
    text-align: center;
    max-width: 380px;
    letter-spacing: .05em;
}

.phase {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: .08em;
}

/* ---------------- 昼夜小图标 ---------------- */

.glyph {
    flex: none;
    width: 26px;
    height: 14px;
    opacity: .8;
}

.glyph path,
.glyph circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
}

.glyph .fill {
    fill: currentColor;
    stroke: none;
}

/* ---------------- 标签 ---------------- */

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    border: 1px solid var(--line-soft);
    color: var(--text-dim);
}

.tag--gold,
.tag--live,
.tag--new {
    border-color: var(--ink);
    color: var(--ink);
}

.tag--new {
    background: var(--ink);
    color: var(--paper-2);
    animation: tag-pop .5s cubic-bezier(.2, 1.6, .4, 1);
}

@keyframes tag-pop {
    from {
        transform: scale(.5);
        opacity: 0;
    }
}

/* ---------------- 结算卡 ---------------- */

.over__score {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}

.over__num {
    font-family: var(--mono);
    font-size: clamp(44px, 13vw, 68px);
    font-weight: 600;
    line-height: 1;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.over__unit {
    font-size: 12px;
    color: var(--text-mute);
    letter-spacing: .2em;
}

.over__delta {
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    min-height: 18px;
}

.over__delta b {
    color: var(--ink);
    font-family: var(--mono);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------------- 设置行 ---------------- */

.opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px;
    background: var(--paper-2);
}

.opt__label {
    font-size: 13px;
}

.opt__desc {
    font-size: 11px;
    color: var(--text-mute);
    margin-top: 1px;
}

.switch {
    flex: none;
    width: 42px;
    height: 22px;
    border: 1px solid var(--ink);
    background: var(--paper-2);
    position: relative;
    cursor: pointer;
    transition: background .15s ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--line-soft);
    transition: transform .18s cubic-bezier(.3, 1.4, .5, 1), background .15s ease;
}

.switch[aria-checked="true"] {
    background: var(--ink);
}

.switch[aria-checked="true"]::after {
    transform: translateX(20px);
    background: var(--paper-2);
}

.switch:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* ---------------- 触屏操作 ---------------- */

.pad {
    position: absolute;
    inset: auto 0 0 0;
    z-index: 15;
    height: min(38vh, 250px);
    pointer-events: none;
}

.pad__btn {
    position: absolute;
    bottom: calc(16px + var(--safe-b));
    appearance: none;
    border: 1px solid var(--ink);
    background: rgba(247, 247, 247, .5);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    letter-spacing: .1em;
    border-radius: 50%;
    pointer-events: auto;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    touch-action: none;
    transition: transform .08s ease, background .15s ease;
}

.pad__btn--jump {
    right: 16px;
    width: 92px;
    height: 92px;
    font-size: 20px;
}

.pad__btn--duck {
    left: 16px;
    width: 72px;
    height: 72px;
    font-size: 16px;
}

.pad__btn--rampage {
    right: 122px;
    bottom: calc(92px + var(--safe-b));
    width: 66px;
    height: 66px;
    font-size: 13px;
    opacity: .32;
}

.pad__btn--rampage:not([disabled]) {
    opacity: 1;
    background: var(--ink);
    color: var(--paper-2);
}

.pad__btn--active {
    transform: scale(.93);
    background: rgba(17, 17, 17, .18);
}

.pad__ring {
    position: absolute;
    inset: -5px;
    border: 1px solid var(--ink);
    border-radius: 50%;
    opacity: 0;
}

.pad__btn--rampage:not([disabled]) .pad__ring {
    animation: pad-ring 1.1s ease-out infinite;
}

@keyframes pad-ring {
    0% {
        opacity: .9;
        transform: scale(.85);
    }

    100% {
        opacity: 0;
        transform: scale(1.25);
    }
}

/* ---------------- 吐司 ---------------- */

.toast {
    position: absolute;
    left: 50%;
    bottom: calc(20px + var(--safe-b));
    transform: translate(-50%, 16px);
    z-index: 30;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
}

.toast--on {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--paper-2);
    border: 1px solid var(--ink);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    animation: toast-in .25s cubic-bezier(.2, 1.3, .4, 1);
}

@keyframes toast-in {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
}

/* ---------------- 无障碍 / 小屏 ---------------- */

.noscript {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: grid;
    place-content: center;
    text-align: center;
    padding: 24px;
    background: var(--paper);
}

@media (max-height: 560px) {
    .panel {
        gap: 9px;
    }

    .card {
        padding: 10px 12px;
    }

    .title__main {
        font-size: clamp(26px, 7vw, 38px);
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}