:root {
  --sky: #7ec8ff;
  --leaf: #3ea34a;
  --bark: #8a5a23;
  --bark2: #6e4519;
  --txt: #f4f7ee;
  --dim: #c7d6b8;
  --gold: #ffd23f;
  --panel: #1f3320;
  --line: rgba(255,255,255,0.16);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: linear-gradient(180deg, #6ec6ff 0%, #bfe8ff 45%, #e9ffd6 100%);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", system-ui, sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
body { display: flex; flex-direction: column; height: 100dvh; }

/* 상단바 */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  background: linear-gradient(180deg, rgba(31,51,32,0.92), rgba(31,51,32,0.78));
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--txt); z-index: 10;
}
#topbar .back { color: var(--dim); text-decoration: none; font-size: 14px; font-weight: 600; }
#topbar .back:hover { color: #fff; }
#topbar .brand { font-weight: 800; letter-spacing: -0.02em; font-size: 16px; display: flex; align-items: center; gap: 5px; }
#topbar .brand .ic { font-size: 18px; }
#topbar .spacer { flex: 1; }
#topbar .stat {
  font-size: 12px; font-weight: 800; color: var(--gold);
  background: rgba(255,210,63,0.14); border: 1px solid rgba(255,210,63,0.35);
  padding: 4px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
#topbar button {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(255,255,255,0.08); color: var(--txt); font-size: 14px; font-weight: 700;
  cursor: pointer; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
#topbar button:hover { background: rgba(255,255,255,0.18); }
#topbar button:active { transform: scale(0.94); }

/* 본문 */
#app {
  flex: 1; display: flex; min-height: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
#boardWrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board {
  border-radius: 18px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.32), inset 0 0 0 1px rgba(255,255,255,0.22);
  touch-action: none; max-width: 100%; max-height: 100%;
  display: block;
}

/* 오버레이 */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: rgba(10,24,12,0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 400px; max-height: 90vh; overflow: auto;
  background: linear-gradient(180deg, #244a26, #15301a);
  border: 1px solid rgba(140,210,140,0.32); border-radius: 22px; padding: 24px 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.5); text-align: center;
}
.sheet .emoji { font-size: 46px; line-height: 1; }
.sheet h2 { margin: 8px 0 2px; font-size: 26px; font-weight: 900; letter-spacing: -0.02em; }
.sheet .subt { margin: 0 0 14px; color: #9be38a; font-weight: 700; font-size: 14px; }
.rules { text-align: left; background: rgba(0,0,0,0.18); border-radius: 14px; padding: 13px 15px; margin: 0 0 16px; }
.rules p { font-size: 13.5px; line-height: 1.6; color: #e4f1da; margin: 0 0 7px; }
.rules p:last-child { margin: 0; }
.rules b { color: #fff; }
.rules .k { color: var(--gold); font-weight: 800; }
.rules .d { color: #ff8f8f; font-weight: 800; }
.goscore { display: flex; justify-content: center; gap: 26px; margin: 4px 0 18px; }
.goscore .b { font-size: 12px; color: var(--dim); font-weight: 600; }
.goscore .v { font-size: 40px; font-weight: 900; color: var(--gold); letter-spacing: -0.02em; line-height: 1.05; }
.goscore .v.small { color: #fff; font-size: 32px; }
.primary {
  width: 100%; padding: 15px; border-radius: 15px; border: none;
  background: linear-gradient(180deg, #5fd06a, #2f9d3a); color: #08230c;
  font-size: 17px; font-weight: 900; cursor: pointer; letter-spacing: -0.01em;
  box-shadow: 0 6px 0 #1c6f26, 0 10px 24px rgba(47,157,58,0.4);
}
.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #1c6f26, 0 6px 14px rgba(47,157,58,0.4); }
.ghost {
  margin-top: 10px; width: 100%; padding: 11px; border-radius: 13px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--txt);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.ghost:active { transform: scale(0.98); }
.tip { margin-top: 13px; font-size: 12px; color: var(--dim); line-height: 1.5; }

@media (min-width: 620px) {
  #topbar .brand { font-size: 18px; }
}
