:root {
    --wrap-w: 1000px;
    --gap: 12px;
    --card-w: 300px;
    --card-h: 420px;
    --img-h: 200px;
    --brand: #4aa3ff;
    --accent: #ffd66b;
    --panel: #1f1f1f;
    --panel-2: #2a2a2a;
    --text: #eaeaea;
    --muted: #9aa0a6;
}

body {
    color: var(--text);
    background: #111;
}

.wrap {
    width: var(--wrap-w);
    max-width: calc(100vw - 32px);
    margin: 20px auto 80px;
}

.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;
}

header .site-title {
    display: none;
}

/* tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 16px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #3a3a3a;
    background: #181818;
    color: #fff;
    cursor: pointer;
    transition: transform .06s ease;
}

.tab-btn[aria-selected="true"] {
    background: #223;
    border-color: #3e5bff;
    box-shadow: 0 0 0 2px rgba(62, 91, 255, .2) inset;
}

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

/* panels */
.panel {
    background: var(--panel);
    border: 1px solid #2c2c2c;
    border-radius: 14px;
    padding: 16px;
}

.h1 {
    font-size: 1.6rem;
    margin: 0 0 8px;
}

.h2 {
    font-size: 1.25rem;
    margin: 20px 0 8px;
}

/* cards grid */
.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
}

@media (max-width:900px) {
    .cards {
        grid-template-columns: 1fr;
    }
}

/* card look */
.card {
    width: 100%;
    height: var(--card-h);
    background: linear-gradient(180deg, #3b2f22 0%, #2a2118 100%);
    border: 2px solid #5c4a33;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 3px #20170f, 0 6px 18px rgba(0, 0, 0, .35);
}

.card-head {
    height: var(--img-h);
    background: #0f0f0f;
    border-bottom: 1px solid #000;
    position: relative;
}

.card-head .img-box {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-head img {
    width: auto;
    height: calc(var(--img-h) - 26px);
    object-fit: contain;
    image-rendering: auto;
}

.card-name {
    text-align: center;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 6px 8px;
    color: #fff;
    border-top: 1px solid #3a2e23;
    background: #20170f;
}

.card-grade {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .85rem;
    background: #00000099;
    border: 1px solid #ffffff22;
}

.card-body {
    padding: 10px 12px;
    color: #ddd;
    font-size: .95rem;
    line-height: 1.35;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    background: #2b2b2b;
    border: 1px solid #3a3a3a;
    font-size: .85rem;
}

.badge.S {
    background: #1d2b3d;
    border-color: #345;
    color: #9ad3ff;
}

.badge.A {
    background: #33243a;
    border-color: #554;
    color: #e7b3ff;
}

.badge.B {
    background: #2f2f2f;
    color: #bbb;
}

/* controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 12px 0;
}

.btn {
    appearance: none;
    border: 1px solid #3a3a3a;
    background: #1a1a1a;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .2s ease, transform .06s ease;
}

.btn:hover {
    background: #232323;
}

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

.btn.primary {
    background: linear-gradient(180deg, #2b63ff, #1634a8);
    border-color: #3457ff;
}

.btn.warn {
    background: #48241f;
    border-color: #6a3a32;
}

.btn.stop {
    background: #6b0c0c;
    border-color: #a33;
}

/* stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
    margin-top: 16px;
}

@media (max-width:900px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--panel-2);
    border: 1px solid #303030;
    border-radius: 10px;
    padding: 12px;
}

.stat-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95rem;
}

.stat-card th,
.stat-card td {
    padding: 6px 8px;
    border-bottom: 1px dashed #343434;
    text-align: center;
}

.stat-card th:first-child,
.stat-card td:first-child {
    text-align: left;
}

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

.money {
    font-weight: 700;
    color: var(--accent);
}

/* tabs visibility */
.tabpanel[hidden] {
    display: none;
}

/* cube-only */
.cube-area {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 12px;
}

@media (max-width: 900px) {
    .cube-area {
        grid-template-columns: 1fr;
    }
}

.card.one {
    height: auto;
}

.pot-box {
    margin-top: 6px;
    background: #0f0f0f;
    border: 1px solid #2b2b2b;
    border-radius: 10px;
    padding: 12px;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.pot-line {
    background: #17202a;
    border: 1px solid #223344;
    border-radius: 8px;
    padding: 8px 10px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellips
}

.cube-controls .btn {
    width: 100%;
    margin: 4px 0;
}

/* 卡片用的潛能盒（比洗方塊的小一點） */
.card .card-pot {
    min-height: 84px;
    gap: 6px;
}

.card .card-pot .pot-line {
    font-size: .9rem;
    padding: 6px 8px;
}

@media (max-width: 600px) {

    /* 抽卡三張卡保持單欄、優先看到名稱與按鈕 */
    .cards {
        grid-template-columns: 1fr;
    }

    /* 手機版不顯示圖片與潛能條（僅保留名稱與稀有度） */
    .card .img-box,
    .card .card-pot {
        display: none;
    }

    /* 卡片高度可縮小一點 */
    .card {
        height: auto;
    }

    .card-head {
        height: 0px;
    }

    .card-body {
        padding-bottom: 12px;
    }
}

.h1 {
    text-align: center;
}



/* 廣告區 */
.ad {
    position: relative;
    top: 12px;
    width: 970px;
    height: 90px;
    /* background: #333;
    border: 1px dashed #aaa;
    color: #fff; */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 8px;
    z-index: 1;
}

/* 底部位置 */
.ad-bottom-test {
    left: calc(50% - 485px);
}

/* 小螢幕隱藏，避免擠壓內容 */
@media (max-width: 1400px) {
    .ad {
        display: none;
    }
}