html,
body {
    height: 100%;
    margin: 0;
}

* {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #eceae2;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", "Helvetica Neue", Arial, sans-serif;
    color: #222;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
select {
    font-family: inherit;
}

.app {
    width: 100%;
    max-width: 390px;
    min-height: 100vh;
    margin: 0 auto;
    background: #fdfdf1;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 28px rgba(0, 0, 0, 0.18);
}

/* ========== Header ========== */
.topbar {
    position: relative;
    background: #fff;
    padding: 6px 10px 6px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    z-index: 2;
    overflow: hidden;
}

.topbar-deco {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.deco-main,
.deco-bar,
.deco-slash {
    position: absolute;
    background: #ffdd00;
}

.deco-main {
    inset: 0 0 auto 0;
    height: 82%;
    clip-path: polygon(63.75% 0, 100% 0, 100% 100%, 43.75% 100%);
}

.deco-slash {
    top: 81%;
    left: 41%;
    width: 28px;
    height: 9%;
    transform: skewX(-48deg);
    transform-origin: top left;
}

.deco-bar {
    left: 0;
    right: 0;
    top: 90%;
    height: 10%;
    clip-path: polygon(40.75% 0, 100% 0, 100% 100%, 40% 100%);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.brand-mark {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding-bottom: 1px;
}

.brand-slogan {
    font-size: 13px;
    font-weight: 800;
    color: #111;
    letter-spacing: 0.2px;
    white-space: nowrap;
    line-height: 1.25;
}

.brand-en {
    margin-top: 4px;
    padding-top: 3px;
    border-top: 1px solid #111;
    font-size: 8px;
    font-weight: 600;
    color: #111;
    letter-spacing: 0.4px;
    white-space: nowrap;
    line-height: 1;
}

.account {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.account-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-deposit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e31b23;
    color: #fff;
    border: 0;
    border-radius: 4px;
    height: 26px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    box-shadow: 0 1px 2px rgba(180, 0, 0, 0.25);
}

.user-icon {
    width: 28px;
    height: 28px;
    color: #111;
}

.balance {
    font-size: 12px;
    font-weight: 800;
    color: #111;
    letter-spacing: 0.2px;
    line-height: 1.2;
    font-family: "Helvetica Neue", Arial, "PingFang TC", sans-serif;
}

/* ========== Main nav ========== */
.main-nav {
    background: #d4141e;
    height: 38px;
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: relative;
    z-index: 2;
}

.main-nav::-webkit-scrollbar {
    display: none;
}

.main-nav a {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 0 9px;
    flex-shrink: 0;
    line-height: 38px;
    letter-spacing: 0.2px;
}

.main-nav a.is-active {
    font-weight: 700;
}

/* ========== Page ========== */
.page {
    padding: 16px 16px 88px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 16px;
    font-size: 28px;
    font-weight: 800;
    color: #111;
    letter-spacing: 0.2px;
}

.page-title svg {
    width: 22px;
    height: 22px;
    margin-top: 2px;
}

.panel {
    background: #fff;
    border: 2px solid #f0d24a;
    border-radius: 8px;
    padding: 4px 12px 14px;
    margin-bottom: 12px;
}

.tabs {
    display: flex;
    gap: 26px;
    padding: 8px 0 0;
    border-bottom: 1px solid #ececec;
}

.tab {
    appearance: none;
    background: none;
    border: 0;
    padding: 10px 0 9px;
    font-size: 16px;
    color: #b3b3b3;
    font-weight: 500;
    position: relative;
    cursor: pointer;
}

.tab.is-active {
    color: #111;
    font-weight: 800;
}

.tab.is-active::after {
    content: "";
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: -1px;
    height: 4px;
    background: #c4181a;
    border-radius: 1px;
}

.filters {
    padding: 16px 0 8px;
}

.filter-row {
    display: flex;
    align-items: center;
}

.filter-row.date-row {
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.filter-row.method-row {
    justify-content: flex-start;
    gap: 10px;
}

.filter-label {
    font-size: 14px;
    color: #111;
    flex-shrink: 0;
}

.filter-label.stacked {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    width: 32px;
}

.method-pill {
    appearance: none;
    border: 0;
    background: #d8d8d8;
    color: #111;
    font-size: 13px;
    font-weight: 500;
    height: 26px;
    padding: 0 14px;
    border-radius: 13px;
    min-width: 48px;
    text-align: center;
}

.select-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 40px;
    padding: 0 36px 0 12px;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    background: #e8e8e2;
    font-size: 15px;
    color: #333;
    outline: none;
}

.select-wrap .chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    pointer-events: none;
    color: #888;
}

/* ========== Ticket ========== */
.ticket {
    border: 2px solid #f0d24a;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.ticket-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff6c3;
    padding: 12px 12px 14px;
}

.ticket-status {
    font-size: 17px;
    font-weight: 800;
    color: #c4181a;
    line-height: 1.2;
}

.ticket-date {
    font-size: 13px;
    color: #333;
    margin-top: 4px;
    font-weight: 500;
}

.win-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.win-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #3f8f3c;
    border: 1.5px solid #3f8f3c;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 14px;
    line-height: 1.2;
}

.win-badge.is-lose {
    color: #c4181a;
    border-color: #c4181a;
}

.win-badge.is-pending {
    color: #222;
    border: 1.5px dashed #222;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    min-width: 64px;
}

body.sheet-open {
    overflow: hidden;
}

.win-caret {
    width: 12px;
    height: 12px;
    color: #333;
}

.win-caret-btn {
    appearance: none;
    border: 0;
    background: none;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ticket-body {
    padding: 14px 10px 14px;
}

.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 2px 2px 16px;
}

.result-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
}

.ticket-foot {
    display: flex;
    padding: 2px 4px 2px;
}

.stat {
    flex: 1;
}

.stat + .stat {
    border-left: 1px solid #e5e5e0;
    padding-left: 14px;
}

.stat-label {
    font-size: 13px;
    color: #6a6a6a;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 17px;
    font-weight: 800;
    color: #111;
    letter-spacing: 0.2px;
    font-family: "Helvetica Neue", Arial, "PingFang TC", sans-serif;
}

/* ========== Bottom tabbar ========== */
.tabbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    background: #fff;
    border-top: 1px solid #d4141e;
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    padding: 6px 0 0;
    gap: 0;
}

.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: auto;
    color: #1a1a1a;
    gap: 2px;
}

.tabbar-item svg {
    width: 22px;
    height: 22px;
}

.tabbar-item span {
    font-size: 11px;
    line-height: 1;
}

/* ========== Detail popup ========== */
.detail-sheet {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: #fdfdf1;
    overflow: auto;
    padding: 10px 0 70px;
}

.detail-sheet-inner {
    margin: 0 10px;
    border-left: 2px solid #f0d24a;
    border-right: 2px solid #f0d24a;
    background: #fff;
    min-height: calc(100% - 20px);
    padding: 12px 12px 20px;
}

.detail-close {
    appearance: none;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 13px;
    margin-bottom: 10px;
}

.detail-card {
    padding: 14px 0 16px;
    border-bottom: 1px solid #eee;
}

.detail-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.detail-pick {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.detail-mark {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    margin-top: 2px;
}

.detail-name {
    font-size: 16px;
    font-weight: 800;
    color: #111;
}

.detail-date {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
}

.detail-odds {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 26px;
    padding: 0 10px;
    background: #f7dfe3;
    color: #b42318;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
}

.detail-meta {
    display: flex;
    gap: 8px;
    font-size: 13px;
    color: #222;
    margin: 4px 0 4px 30px;
}

.meta-label {
    color: #888;
}

.detail-event {
    margin: 8px 0 0 30px;
}

.event-pill {
    margin-top: 4px;
    background: #efefef;
    border-radius: 16px;
    padding: 8px 12px;
    font-size: 13px;
    color: #333;
    line-height: 1.35;
}

.mask-inner {
    display: inline-block;
}

.mask-none .mask-inner {
    display: inline;
}

.mask-bar .mask-inner {
    color: transparent;
    background: #111;
    border-radius: 2px;
    user-select: none;
    -webkit-user-select: none;
    min-width: 7.5em;
    line-height: 1.25;
    padding: 1px 0;
}

.detail-name.mask-bar .mask-inner {
    min-width: 11em;
    height: 18px;
    min-height: 18px;
}

.mask-mosaic {
    position: relative;
    display: inline-flex;
    overflow: hidden;
    isolation: isolate;
    vertical-align: middle;
}

.mask-mosaic .mask-inner {
    filter: blur(6px) contrast(1.75) saturate(0.55);
    transform: scale(1.12);
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
}

.mask-mosaic::after {
    content: "";
    position: absolute;
    inset: -1px;
    background-image:
        repeating-linear-gradient(0deg, rgba(35, 35, 35, 0.28) 0 3px, rgba(255, 255, 255, 0.1) 3px 6px),
        repeating-linear-gradient(90deg, rgba(20, 20, 20, 0.22) 0 3px, rgba(255, 255, 255, 0.12) 3px 6px);
    mix-blend-mode: overlay;
    pointer-events: none;
    z-index: 2;
}

.stat-value.mask-mosaic,
.stat-value.mask-bar {
    display: block;
}

.win-badge.mask-mosaic {
    overflow: hidden;
}

.detail-odds.mask-mosaic {
    overflow: hidden;
}

.detail-odds.is-stamp {
    min-width: 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 4px;
    background: #efb4b8;
    color: #9a2a2a;
    align-items: center;
    justify-content: center;
}

.detail-odds.is-stamp .mask-inner {
    font-size: 13px;
}

.detail-ticket-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 14px;
}

.pending-sheet-head {
    background: #fff4b0;
    margin: -12px -12px 0;
    padding: 14px 14px 16px;
}

.detail-sheet-inner.is-pending-sheet {
    background: #f6f3e8;
    padding-bottom: 28px;
}

.pending-leg {
    padding: 18px 2px 22px;
    border-bottom: 1px solid #e6e2d4;
}

.pending-leg:last-child {
    border-bottom: 0;
}

.pending-field {
    margin: 14px 0 0 30px;
}

.pending-field-label {
    color: #8a8a8a;
    font-size: 13px;
    line-height: 1.3;
}

.pending-field-value {
    margin-top: 8px;
    color: #111;
    font-size: 16px;
    font-weight: 700;
}

.pending-field .event-pill {
    margin-top: 8px;
}

.pending-odds-mosaic {
    display: block;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 3px;
    background-color: #d89aa0;
    background-image:
        repeating-conic-gradient(#e7b4b8 0% 25%, #c56d74 0% 50%) 0 0 / 8px 8px;
    image-rendering: pixelated;
}

.pending-head-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pending-refresh {
    display: inline-flex;
    width: 22px;
    height: 22px;
    color: #4a4a4a;
}

.pending-refresh svg {
    width: 22px;
    height: 22px;
}

.win-caret.is-up {
    transform: rotate(0deg);
}

@media (min-width: 430px) {
    body {
        background: #cfc9b8;
        padding: 24px 0;
    }

    .app {
        min-height: 780px;
        border-radius: 8px;
        overflow: hidden;
    }
}
