:root {
  --peach: #ffd1bd;
  --orange: #ffc36f;
  --ivory: #fff7e7;
  --mint: #bdebd8;
  --lavender: #c8c2ff;
  --navy: #263258;
  --ink: #4d3d4a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffe7d6, #e7f6ec 45%, #d8d5ff);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 18px;
  background: rgba(255, 247, 231, .88);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(72, 50, 80, .14);
  cursor: pointer;
  touch-action: manipulation;
}

button:active { transform: translateY(1px) scale(.98); }
button:disabled { opacity: .48; cursor: default; }

.shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.phone {
  width: min(100vw, 430px);
  height: min(100vh, 860px);
  max-height: 100vh;
  aspect-ratio: 1 / 2;
  border-radius: 28px;
  padding: 8px;
  background: rgba(255, 255, 255, .5);
  box-shadow: 0 20px 70px rgba(58, 49, 91, .22);
}

.mv {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffb37b 0%, #ffd0ce 52%, #fff4dc 100%);
  isolation: isolate;
}

.mv::before,
.mv::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transition: opacity 900ms ease;
}

.mv::before {
  background: radial-gradient(circle at 20% 12%, rgba(255, 255, 255, .55), transparent 24%),
    linear-gradient(180deg, rgba(255, 196, 107, .8), rgba(255, 179, 197, .45));
  opacity: .12;
}

.mv::after {
  background: linear-gradient(180deg, rgba(38, 50, 88, .9), rgba(91, 87, 148, .72) 52%, rgba(255, 238, 194, .5));
  opacity: 0;
}

.mv.room {
  background: linear-gradient(180deg, #ffd9a3, #fff1d6 58%, #dff5e8);
}

.mv.chorus {
  background: linear-gradient(180deg, #ffe5ca, #e9f8e9 48%, #dad7ff);
}

.mv.night::before,
.mv.sleep::before { opacity: 0; }
.mv.night::after { opacity: .82; }
.mv.sleep::after { opacity: .95; }

#sparkles,
.sky-layer,
.room-props,
.floating-words {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.art-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #fff7e7;
}

.art-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 247, 231, .34), transparent 24%, transparent 64%, rgba(45, 38, 72, .16)),
    radial-gradient(circle at 50% 70%, transparent 0 38%, rgba(255, 247, 231, .08) 74%);
}

.scene-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 48%;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 1200ms ease, transform 6200ms ease;
  filter: saturate(1.04) contrast(.98);
}

.scene-art.active {
  opacity: 1;
  transform: scale(1.12);
}

.art-scene-1 { object-position: 50% 50%; }
.art-scene-2 { object-position: 50% 48%; }
.art-scene-3 { object-position: 50% 50%; }
.art-scene-4 { object-position: 50% 45%; }

.sky-layer span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff9c9;
  opacity: 0;
  box-shadow: 0 0 10px #fff7bc;
  animation: twinkle 2.8s ease-in-out infinite;
}

.sky-layer span:nth-child(1) { left: 18%; top: 18%; animation-delay: .2s; }
.sky-layer span:nth-child(2) { left: 72%; top: 13%; animation-delay: .8s; }
.sky-layer span:nth-child(3) { left: 38%; top: 30%; animation-delay: 1.4s; }
.sky-layer span:nth-child(4) { left: 84%; top: 38%; animation-delay: 2s; }
.sky-layer span:nth-child(5) { left: 12%; top: 43%; animation-delay: 1s; }
.night .sky-layer span,
.sleep .sky-layer span { opacity: .85; }

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 0;
}

.title-block {
  min-width: 0;
}

.mini {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  opacity: .72;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.heal {
  min-width: 116px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .45);
  text-align: right;
  backdrop-filter: blur(10px);
}

.heal span,
.top-stat span {
  display: block;
  font-size: 10px;
  font-weight: 800;
  opacity: .7;
}

.heal > strong { font-size: 21px; }

.top-stat {
  display: inline-grid;
  gap: 1px;
  margin-top: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .38);
  backdrop-filter: blur(8px);
}

.top-stat strong {
  min-width: 38px;
  font-size: 16px;
  line-height: 1.05;
  white-space: nowrap;
}

.judge-stat {
  width: 100%;
  justify-items: end;
}

.judge-stat strong {
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-words span {
  position: absolute;
  color: rgba(255, 255, 255, .78);
  font-weight: 900;
  text-shadow: 0 2px 16px rgba(119, 86, 127, .2);
  animation: wordFloat 5.8s ease-out forwards;
  white-space: nowrap;
}

.room-props {
  z-index: 1;
  display: none;
  opacity: 0;
  transition: opacity 900ms ease;
}

.room .room-props,
.chorus .room-props,
.sleep .room-props { opacity: 1; }

.window {
  position: absolute;
  left: 28px;
  top: 116px;
  width: 86px;
  height: 82px;
  border-radius: 8px;
  background: rgba(255,255,255,.42);
  border: 5px solid rgba(255,247,231,.72);
}

.window i {
  position: absolute;
  width: 4px;
  height: 100%;
  left: 50%;
  background: rgba(255,247,231,.7);
}
.window i:nth-child(2) { width: 100%; height: 4px; left: 0; top: 50%; }
.window i:nth-child(3) { display: none; }

.lamp {
  position: absolute;
  right: 42px;
  top: 132px;
  width: 54px;
  height: 86px;
  border-radius: 32px 32px 10px 10px;
  background: rgba(255, 237, 154, .75);
  box-shadow: 0 0 var(--lampGlow, 28px) rgba(255, 227, 130, .65);
}

.carrot-cushion {
  position: absolute;
  left: 32px;
  bottom: 248px;
  width: 102px;
  height: 58px;
  border-radius: 48px 20px 44px 20px;
  background: #ff9b59;
  transform: rotate(-8deg);
  box-shadow: inset -12px -10px rgba(222, 112, 56, .18);
}

.carrot-cushion b {
  position: absolute;
  right: -12px;
  top: -18px;
  width: 38px;
  height: 36px;
  background: #8ed69a;
  clip-path: polygon(50% 0, 64% 38%, 100% 16%, 76% 58%, 96% 92%, 52% 68%, 18% 100%, 30% 58%, 0 30%, 38% 38%);
}

.futon {
  position: absolute;
  right: 26px;
  bottom: 226px;
  width: 142px;
  height: 62px;
  border-radius: 34px 34px 10px 10px;
  background: linear-gradient(90deg, #e7e1ff, #fff7e7);
  box-shadow: 0 12px 0 rgba(178, 164, 226, .24);
}

.korori-wrap {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 280px;
  width: 132px;
  height: 210px;
  transform: translateX(-50%);
  transition: bottom 900ms ease, transform 900ms ease;
}

.korori {
  position: relative;
  width: 100%;
  height: 100%;
  animation: walk 1.8s ease-in-out infinite;
}

.head {
  position: absolute;
  left: 32px;
  top: 36px;
  width: 70px;
  height: 64px;
  border-radius: 45% 45% 50% 50%;
  background: #ffe0c7;
  z-index: 3;
}

.hair {
  position: absolute;
  left: 25px;
  top: 22px;
  width: 84px;
  height: 76px;
  border-radius: 42px 42px 24px 24px;
  background: #28212a;
  z-index: 2;
}

.hair::before,
.hair::after {
  content: "";
  position: absolute;
  top: 40px;
  width: 18px;
  height: 54px;
  background: #28212a;
  border-radius: 0 0 16px 16px;
}
.hair::before { left: 0; }
.hair::after { right: 0; }

.eye {
  position: absolute;
  top: 30px;
  width: 8px;
  height: 9px;
  border-radius: 50%;
  background: #3f3034;
  transition: height 500ms ease, transform 500ms ease;
}
.eye.left { left: 19px; }
.eye.right { right: 19px; }

.cheek {
  position: absolute;
  top: 42px;
  width: 12px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 139, 147, .42);
}
.cheek.left { left: 8px; }
.cheek.right { right: 8px; }

.mouth {
  position: absolute;
  left: 30px;
  top: 43px;
  width: 12px;
  height: 6px;
  border-bottom: 2px solid #7f4d56;
  border-radius: 0 0 12px 12px;
}

.body {
  position: absolute;
  left: 38px;
  top: 94px;
  width: 58px;
  height: 56px;
  border-radius: 18px 18px 10px 10px;
  background: #ffd34e;
  z-index: 2;
}

.collar {
  position: absolute;
  left: 21px;
  top: 0;
  width: 18px;
  height: 14px;
  background: #fff7e7;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
}

.arm {
  position: absolute;
  top: 10px;
  width: 16px;
  height: 54px;
  border-radius: 999px;
  background: #ffe0c7;
  transform-origin: top center;
}
.arm.left { left: -8px; transform: rotate(15deg); }
.arm.right { right: -8px; transform: rotate(-15deg); }

.skirt {
  position: absolute;
  left: 24px;
  top: 138px;
  width: 86px;
  height: 54px;
  border-radius: 18px 18px 34px 34px;
  background: linear-gradient(90deg, #ffe07b, #ffd15b 50%, #ffe492);
  clip-path: polygon(16% 0, 84% 0, 100% 100%, 0 100%);
  z-index: 2;
  animation: sway 2.2s ease-in-out infinite;
}

.legs {
  position: absolute;
  left: 47px;
  top: 184px;
  display: flex;
  gap: 16px;
}
.legs i {
  width: 11px;
  height: 25px;
  border-radius: 999px;
  background: #ffe0c7;
}

.korori.happy .mouth {
  width: 16px;
  height: 10px;
  left: 27px;
  border-bottom-width: 3px;
}
.korori.sleepy .eye {
  height: 2px;
  transform: translateY(4px);
}
.sleep .korori-wrap {
  bottom: 238px;
  transform: translateX(-30%) rotate(-8deg) scale(.9);
}
.sleep .korori { animation: breathe 2.8s ease-in-out infinite; }

.lyric {
  position: absolute;
  z-index: 7;
  left: 24px;
  right: 24px;
  top: 55%;
  min-height: 56px;
  display: grid;
  place-items: center;
  color: #5b4053;
  font-size: 20px;
  line-height: 1.45;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 12px rgba(255,255,255,.82);
  opacity: .92;
  transition: opacity 260ms ease, transform 260ms ease;
}

.lyric.pop {
  animation: lyricPop 520ms ease;
}

.lanes {
  position: absolute;
  z-index: 6;
  left: 18px;
  right: 18px;
  bottom: 154px;
  height: 214px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-hard .lanes {
  left: 14px;
  right: 14px;
  gap: 6px;
}

.lane {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.36));
  border: 1px solid rgba(255,255,255,.28);
}

.lane > span {
  position: absolute;
  left: 10px;
  bottom: 12px;
  font-weight: 900;
  opacity: .38;
}

.note {
  position: absolute;
  left: 50%;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .84);
  border: 2px solid rgba(255, 247, 231, .9);
  box-shadow: 0 0 18px rgba(255,255,255,.82), 0 8px 18px rgba(85, 61, 94, .14);
  overflow: hidden;
}

.note img {
  width: 94%;
  height: 94%;
  object-fit: contain;
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
}

.mode-hard .note {
  width: 38px;
  height: 38px;
}

.note.rare {
  border-color: rgba(255, 246, 178, .98);
  box-shadow: 0 0 22px rgba(255, 245, 155, .95), 0 10px 24px rgba(85, 61, 94, .16);
}

.note.hit {
  animation: noteHit 420ms ease forwards;
}

.judge-line {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 38px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 0 18px rgba(255, 250, 206, .9);
}

.tap-labels {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -76px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-hard .tap-labels {
  gap: 8px;
}

.tap-labels button {
  min-height: 64px;
  border-radius: 8px;
  background: rgba(255, 247, 231, .76);
  font-size: 18px;
  padding: 0 8px;
}

.tap-labels button.active {
  background: #fff2a6;
  box-shadow: 0 0 30px rgba(255, 235, 155, .8);
}

.controls {
  position: absolute;
  z-index: 10;
  left: 18px;
  right: 18px;
  bottom: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.controls button {
  min-width: 0;
  padding: 0 8px;
  font-size: 13px;
}

.overlay,
.password-panel,
.result {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 30px;
  background: linear-gradient(180deg, rgba(255, 229, 211, .42), rgba(255,247,231,.56));
  text-align: center;
}

.overlay h2 {
  margin: 4px 0 12px;
  font-size: 38px;
  line-height: 1.18;
}

.password-panel {
  z-index: 23;
  background: linear-gradient(180deg, rgba(255, 247, 231, .62), rgba(216, 255, 240, .58));
  backdrop-filter: blur(8px);
}

.password-surface {
  width: min(100%, 300px);
  padding: 22px 18px 18px;
  border-radius: 10px;
  background: rgba(255, 247, 231, .9);
  box-shadow: 0 16px 42px rgba(72, 50, 80, .18);
}

.password-surface h2 {
  margin: 4px 0 14px;
  font-size: 26px;
}

.password-surface input {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .74);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(93, 70, 94, .12);
}

.password-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.password-actions button {
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
}

.difficulty-group {
  display: grid;
  gap: 8px;
  margin: 14px 0 12px;
}

.difficulty-option {
  width: min(100%, 310px);
  min-height: 56px;
  margin: 0 auto;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255, 247, 231, .72);
  text-align: left;
  box-shadow: 0 8px 22px rgba(72, 50, 80, .12);
}

.difficulty-option.active {
  background: rgba(255, 242, 166, .9);
  box-shadow: 0 0 0 2px rgba(255,255,255,.7), 0 10px 26px rgba(214, 158, 95, .22);
}

.difficulty-option strong,
.difficulty-option span {
  display: block;
}

.difficulty-option strong {
  font-size: 15px;
  line-height: 1.25;
}

.difficulty-option span {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  opacity: .72;
}

.overlay p,
.result p {
  margin: 0 0 18px;
  line-height: 1.7;
  font-weight: 700;
}

.overlay button,
.result button {
  background: #fff7e7;
  min-width: 180px;
}

.edit-entry {
  display: block;
  margin: 10px auto 0;
  min-height: 40px;
  background: rgba(255, 247, 231, .72) !important;
  font-size: 13px;
}

.error {
  min-height: 24px;
  color: #8f4d59;
  font-size: 13px;
}

.editor-panel {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: stretch;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 247, 231, .76), rgba(216, 255, 240, .7));
  backdrop-filter: blur(8px);
}

.editor-surface {
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 247, 231, .86);
  box-shadow: 0 18px 45px rgba(72, 50, 80, .18);
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.editor-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.editor-header button {
  min-width: 72px;
  min-height: 40px;
  padding: 0 12px;
}

.editor-status {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.editor-status span {
  min-width: 0;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .56);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.editor-actions button {
  min-width: 0;
  min-height: 42px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
}

.editor-help {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 800;
  opacity: .74;
}

.editor-lane-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mode-hard .editor-lane-buttons {
  grid-template-columns: repeat(4, 1fr);
}

.editor-lane-buttons button {
  min-width: 0;
  min-height: 54px;
  padding: 0 8px;
  border-radius: 8px;
  background: #fff2a6;
  font-size: 16px;
}

.editor-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 2px;
}

.editor-row {
  display: grid;
  grid-template-columns: 68px 1fr 40px 40px 42px;
  gap: 5px;
  align-items: center;
  padding: 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .54);
}

.editor-row input,
.editor-row select {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 0;
  border-radius: 7px;
  padding: 0 8px;
  background: rgba(255, 247, 231, .9);
  color: var(--ink);
  font-weight: 800;
}

.editor-row button {
  min-width: 0;
  min-height: 36px;
  padding: 0;
  border-radius: 7px;
  font-size: 13px;
  box-shadow: none;
}

.editor-empty {
  align-self: start;
  margin: 10px 0;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .46);
  text-align: center;
  font-weight: 800;
  opacity: .72;
}

.result {
  z-index: 22;
  background: linear-gradient(180deg, rgba(38,50,88,.88), rgba(91,87,148,.72));
  color: var(--ivory);
}

.result strong {
  display: block;
  margin-bottom: 22px;
  font-size: 25px;
}

.result-badge {
  display: inline-grid;
  place-items: center;
  min-height: 38px;
  margin: 0 0 18px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 247, 231, .18);
  color: #fff7bd;
  font-weight: 900;
}

.result-actions {
  display: grid;
  gap: 10px;
  justify-items: center;
}

@keyframes walk {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-5px) rotate(1deg); }
}

@keyframes sway {
  0%, 100% { transform: skewX(-3deg); }
  50% { transform: skewX(4deg); }
}

@keyframes breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

@keyframes lyricPop {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: .92; transform: translateY(0); }
}

@keyframes noteHit {
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.8); filter: blur(2px); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(.7); opacity: .28; }
  50% { transform: scale(1.4); opacity: .95; }
}

@keyframes wordFloat {
  0% { opacity: 0; transform: translateY(24px) scale(.94); }
  18% { opacity: .82; }
  100% { opacity: 0; transform: translateY(-60px) scale(1.06); }
}

@media (max-height: 740px) {
  .phone { width: min(100vw, 370px); }
  .korori-wrap { bottom: 250px; transform: translateX(-50%) scale(.86); }
  .lyric { top: 50%; font-size: 17px; }
  .lanes { height: 190px; bottom: 138px; }
  .editor-panel { padding: 10px; }
  .editor-surface { gap: 8px; padding: 10px; }
  .editor-header h2 { font-size: 20px; }
  .editor-actions button { font-size: 11px; }
}

@media (max-width: 430px) {
  .shell { padding: 0; }
  .phone {
    width: 100vw;
    height: 100vh;
    padding: 0;
    border-radius: 0;
  }
  .mv { border-radius: 0; }
}

.result[hidden],
.overlay[hidden],
.password-panel[hidden],
.editor-panel[hidden] {
  display: none !important;
  pointer-events: none !important;
}
