:root {
  --ink: #2c3528;
  --mist: #e8f0e2;
  --leaf: #6f8f5c;
  --wood: #7a5535;
  --gold: #c9a46a;
  --panel: rgba(36, 46, 34, 0.55);
  --panel-strong: rgba(36, 46, 34, 0.72);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #c5d6b8;
  color: var(--mist);
  font-family: "Noto Sans SC", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#game:active { cursor: grabbing; }

.boot {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px 20px max(28px, env(safe-area-inset-bottom));
  background:
    radial-gradient(80% 60% at 50% 35%, #dfead4 0%, transparent 70%),
    linear-gradient(180deg, #b7cda8 0%, #8fa97c 55%, #6f8660 100%);
  color: var(--ink);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.boot.is-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-mark {
  font-family: "Noto Serif SC", serif;
  font-size: clamp(64px, 16vw, 96px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.boot-line {
  font-size: 16px;
  letter-spacing: 0.12em;
  opacity: 0.85;
}

.boot-sub {
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.55;
}

.boot-guest {
  margin-top: 36px;
  border: 0;
  min-width: 168px;
  height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  background: rgba(245, 241, 230, 0.95);
  color: var(--ink);
  font-family: "Noto Sans SC", sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  box-shadow: 0 10px 24px rgba(40, 50, 36, 0.18);
  cursor: pointer;
}

.boot-guest:active {
  transform: translateY(2px);
}

#app.is-locked .hud-top,
#app.is-locked .hud-bottom,
#app.is-locked #game {
  visibility: hidden;
  pointer-events: none;
}

.hud-top, .hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}

.hud-top {
  top: 0;
  padding: max(14px, env(safe-area-inset-top)) 16px 24px;
  background: linear-gradient(180deg, rgba(28, 36, 26, 0.5), transparent);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hall-chip, .presence, .status {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.hall-name {
  font-family: "Noto Serif SC", serif;
  font-weight: 500;
}

.hall-sep { opacity: 0.45; margin: 0 4px; }

.me-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.me-name {
  font-family: "Noto Serif SC", serif;
  font-size: 15px;
  opacity: 0.95;
  letter-spacing: 0.04em;
}

.hint {
  font-size: 13px;
  opacity: 0.78;
  max-width: 28em;
}

.hud-bottom {
  bottom: 0;
  padding: 20px 16px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(28, 36, 26, 0.58), transparent);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.actions {
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.act {
  border: 0;
  min-width: 72px;
  height: 64px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(245, 241, 230, 0.92);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(30, 40, 28, 0.18);
  cursor: pointer;
}

.act-ico {
  font-family: "Noto Serif SC", serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--wood);
}

.act:active { transform: translateY(2px); }

.act.is-on {
  background: #efe2c4;
  outline: 2px solid var(--gold);
}

.toast {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--panel-strong);
  backdrop-filter: blur(10px);
  font-size: 14px;
  white-space: nowrap;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.beads {
  position: absolute;
  inset: 0;
  z-index: 10;
  background:
    radial-gradient(70% 50% at 50% 40%, #3a2a1c 0%, transparent 65%),
    linear-gradient(180deg, #1c1814 0%, #2a2118 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #f3e6c8;
}

.beads[hidden] { display: none; }

.beads-back {
  position: absolute;
  left: 16px;
  top: max(16px, env(safe-area-inset-top));
  border: 0;
  background: rgba(255,255,255,0.1);
  color: inherit;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.beads-count {
  margin-top: max(72px, 12vh);
  font-family: "Noto Serif SC", serif;
  font-size: clamp(40px, 9vw, 56px);
  letter-spacing: 0.06em;
}

.beads-stage {
  flex: 1;
  width: min(420px, 92vw);
  display: grid;
  place-items: center;
  position: relative;
}

.mala {
  /* Front-facing 平视手串 — round loop like the reference */
  position: relative;
  width: min(400px, 88vmin);
  height: min(400px, 88vmin);
}

.mala-cord-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}

.mala-cord {
  fill: none;
  stroke: #5a3a1c;
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0.85;
}

.mala-ring {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.mala-bead {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  /* Round wood bead */
  background:
    radial-gradient(circle at 38% 32%, rgba(255, 236, 200, 0.45) 0%, transparent 42%),
    repeating-linear-gradient(
      118deg,
      rgba(90, 50, 20, 0.14) 0 1px,
      transparent 1px 3px
    ),
    repeating-linear-gradient(
      28deg,
      rgba(255, 220, 170, 0.12) 0 1px,
      transparent 1px 4px
    ),
    radial-gradient(circle at 50% 48%, #e2b888 0%, #c49258 42%, #9a6838 78%, #6e4524 100%);
  border: 1px solid rgba(70, 42, 18, 0.45);
  box-shadow:
    inset 0 1px 2px rgba(255, 240, 210, 0.35),
    inset 0 -2px 3px rgba(60, 30, 10, 0.28);
  will-change: transform;
  z-index: 1;
}

.mala-bead.is-guru {
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  background:
    radial-gradient(circle at 38% 32%, rgba(255, 248, 210, 0.55) 0%, transparent 42%),
    repeating-linear-gradient(
      118deg,
      rgba(120, 70, 20, 0.16) 0 1px,
      transparent 1px 3px
    ),
    radial-gradient(circle at 50% 48%, #f0d090 0%, #d4a04a 45%, #a87828 80%, #7a5018 100%);
  border-color: rgba(120, 80, 20, 0.55);
}

.mala-bead.is-active {
  filter: brightness(1.08);
  z-index: 2;
}

.beads-tip {
  position: absolute;
  bottom: max(48px, 8vh);
  font-size: 14px;
  opacity: 0.6;
}

@media (max-width: 480px) {
  .act { min-width: 64px; height: 60px; }
  .hint { font-size: 12px; }
}
