:root {
  --paper: #fbf3e0;
  --paper-2: #f3e5c3;
  --ink: #4f3418;
  --ink-soft: #8a6a42;
  --accent: #d9822b;
  --accent-dark: #b9671a;
  --line: rgba(110, 70, 25, 0.22);
  --shadow: 0 10px 30px rgba(60, 30, 5, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #d9a24f; color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

:lang(ja) body, body:lang(ja) { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans CJK JP", sans-serif; }

#board { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }
#board.dragging { cursor: grabbing; }

[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
}
#hud > * { pointer-events: auto; }
.hud-right { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.chip-btn, .status {
  background: rgba(251, 243, 224, 0.94); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 3px 12px rgba(60, 30, 5, 0.25);
  font-size: 14px; line-height: 1;
}
.chip-btn { padding: 10px 14px; cursor: pointer; font-family: inherit; }
.chip-btn:hover { background: #fff8e8; }
.chip-btn:active { transform: translateY(1px); }

.status {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px;
  font-weight: 600; max-width: 100%;
}
.status img { border-radius: 50%; background: rgba(217, 162, 79, 0.55); padding: 1px; }
.badge {
  font-size: 12px; font-weight: 500; color: var(--accent-dark);
  background: rgba(217, 130, 43, 0.14); border-radius: 999px; padding: 3px 8px; white-space: nowrap;
}

/* ---------- 面板 ---------- */
.panel {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 16px 18px; width: min(440px, calc(100vw - 24px));
}
#invite { bottom: calc(24px + env(safe-area-inset-bottom)); }
.paused {
  top: calc(64px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 16px; font-size: 14px;
}
.result { bottom: calc(28px + env(safe-area-inset-bottom)); text-align: center; }
.panel-title { font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--ink-soft); font-size: 13px; margin: 4px 0 10px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fffaf0; color: var(--ink); font-size: 14px;
}
.result-text { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer; font-family: inherit;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
}
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.04); }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link-btn { display: block; margin: 12px auto 0; border: 0; background: none; color: var(--ink-soft); cursor: pointer; font-size: 14px; text-decoration: underline; font-family: inherit; }

#toast {
  position: fixed; z-index: 9; left: 50%; top: calc(72px + env(safe-area-inset-top)); transform: translateX(-50%);
  background: rgba(60, 35, 12, 0.92); color: #fff6e0; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 24px); text-align: center;
}

/* ---------- 菜单 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  background: rgba(70, 38, 8, 0.45); backdrop-filter: blur(3px); padding: 12px; overflow-y: auto;
}
.card {
  width: min(520px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--paper); border-radius: 22px; box-shadow: var(--shadow);
  padding: 26px 26px 22px; border: 1px solid var(--line);
}
.card { position: relative; }
/* 菜单卡片右上角的两只坐姿猫，直接取自图集（192px 一格，缩到 84px） */
.duo { position: absolute; right: 18px; top: 8px; display: flex; pointer-events: none; }
.duo .cat {
  display: block; width: 84px; height: 84px; background: url('../cats/atlas.png') no-repeat;
  background-size: 672px 336px; filter: drop-shadow(3px 4px 3px rgba(80, 40, 0, 0.35));
}
.duo .cat.black { background-position: -252px 0; margin-right: -36px; }
.duo .cat.white { background-position: -252px -168px; filter: drop-shadow(0 0 1.2px rgba(150, 105, 50, 0.95)) drop-shadow(0 0 1px rgba(150, 105, 50, 0.8)) drop-shadow(3px 4px 3px rgba(80, 40, 0, 0.3)); }
.card h1 { margin: 0; font-size: 28px; letter-spacing: 1px; }
.paw { filter: grayscale(0.2); }
.sub { margin: 6px 0 18px; color: var(--ink-soft); font-size: 14px; padding-right: 110px; }   /* 给右上角的猫留位置 */
.group { margin-bottom: 16px; }
.label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; letter-spacing: 1px; }

.seg { display: flex; gap: 8px; }
.seg button, .modes button {
  flex: 1; border: 2px solid var(--line); background: #fffaf0; color: var(--ink); border-radius: 12px;
  padding: 10px 8px; cursor: pointer; font-size: 15px; font-weight: 600; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px; transition: border-color .12s, background .12s;
}
.seg button small, .modes button small { font-size: 12px; font-weight: 400; color: var(--ink-soft); }
.seg button.on, .modes button.on { border-color: var(--accent); background: #fff1d6; }
.seg button:hover, .modes button:hover { border-color: rgba(217, 130, 43, 0.6); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

.modes { display: grid; gap: 8px; }
.modes button { flex-direction: row; justify-content: space-between; text-align: left; padding: 12px 16px; }
.modes button b { font-size: 16px; }
.modes button small { text-align: right; }

/* 语言切换（菜单卡片底部） */
.lang { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.lang .globe { font-size: 14px; margin-right: 2px; opacity: 0.75; }
.lang button {
  border: 1px solid transparent; background: none; color: var(--ink-soft); cursor: pointer; font-family: inherit;
  font-size: 13px; padding: 5px 10px; border-radius: 999px;
}
.lang button:hover { color: var(--ink); background: rgba(217, 130, 43, 0.1); }
.lang button.on { color: var(--accent-dark); border-color: rgba(217, 130, 43, 0.45); background: #fff1d6; font-weight: 600; }
.lang .privacy { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--line); color: var(--ink-soft); font-size: 12px; text-decoration: none; }
.lang .privacy:hover { color: var(--accent-dark); text-decoration: underline; }

@media (max-width: 520px) {
  .duo { right: 8px; top: 2px; transform: scale(0.7); transform-origin: top right; }
  .card { padding: 20px 16px 16px; border-radius: 18px; }
  .sub { padding-right: 0; }
  .seg button small { display: none; }
  .modes button { flex-direction: column; align-items: flex-start; gap: 2px; }
  .modes button small { text-align: left; }
  #hud { flex-wrap: wrap; }
  .status { order: 3; width: 100%; justify-content: center; }
}
