:root {
  --ink: #254c48;
  --muted: #65837b;
  --soft: rgba(255, 255, 255, 0.78);
  --line: rgba(120, 165, 190, 0.32);
  --shadow: 0 6px 16px rgba(31, 62, 82, 0.12);
}

* { box-sizing: border-box; }

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

body {
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 12% 8%, #fff6d9, transparent 55%),
    radial-gradient(ellipse at 90% 80%, #c5e5d4, transparent 65%),
    #eaf3e9;
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
}

.game {
  position: relative;
  width: min(780px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: 16px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 상단 정보 */
.hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.hud-box {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 20px;
  background: #fffcf3;
  border: 1px solid #d9e4d7;
  border-radius: 18px;
  box-shadow: 0 4px 0 #d5e2d3, 0 8px 20px #355e4610;
}

.hud-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.hud-value {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

/* 조작 안내 */
.hint {
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
  padding: 5px 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* 놀이 영역 */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 140px;
  margin-top: 2px;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  border: 0;
  outline: 5px solid #fffdf4;
  outline-offset: -1px;
  border-radius: 26px;
  background: #e5f4ef;
  box-shadow: 0 8px 0 #c4d6be, 0 20px 40px #315b4920;
}

/* 시작/종료 화면 */
.overlay {
  position: absolute;
  inset: 12px;
  z-index: 30;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 22px;
  text-align: center;
  border: 1px solid #ffffff;
  border-radius: 26px;
  background:
    radial-gradient(ellipse at 50% 38%, #fffcf5 0%, #fffcf5ed 34%, #eaf4e5bc 72%);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  box-shadow: inset 0 0 70px #d6e8ce55;
}

.overlay.hidden { display: none; }

.overlay h1 {
  margin: 0;
  font-family: "Jua", "Noto Sans KR", sans-serif;
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 400;
  color: #1c4a3a;
  text-shadow: 0 2px 0 #ffffff;
}

.overlay p {
  margin: 0;
  max-width: 34ch;
  font-size: 15px;
  color: #60796c;
  line-height: 1.6;
}

.btn {
  margin-top: 8px;
  padding: 13px 38px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font-family: "Jua", "Noto Sans KR", sans-serif;
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: linear-gradient(180deg, #4fd193 0%, #2fa96d 55%, #27975f 100%);
  box-shadow:
    0 5px 0 #1f8a56,
    0 10px 20px rgba(31, 138, 86, 0.28);
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.btn:hover {
  background: linear-gradient(180deg, #5cd79c 0%, #33b475 55%, #2a9d64 100%);
}

.btn:active {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 #1f8a56,
    0 4px 10px rgba(31, 138, 86, 0.24);
}

.btn:focus-visible {
  outline: 3px solid rgba(47, 169, 109, 0.45);
  outline-offset: 3px;
}

.ranking-status {
  margin: 2px 0 0;
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
  color: #2f8a5f;
}

.ranking-status:empty { display: none; }

.data-note {
  margin-top: 4px;
  padding: 6px 14px;
  font-size: 12px;
  color: #9a5f34;
  background: rgba(255, 244, 230, 0.9);
  border: 1px solid rgba(200, 140, 80, 0.35);
  border-radius: 999px;
}

.hud-box:last-child .hud-value { color: #df7c81; font-size: 20px; letter-spacing: 3px; }
.overlay h1::before {
  content: '♻';
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  border-radius: 24px;
  background: #e0efcf;
  color: #3d885c;
  font: 48px/76px system-ui, sans-serif;
  box-shadow: 0 5px 0 #c9ddba;
  transform: rotate(-7deg);
}
.overlay .data-note { font-size: 12px; color: #94643c; }
@media (max-width: 420px) {
  .game { padding: 10px; gap: 8px; }
  .hud-box { padding: 6px 12px; gap: 7px; }
  .hint { font-size: 10px; padding: 5px 8px; }
  .overlay { inset: 6px; padding: 16px; }
}
@media (max-height: 520px) {
  .game { padding: 8px; gap: 6px; }
  .hud-box { padding: 5px 12px; }
  .hint { font-size: 11px; padding: 3px 10px; }
  .overlay { gap: 8px; padding: 12px; }
  .overlay h1 { font-size: 26px; }
  .overlay h1::before { display: none; }
  .hud-value { font-size: 19px; }
  .overlay p { font-size: 13px; line-height: 1.45; }
  .btn { padding: 10px 28px; font-size: 17px; }
}
