:root {
    --ink: #241c12;
    --paper: #fbf6ec;
    --paper-2: #f3ead9;
    --line: #e6d7bf;
    --muted: #8b7a5f;
    --muted-2: #a08a6a;
    --accent: #c4552d;
    --wood-1: #f6e0bd;
    --wood-2: #e3bd88;
}

* { box-sizing: border-box; }

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

body {
    background: radial-gradient(120% 80% at 50% 0%, #fffdf8 0%, #f6efe2 55%, #efe5d3 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.app {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 18px 16px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.topbar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.brand h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: 1px;
    line-height: 1.2;
}

.brand p {
    margin: 3px 0 0;
    font-size: 10px;
    letter-spacing: 3px;
    color: var(--muted-2);
}

.ghost-btn {
    border: 0;
    background: var(--ink);
    color: #fdf6e9;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: transform .12s ease, opacity .12s ease;
}

.ghost-btn:active { transform: scale(.96); opacity: .8; }

.seg {
    width: 100%;
    display: flex;
    padding: 4px;
    gap: 2px;
    border-radius: 999px;
    background: #ece0cc;
    margin-bottom: 10px;
}

.seg-item {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    padding: 10px 0;
    border-radius: 999px;
    cursor: pointer;
    transition: all .18s ease;
}

.seg-item.is-on {
    background: #fffdf8;
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(120, 88, 46, .16);
}

.levels {
    width: 100%;
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.levels[hidden] { display: none; }

.level {
    flex: 1;
    border: 1px solid var(--line);
    background: #fffaf1;
    color: var(--muted);
    font-size: 12px;
    padding: 7px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: all .16s ease;
}

.level.is-on {
    border-color: var(--accent);
    background: #fff2e8;
    color: var(--accent);
    font-weight: 600;
}

.players {
    width: 100%;
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.player {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 253, 248, .85);
    border: 1px solid var(--line);
    transition: all .18s ease;
}

.player.is-live {
    background: #fff7ea;
    border-color: #d9a15f;
    box-shadow: 0 5px 14px rgba(180, 128, 60, .14);
}

.mini-stone {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex: none;
}

.mini-stone.black {
    background: radial-gradient(circle at 32% 28%, #6f6f6f, #161616 70%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.mini-stone.white {
    background: radial-gradient(circle at 32% 28%, #ffffff, #ddd8cf 75%);
    border: 1px solid rgba(120, 100, 70, .25);
}

.pinfo { display: flex; flex-direction: column; line-height: 1.15; }

.pname { font-size: 11px; color: #6b5a41; }

.ptime {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.board-shell {
    position: relative;
    padding: 4px;
    border-radius: 14px;
    background: linear-gradient(160deg, #e9c79a 0%, #dcae76 100%);
    box-shadow: 0 14px 30px rgba(120, 82, 38, .26), inset 0 1px 0 rgba(255, 255, 255, .5);
}

.board {
    display: grid;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(140deg, var(--wood-1) 0%, #eed0a2 55%, var(--wood-2) 100%);
    box-shadow: inset -1px -1px 0 rgba(120, 80, 40, .4);
    touch-action: manipulation;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid rgba(120, 84, 44, .36);
    border-top: 1px solid rgba(120, 84, 44, .36);
    cursor: pointer;
}

.cell:first-child { border-left: 0; }

.cell.no-top { border-top: 0; }

.cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(196, 85, 45, 0);
    transition: background .15s ease;
    pointer-events: none;
}

@media (hover: hover) {
    .cell:hover::after { background: rgba(196, 85, 45, .1); }
}

.stone {
    width: 82%;
    height: 82%;
    border-radius: 50%;
    position: relative;
    z-index: 1;
    animation: drop .16s ease-out;
}

@keyframes drop {
    from { transform: scale(.55); opacity: .4; }
    to { transform: scale(1); opacity: 1; }
}

.stone.black {
    background: radial-gradient(circle at 32% 26%, #7a7a7a 0%, #2e2e2e 42%, #050505 100%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .38), inset 0 -1px 3px rgba(0, 0, 0, .5);
}

.stone.white {
    background: radial-gradient(circle at 32% 26%, #ffffff 0%, #f7f4ee 55%, #d6cfc3 100%);
    border: 1px solid rgba(120, 100, 70, .22);
    box-shadow: 0 2px 4px rgba(80, 60, 30, .18);
}

.stone.win {
    box-shadow: 0 0 0 2px var(--accent), 0 0 12px rgba(196, 85, 45, .55);
}

.stone .dota, .stone .dotb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.stone .dota { background: #f5e9d4; opacity: .9; }
.stone .dotb { background: var(--accent); opacity: .85; }

.thinking {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(36, 28, 18, .74);
    color: #fdf6e9;
    font-size: 12px;
}

.thinking[hidden] { display: none; }

.thinking .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffb268;
    animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.statusrow {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px 6px;
}

.status { font-size: 14px; font-weight: 600; color: #4b3c28; }
.status.win { color: var(--accent); }
.moves { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.footer {
    width: 100%;
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    border: 0;
    font-size: 15px;
    padding: 13px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .12s ease, opacity .12s ease, box-shadow .12s ease;
}

.btn:active { transform: scale(.985); }

.btn.ghost {
    background: rgba(255, 253, 248, .92);
    border: 1px solid #e2d3ba;
    color: #6b5a41;
}

.btn.ghost:disabled { color: #c8bba6; cursor: default; }

.btn.solid {
    background: var(--ink);
    color: #fdf6e9;
    box-shadow: 0 8px 18px rgba(36, 28, 18, .22);
}

.hint {
    margin: 14px 0 0;
    font-size: 11px;
    color: #b3a288;
    text-align: center;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(24, 18, 12, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: fade .18s ease;
}

.overlay[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.result-card {
    width: 76%;
    max-width: 320px;
    padding: 26px 22px 20px;
    border-radius: 20px;
    background: #fffdf8;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .28);
    animation: rise .2s ease;
}

@keyframes rise { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }

.kicker {
    margin: 0;
    font-size: 10px;
    letter-spacing: 4px;
    color: #b08a58;
}

.result-card h2 {
    margin: 8px 0 0;
    font-size: 28px;
}

.sub {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted-2);
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.rbtn {
    flex: 1;
    border: 0;
    padding: 11px 0;
    border-radius: 10px;
    background: #f3e9d8;
    color: #6b5a41;
    font-size: 14px;
    cursor: pointer;
}

.rbtn.solid { background: var(--ink); color: #fdf6e9; }

@media (max-width: 360px) {
    .brand h1 { font-size: 22px; }
    .ptime { font-size: 14px; }
}

/* 矮屏收紧间距，尽量一屏放下 */
@media (max-height: 720px) {
    .app { padding: 10px 14px 12px; }
    .topbar { margin-bottom: 8px; }
    .brand h1 { font-size: 21px; }
    .brand p { letter-spacing: 2px; }
    .seg, .levels, .players { margin-bottom: 6px; }
    .seg-item { padding: 8px 0; }
    .level { padding: 5px 0; }
    .player { padding: 6px 10px; }
    .statusrow { padding: 6px 4px 4px; }
    .btn { padding: 11px 0; }
    .hint { display: none; }
}
