* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: #2c5a14;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: radial-gradient(circle at 50% 0%, #d9f6ff 0%, #67b7ee 46%, #3f9a48 100%);
}

#app {
  width: min(480px, 100%);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(#8fd4ff, #e5f8ff 46%, #d3f5a4);
  box-shadow: 0 0 40px rgba(20, 70, 30, 0.18);
}

header {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
}

.pill {
  flex: 1;
  min-width: 0;
  text-align: center;
  background: rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  padding: 7px 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(70, 130, 40, 0.08);
}

.pill strong { font-size: 16px; }

.pill.warn {
  background: #ffd5dc;
  color: #b41334;
}

@media (max-width: 420px) {
  header { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .pill { font-size: 12px; padding: 7px 4px; }
  .pill strong { font-size: 14px; }
}

#mute {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.84);
  font-size: 18px;
  box-shadow: 0 2px 0 rgba(70, 130, 40, 0.08);
}

#board {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-bottom: env(safe-area-inset-bottom);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(90, 170, 210, 0.28);
  backdrop-filter: blur(5px);
}

#overlay.show { display: flex; }

.card {
  width: min(380px, 100%);
  max-height: 100%;
  overflow: auto;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  padding: 16px 16px 14px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(40, 90, 40, 0.16);
}

.hero-wrap {
  width: 112px;
  height: 112px;
  margin: 0 auto 6px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid #fff;
  box-shadow: 0 6px 0 rgba(90, 150, 40, 0.16), 0 0 0 4px #ffe14a;
}

.hero-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 12%;
}

h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 1px;
  color: #f0a000;
  text-shadow: 0 2px 0 #fff1bf;
}

.lead, .note, .best, .end-copy {
  margin: 8px 0 0;
  line-height: 1.45;
}

.lead { font-size: 15px; font-weight: 600; }

.note, .best, .end-copy {
  font-size: 13px;
  color: #5d7a38;
}

.primary, .ghost {
  appearance: none;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  margin-top: 12px;
  min-width: 180px;
  padding: 13px 26px;
  font-size: 20px;
  color: #6d4c00;
  background: linear-gradient(#ffe56a, #ffc107);
  box-shadow: 0 5px 0 #e09a00;
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #e09a00;
}

.primary.alt {
  margin-top: 10px;
  color: #0d4f7a;
  background: linear-gradient(#7fd7ff, #2ea8e8);
  box-shadow: 0 5px 0 #1c86bf;
}

.primary.alt:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #1c86bf;
}

.ghost {
  margin-top: 8px;
  padding: 8px 16px;
  background: transparent;
  color: #5d7a38;
  font-size: 14px;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 12px;
}

.legend figure { margin: 0; width: 46px; }

.legend img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

.legend figcaption {
  margin-top: 2px;
  font-size: 10px;
  color: #6a8648;
}

.score-lg {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 800;
  color: #ef9f00;
}

.celebrate {
  height: 250px;
  margin: 0 auto 6px;
  background: #e7f6c9;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.nailong-act {
  width: 176px;
  height: 214px;
  display: block;
}

.scene-line {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: #e25578;
}

.stars {
  margin: 2px 0 0;
  font-size: 30px;
  letter-spacing: 3px;
  color: #f0a000;
  line-height: 1;
}

.stars .off { color: #eadfb8; }

.replay {
  appearance: none;
  margin-top: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid #b7d98a;
  background: #fff;
  color: #2f6a16;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 3px 0 #d7eeb4;
  cursor: pointer;
}

.replay:active { transform: translateY(2px); box-shadow: 0 1px 0 #d7eeb4; }

.record {
  margin: 4px 0 0;
  color: #e25578;
  font-weight: 800;
}

#turn {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #c8f1ff;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #2f6a16;
  padding: 24px;
  text-align: center;
}

@media (orientation: landscape) and (max-height: 520px) {
  #turn { display: flex; }
}
