* { 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 42%, #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.88);
  border-radius: 999px;
  padding: 7px 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.score-pill strong {
  font-size: 26px;
  color: #ef9f00;
  letter-spacing: 0.5px;
}

#combo[hidden] { display: none; }
#combo.show {
  flex: 0 0 auto;
  background: #ffe9a8;
  color: #a15c00;
}

#mute {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  font-size: 18px;
}

#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: 16px;
  background: rgba(80, 160, 210, 0.25);
}

#overlay.show { display: flex; }

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

h1 {
  margin: 0;
  font-size: 30px;
  color: #f0a000;
  text-shadow: 0 2px 0 #fff1bf;
}

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

.lead { font-size: 15px; font-weight: 600; }
.note { font-size: 13px; color: #5d7a38; }

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

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

.skins {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.skin {
  appearance: none;
  border: none;
  background: #f7fbff;
  border-radius: 16px;
  padding: 8px 4px 6px;
  box-shadow: 0 0 0 2px transparent;
  font: inherit;
  color: #3d6a22;
  cursor: pointer;
}

.skin img {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}

.skin span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
}

.skin.on { box-shadow: 0 0 0 3px #f0a000; }

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

.primary {
  margin-top: 14px;
  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; }

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

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

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

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