:root {
  color-scheme: light;
  --ink: #3f2b36;
  --cream: #fff9e8;
  --orange: #ff875f;
  --orange-dark: #d95745;
  --yellow: #ffd95d;
  --green: #5cc991;
  --blue: #63c8df;
  --purple: #8062b3;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #fff5d7; }
body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 18%, #fff 0 5px, transparent 6px),
    radial-gradient(circle at 86% 24%, #fff7 0 7px, transparent 8px),
    linear-gradient(145deg, #fff9df 0 55%, #ffe6ba 100%);
  color: var(--ink);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .42; cursor: default; }
button:focus-visible, a:focus-visible { outline: 4px solid #684d9f; outline-offset: 3px; }
button:active:not(:disabled) { transform: translateY(2px); }
[hidden] { display: none !important; }

.topbar {
  height: 64px;
  max-width: 1040px;
  margin: auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 900; font-size: 12px; letter-spacing: 1.5px; }
.brand b { padding: 5px 9px; border-radius: 50px; background: var(--orange); color: white; font-size: 10px; transform: rotate(-3deg); }
.pill-button { min-height: 38px; padding: 8px 14px; border: 2px solid #684d9f22; border-radius: 30px; background: #fffaf0cc; font-size: 12px; font-weight: 800; box-shadow: 0 3px 0 #684d9f18; }
.pill-button[aria-pressed="true"] { background: #684d9f; color: white; }

.layout { max-width: 960px; margin: 0 auto; padding: 4px 22px 14px; display: grid; grid-template-columns: 390px 420px; gap: 66px; align-items: center; justify-content: center; }
.intro { padding-bottom: 20px; }
.eyebrow { margin: 0 0 14px; color: var(--orange-dark); font-size: 11px; font-weight: 900; letter-spacing: 3px; }
h1 { margin: 0; font-size: clamp(43px, 5vw, 61px); line-height: 1.18; letter-spacing: -4px; font-weight: 950; }
h1 span { color: var(--orange); text-shadow: 3px 4px 0 #ffd65b; }
.lead { margin: 22px 0; font-weight: 700; line-height: 1.9; color: #6d5960; }
.how-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 28px 0 22px; }
.how-card div { min-width: 0; padding: 14px 8px 13px; border: 2px solid #e9ca9f; border-radius: 19px; background: #fffdfa; text-align: center; box-shadow: 0 5px 0 #e9ca9f; }
.how-card b { display: block; margin-bottom: 5px; font-size: 27px; }
.how-card span { font-size: 10px; line-height: 1.5; color: #796267; }
.how-card strong { color: var(--orange-dark); font-size: 12px; }
.record-card { padding: 17px 20px; border-radius: 20px; background: var(--ink); color: #fff9e8; box-shadow: 0 8px 20px #3f2b3622; }
.record-card > span { color: #ffd95d; font-size: 10px; font-weight: 900; letter-spacing: 2px; }
.record-card p { display: inline; margin: 0 20px; }
.record-card p strong { font-size: 28px; }
.record-card small { color: #e8dce0; font-size: 10px; }
.record-card small b { color: white; }

.game-shell { width: 420px; min-width: 0; }
.hud { height: 49px; display: grid; grid-template-columns: 1fr 90px 1fr; align-items: center; border-radius: 17px 17px 0 0; background: var(--ink); color: white; text-align: center; box-shadow: 0 8px 24px #49333b22; }
.hud div { display: flex; align-items: baseline; justify-content: center; gap: 7px; }
.hud small { color: #ffe56f; font-size: 8px; font-weight: 900; letter-spacing: 1px; }
.hud strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.hud .level { height: 30px; border-inline: 1px solid #ffffff2b; }
.viewport { position: relative; width: 100%; aspect-ratio: 420 / 680; overflow: hidden; background: #79d8ed; border-inline: 4px solid var(--ink); isolation: isolate; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.mini-hud { position: absolute; top: 15px; left: 16px; right: 16px; z-index: 2; display: flex; justify-content: space-between; pointer-events: none; font-weight: 950; text-shadow: 0 2px 1px #4e394955, 0 0 6px #fff; }
#hearts { color: #ef4e67; letter-spacing: 3px; }
#combo { min-height: 22px; color: #713f94; }
.rainbow-meter { position: absolute; top: 47px; left: 50%; z-index: 3; width: 160px; height: 25px; overflow: hidden; transform: translateX(-50%); border: 3px solid white; border-radius: 20px; background: #ffffffaa; box-shadow: 0 3px 9px #47394c33; }
.rainbow-meter span { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #ff6584, #ffce54, #62d795, #5bc8ee, #a974dc); }
.rainbow-meter b { position: absolute; inset: 0; text-align: center; color: white; font-size: 10px; line-height: 19px; text-shadow: 0 1px 2px #5e4966; }
.toast { position: absolute; top: 83px; left: 14px; right: 14px; z-index: 4; color: white; text-align: center; font-weight: 950; font-size: 17px; text-shadow: 0 3px 5px #513847aa; pointer-events: none; }
.toast.pop { animation: toast-pop .42s ease-out; }
@keyframes toast-pop { 0% { transform: scale(.7); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

.overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 22px; background: #46313a4c; backdrop-filter: blur(3px); overflow: auto; overscroll-behavior: contain; }
.overlay.empty { display: none; }
.panel { width: min(100%, 350px); padding: 24px 22px 22px; border: 3px solid var(--ink); border-radius: 27px; background: #fffaf0; text-align: center; box-shadow: 0 10px 0 #3f2b3655; }
.panel .mascot { display: block; margin: -66px auto 2px; width: 104px; height: 104px; border: 3px solid var(--ink); border-radius: 50%; background: #ffd85e; font-size: 57px; line-height: 98px; box-shadow: 0 6px 0 #dbad3f; }
.panel .kicker { color: var(--orange-dark); font-size: 9px; font-weight: 950; letter-spacing: 2px; }
.panel h2 { margin: 8px 0 9px; font-size: 27px; line-height: 1.25; letter-spacing: -1px; }
.panel p { margin: 8px 0 17px; color: #745f65; font-size: 12px; line-height: 1.7; font-weight: 700; }
.quick-guide { display: flex; justify-content: center; gap: 8px; margin: 14px 0 19px; }
.quick-guide span { flex: 1; padding: 8px 3px; border-radius: 12px; background: #f7ead2; font-size: 11px; font-weight: 900; }
.primary, .secondary { width: 100%; min-height: 51px; border-radius: 15px; font-weight: 950; }
.primary { background: var(--orange); color: white; box-shadow: 0 5px 0 var(--orange-dark); font-size: 18px; }
.secondary { min-height: 43px; margin-top: 11px; border: 2px solid #d8c2aa; background: white; color: #665057; font-size: 12px; }
.result-score { margin: 5px 0 !important; color: var(--orange-dark) !important; font-size: 48px !important; line-height: 1 !important; }
.result-score small { font-size: 14px; }
.stars { margin: 6px 0; color: #f4b92f; font-size: 29px; letter-spacing: 3px; }
.new-friend { padding: 8px !important; border-radius: 11px; background: #e4f6cf; color: #48764b !important; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.panel-head h2 { margin: 0; font-size: 22px; }
.panel-head button { width: 37px; height: 37px; border-radius: 50%; background: #eee0cf; font-weight: 950; }
.friend-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.friend-card { min-height: 105px; padding: 9px 4px; border: 2px solid #ead8bf; border-radius: 16px; background: white; }
.friend-card.selected { border-color: var(--orange); background: #fff0d3; }
.friend-card .face { display: block; font-size: 34px; filter: saturate(.9); }
.friend-card strong { display: block; margin-top: 3px; font-size: 12px; }
.friend-card small { display: block; margin-top: 4px; color: #927a75; font-size: 9px; }
.friend-card:disabled .face { filter: grayscale(1); }
.collection-note { margin-bottom: 0 !important; font-size: 10px !important; }

.lane-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 9px 8px 8px; border-radius: 0 0 19px 19px; background: var(--ink); }
.lane-buttons button { height: 47px; border-radius: 13px; background: #fff5d9; color: var(--ink); font-size: 21px; font-weight: 950; box-shadow: 0 3px 0 #d4b989; }
.lane-buttons button.active { background: var(--yellow); }
.lane-buttons small { display: block; margin-top: -2px; font-size: 8px; }
.game-menu { display: flex; gap: 7px; margin-top: 10px; }
.game-menu button { flex: 1; min-height: 39px; border: 2px solid #ebcea4; border-radius: 12px; background: #fffaf0cc; font-size: 11px; font-weight: 900; }
.game-menu span { color: #a55c49; }
.save-note { margin: 8px 0 0; text-align: center; color: #9a7f77; font-size: 8px; }
footer { margin: 14px 0 18px; color: #bd7d63; text-align: center; font-size: 8px; font-weight: 900; letter-spacing: 3px; }

@media (max-width: 820px) {
  .topbar { height: 48px; max-width: 480px; padding: 0 14px; }
  .brand { font-size: 9px; }
  .layout { display: block; width: 100%; padding: 0 10px 8px; }
  .intro { display: none; }
  .game-shell { width: min(100%, calc((100svh - 230px) * .61765)); min-width: 294px; margin: 0 auto; }
  .hud { height: 42px; border-radius: 14px 14px 0 0; }
  .hud strong { font-size: 15px; }
  .viewport { border-inline-width: 3px; }
  .lane-buttons { padding: 7px; }
  .lane-buttons button { height: 43px; }
  .game-menu { margin-top: 7px; }
  .game-menu button { min-height: 35px; }
  footer { display: none; }
}

@media (max-width: 360px) {
  .brand span { display: none; }
  .game-shell { min-width: 280px; }
  .panel { padding-inline: 16px; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .topbar { height: 42px; }
  .layout { display: grid; grid-template-columns: 260px 310px; gap: 30px; max-width: 700px; }
  .intro { display: block; padding: 0; }
  .intro h1 { font-size: 35px; }
  .lead, .how-card, .record-card { display: none; }
  .game-shell { width: 310px; min-width: 0; }
  .viewport { height: 375px; aspect-ratio: auto; }
  .game-menu, .save-note, footer { display: none; }
  .lane-buttons button { height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
