:root {
  --pink: #ff8fb8;
  --pink-d: #e8588f;
  --sky: #c9f0ff;
  --cream: #fff8ec;
  --ink: #4a3350;
  --green: #6fd36a;
  --navy: #1d1b2f;
  --font: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "M PLUS Rounded 1c", "BIZ UDPGothic", "Meiryo", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #ffe3f0 0%, var(--sky) 100%);
  background-color: var(--sky);
}
#app {
  position: relative;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, #ffe9f3 0%, #d6f4ff 100%);
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen[hidden] { display: none; }
button { font-family: inherit; touch-action: manipulation; cursor: pointer; border: 0; }

/* title */
.title-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  text-align: center;
}
.logo-badge {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: #fff;
  border: 6px solid var(--pink);
  box-shadow: 0 6px 0 var(--pink-d), 0 10px 18px rgba(232, 88, 143, .3);
  display: grid; place-items: center;
  animation: roll 3s ease-in-out infinite;
}
.logo-badge span { font-size: 40px; font-weight: 900; color: var(--pink-d); }
@keyframes roll {
  0%, 100% { transform: translateX(-14px) rotate(-30deg); }
  50% { transform: translateX(14px) rotate(30deg); }
}
.logo {
  font-size: 30px; line-height: 1.1; font-weight: 900; letter-spacing: .04em;
  color: var(--ink);
  text-shadow: 0 3px 0 #fff;
}
.logo span { font-size: 54px; color: var(--pink-d); text-shadow: 0 4px 0 #fff, 0 6px 0 rgba(74, 51, 80, .15); }
.lead { font-size: 14px; line-height: 1.6; font-weight: 700; }
.name-label { font-size: 13px; font-weight: 700; margin-top: 4px; }
#name-input {
  width: 100%; max-width: 300px;
  font: 700 22px var(--font);
  text-align: center;
  color: var(--ink);
  padding: 12px 14px;
  border: 4px solid var(--pink);
  border-radius: 999px;
  background: #fff;
  outline: none;
}
#name-input:focus { border-color: var(--pink-d); box-shadow: 0 0 0 4px rgba(255, 143, 184, .35); }
.btn {
  font-size: 20px; font-weight: 900; letter-spacing: .05em;
  padding: 14px 28px;
  border-radius: 999px;
  color: #fff;
  transition: transform .08s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(3px); }
.btn-main { background: var(--pink-d); box-shadow: 0 5px 0 #b8386c; }
.btn-main:active { box-shadow: 0 2px 0 #b8386c; }
.btn-share { background: var(--navy); box-shadow: 0 5px 0 #000; }
.btn-share:active { box-shadow: 0 2px 0 #000; }
#start-btn { width: 100%; max-width: 300px; font-size: 24px; }
.hint { font-size: 12px; opacity: .8; }

/* ads & footer */
.ad-slot {
  flex: 0 0 100px;
  height: 100px;
  width: 100%;
  margin: 0 auto;
}
.foot { flex: 0 0 auto; text-align: center; padding: 4px 0 calc(6px + env(safe-area-inset-bottom)); font-size: 11px; }
.foot a { color: var(--ink); opacity: .7; }

/* play */
#screen-play { touch-action: none; background: #ffe9f3; align-items: center; justify-content: center; }
.stage {
  position: relative;
  width: min(100%, calc(100dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  max-height: 100%;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; gap: 6px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  pointer-events: none;
}
.hud-pill {
  background: rgba(255, 255, 255, .88);
  border: 3px solid var(--pink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 18px; font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
}
#hud-time { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.hud-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: center; letter-spacing: .08em; }
.mute { pointer-events: auto; font-size: 18px; padding: 4px 10px; }

/* result */
.result-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  padding: 10px 16px 4px;
}
#card {
  display: block;
  height: min(480px, calc(100dvh - 250px));
  aspect-ratio: 3 / 4;
  max-width: 100%;
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(74, 51, 80, .25);
}
.btn-row { display: flex; gap: 10px; width: 100%; max-width: 360px; }
.btn-row .btn { flex: 1 1 0; padding: 13px 8px; font-size: 18px; }
.link-btn { background: none; color: var(--ink); font-size: 13px; text-decoration: underline; opacity: .75; padding: 2px 8px; }
@media (max-height: 600px) {
  .logo-badge { display: none; }
  .ad-slot { flex-basis: 90px; height: 90px; }
}
