/* ==================================================
   骰布 67 · 复古像素街机风
   深紫黑底 + 单紫 accent + 硬阴影像素块 + 等宽字体
   ================================================== */

:root {
    --bg: #14101f;
    --bg2: #1c1630;
    --panel: #241b3d;
    --line: #3d2f63;
    --acc: #a78bfa;
    --acc-deep: #7c5ce0;
    --fg: #efeaff;
    --dim: #9d90c4;
    --gold: #ffd24a;
    --red: #ff5d5d;
    --green: #6fe3a1;
    --px: 4px; /* 像素单位 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: "Courier New", ui-monospace, monospace;
    background: var(--bg);
    color: var(--fg);
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    /* 像素网格底纹 */
    background-image:
        linear-gradient(rgba(167, 139, 250, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(167, 139, 250, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
}

.hidden { display: none !important; }
.g-acc { color: var(--acc); }
.g-dim { color: var(--dim); font-size: 13px; line-height: 1.7; }

/* ---------- 顶栏 ---------- */

.g-nav {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    border-bottom: var(--px) solid var(--line);
    background: var(--bg2);
}
.g-brand { font-weight: 900; font-size: 20px; letter-spacing: 2px; }
.g-nav-sub { flex: 1; font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.g-net { font-size: 14px; color: var(--red); }
.g-net.on { color: var(--green); }

/* ---------- 布局 ---------- */

.g-wrap { max-width: 640px; margin: 0 auto; padding: 18px 14px 32px; }

.g-card {
    background: var(--panel);
    border: var(--px) solid var(--line);
    box-shadow: var(--px) var(--px) 0 #000;
    padding: 22px 18px;
}
.g-center { text-align: center; }

/* ---------- 首页 ---------- */

.g-logo {
    text-align: center; font-size: 40px; font-weight: 900; letter-spacing: 4px;
    text-shadow: var(--px) var(--px) 0 #000;
}
.g-tag { text-align: center; margin-top: 10px; color: var(--dim); font-size: 12.5px; line-height: 1.8; }

.g-rules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 4px; }
.g-rule {
    border: 3px solid var(--line); background: var(--bg2);
    text-align: center; padding: 8px 2px;
    box-shadow: 3px 3px 0 #000;
}
.g-rule span { display: block; font-size: 10px; color: var(--dim); }
.g-rule b { font-size: 14px; }
.g-rule.win b { color: var(--green); }
.g-rule.lose b { color: var(--red); }

.g-label { display: block; margin-top: 16px; font-size: 12px; color: var(--dim); letter-spacing: 1px; }
.g-input {
    display: block; width: 100%; margin-top: 8px;
    height: 48px; padding: 0 12px;
    background: var(--bg); color: var(--fg);
    border: 3px solid var(--line);
    font-family: inherit; font-size: 15px;
    outline: none; border-radius: 0;
}
.g-input:focus { border-color: var(--acc); box-shadow: 3px 3px 0 #000; }

.g-seg { display: flex; gap: 8px; margin-top: 8px; }
.g-seg button {
    flex: 1; height: 42px; font-family: inherit; font-weight: 700; font-size: 14px;
    background: var(--bg); color: var(--dim);
    border: 3px solid var(--line); cursor: pointer;
}
.g-seg button.on { background: var(--acc-deep); color: #fff; border-color: var(--acc); box-shadow: 3px 3px 0 #000; }

.g-home-btns { display: flex; gap: 10px; margin-top: 20px; }

.g-btn {
    flex: 1; height: 50px;
    font-family: inherit; font-size: 15px; font-weight: 900; letter-spacing: 1px;
    background: var(--bg2); color: var(--fg);
    border: var(--px) solid var(--line);
    box-shadow: var(--px) var(--px) 0 #000;
    cursor: pointer;
    transition: transform 0.05s;
}
.g-btn:active { transform: translate(var(--px), var(--px)); box-shadow: none; }
.g-btn:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: var(--px) var(--px) 0 #000; }
.g-btn-main { background: var(--acc-deep); border-color: var(--acc); color: #fff; }
.g-btn-ghost { background: transparent; color: var(--dim); font-size: 12px; height: 40px; margin-top: 14px; width: 100%; }

.g-msg { min-height: 20px; margin-top: 12px; font-size: 12.5px; color: var(--red); text-align: center; }
.g-tip { margin-top: 12px; font-size: 11px; color: var(--dim); line-height: 1.9; text-align: center; }

/* ---------- 等候厅 ---------- */

#gLobby h2 { margin: 14px 0 8px; letter-spacing: 2px; }
.g-room-code {
    margin: 16px auto 6px; padding: 10px; font-size: 13px; color: var(--dim);
    border: 3px dashed var(--line); letter-spacing: 2px;
}
.g-room-code b { color: var(--acc); }

.g-pixel-loader { display: flex; gap: 8px; justify-content: center; }
.g-pixel-loader span {
    width: 14px; height: 14px; background: var(--acc);
    animation: pxblink 1s steps(2) infinite;
}
.g-pixel-loader span:nth-child(2) { animation-delay: 0.25s; }
.g-pixel-loader span:nth-child(3) { animation-delay: 0.5s; }
.g-pixel-loader span:nth-child(4) { animation-delay: 0.75s; }
@keyframes pxblink { 0%, 100% { opacity: 1; } 50% { opacity: 0.15; } }

/* ---------- 计分板 ---------- */

.g-score {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    background: var(--panel); border: var(--px) solid var(--line);
    box-shadow: var(--px) var(--px) 0 #000;
    padding: 10px 14px;
}
.g-score-side { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.g-score-side.right { justify-content: flex-end; }
.g-sname { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 80px; }
.g-snum { font-size: 32px; font-weight: 900; }
.g-score-side.lead .g-snum { color: var(--acc); }
.g-score-mid { text-align: center; padding: 0 8px; }
.g-round { font-size: 14px; font-weight: 900; letter-spacing: 1px; }
.g-target-line { font-size: 10px; color: var(--dim); margin-top: 2px; }

/* ---------- 竞技场 ---------- */

.g-arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 12px; align-items: stretch; }
.g-vs { align-self: center; font-weight: 900; color: var(--dim); letter-spacing: 1px; }

.g-panel {
    background: var(--panel); border: var(--px) solid var(--line);
    box-shadow: var(--px) var(--px) 0 #000;
    padding: 12px 10px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.g-panel.me { border-color: var(--acc); }
.g-panel.lost { border-color: var(--red); }

.g-phead { display: flex; gap: 8px; align-items: center; width: 100%; justify-content: center; }
.g-pname { font-weight: 900; font-size: 13px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-offline { display: none; font-size: 10px; color: var(--red); border: 2px solid var(--red); padding: 0 4px; }
.g-panel.off .g-offline { display: inline; }

/* 像素骰子：3×3 方点 */
.g-dice {
    width: 72px; height: 72px;
    background: var(--bg); border: 3px solid var(--line);
    box-shadow: 3px 3px 0 #000;
    padding: 8px;
}
.g-pips { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 100%; height: 100%; }
.g-pips i { width: 10px; height: 10px; background: var(--fg); place-self: center; visibility: hidden; }
.g-dice.rolling { animation: diceshake 0.5s steps(4) infinite; }
@keyframes diceshake {
    0% { transform: translate(0, 0); } 25% { transform: translate(-3px, 2px); }
    50% { transform: translate(3px, -2px); } 75% { transform: translate(-2px, -3px); }
}

.g-hand {
    width: 60px; height: 60px; font-size: 32px;
    background: var(--bg); border: 3px dashed var(--line);
    display: flex; align-items: center; justify-content: center;
    color: var(--dim);
}
.g-hand.pop { animation: handpop 0.3s steps(3); border-style: solid; }
@keyframes handpop { 0% { transform: scale(0.4); } 100% { transform: scale(1); } }

.g-count { text-align: center; min-height: 52px; }
.g-count b { font-size: 36px; font-weight: 900; display: block; line-height: 1; }
.g-count span { font-size: 10px; color: var(--dim); display: block; margin-top: 4px; }

/* 0 / 67 特效 */
.g-panel.fx0 { border-color: var(--gold); }
.g-panel.fx0 .g-count b { color: var(--gold); text-shadow: 3px 3px 0 #7a5b00; animation: pxblink 0.8s steps(2) infinite; }
.g-panel.fx67 { border-color: var(--red); animation: quake 0.4s steps(4) 3; }
.g-panel.fx67 .g-count b { color: var(--red); text-shadow: 3px 3px 0 #6b0000; animation: pxblink 0.8s steps(2) infinite; }
@keyframes quake {
    0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-4px, 0); }
    50% { transform: translate(4px, 0); } 75% { transform: translate(-4px, 2px); }
}

/* ---------- 判定 / 操作 ---------- */

/* 像素拳图标：currentColor 上色 + 关闭抗锯齿保持点阵锐利 */
.px-icon {
    width: 34px; height: 34px;
    fill: currentColor;
    shape-rendering: crispEdges;
    image-rendering: pixelated;
}
.g-hand .px-icon { width: 32px; height: 32px; color: var(--fg); }
.g-hl .px-icon { width: 16px; height: 16px; vertical-align: -3px; }

.g-btn-surrender {
    width: 100%; margin-top: 10px; height: 40px;
    background: transparent; color: var(--red); border-color: var(--red);
    font-size: 12.5px; letter-spacing: 2px;
}

.g-verdict { margin-top: 14px; text-align: center; font-size: 14px; font-weight: 700; min-height: 24px; line-height: 1.6; }
.g-verdict .who { color: var(--red); }

#gControls { margin-top: 12px; }
.g-pick-tip { text-align: center; font-size: 12px; color: var(--dim); margin-bottom: 10px; min-height: 16px; }
.g-pick-tip b { color: var(--acc); }

.g-hand-row { display: flex; gap: 10px; }
.g-hand-row button {
    flex: 1; height: 76px; font-size: 32px;
    background: var(--panel); border: var(--px) solid var(--line);
    box-shadow: var(--px) var(--px) 0 #000; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.g-hand-row button small { font-size: 11px; font-family: inherit; color: var(--dim); font-weight: 700; }
.g-hand-row button:active { transform: translate(var(--px), var(--px)); box-shadow: none; }
.g-hand-row button.picked { border-color: var(--acc); background: var(--acc-deep); }
.g-hand-row button.picked small { color: #fff; }
.g-hand-row button:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: var(--px) var(--px) 0 #000; }

#gNext { width: 100%; margin-top: 4px; }

/* 倒数 */
.g-countdown {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(20, 16, 31, 0.92);
    display: flex; align-items: center; justify-content: center;
    font-size: 110px; font-weight: 900; color: var(--acc);
    text-shadow: 6px 6px 0 #000;
}
.g-countdown.go { color: var(--red); font-size: 72px; }

/* ---------- 历史 ---------- */

.g-hist { margin-top: 18px; }
.g-hist-title { font-size: 11px; color: var(--dim); letter-spacing: 2px; margin-bottom: 8px; }
#gHist { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#gHist li {
    display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center;
    background: var(--panel); border: 3px solid var(--line);
    padding: 8px 10px; font-size: 12px;
    box-shadow: 3px 3px 0 #000;
}
.g-hl { display: flex; gap: 6px; align-items: center; min-width: 0; }
.g-hl.right { justify-content: flex-end; }
.g-hl .n { font-weight: 900; }
.g-hl .n.lose { color: var(--red); }
.g-hl .n.win { color: var(--green); }
.g-hl-mid { text-align: center; font-size: 10px; color: var(--dim); line-height: 1.5; }

/* ---------- 终局 ---------- */

.g-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(20, 16, 31, 0.94);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.g-overlay .g-card { width: 100%; max-width: 360px; }
.g-end-emoji { font-size: 52px; }
.g-overlay h2 { margin: 12px 0 8px; font-size: 22px; letter-spacing: 2px; }
.g-overlay .g-btn { margin-top: 16px; width: 100%; }
.g-overlay .g-btn-ghost { margin-top: 10px; }

/* ---------- 竖屏单列 ---------- */

@media (max-width: 560px) {
    .g-arena { grid-template-columns: 1fr; }
    .g-vs { text-align: center; font-size: 12px; }
    .g-panel { flex-direction: row; justify-content: space-between; padding: 10px 12px; }
    .g-phead { flex-direction: column; gap: 4px; width: auto; flex: 1; align-items: flex-start; }
    .g-dice { width: 56px; height: 56px; padding: 6px; }
    .g-pips i { width: 8px; height: 8px; }
    .g-hand { width: 48px; height: 48px; font-size: 26px; }
    .g-count b { font-size: 28px; }
    .g-count { min-height: 44px; }
}
