* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #d8dde6;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: #1a1a1a;
  user-select: none;
  touch-action: none;
}

#app {
  width: min(100vw, 430px);
  height: 100%;
  max-height: 100dvh;
  margin: 0 auto;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ffffff;
}

.hidden {
  display: none !important;
}

.brand {
  font-size: clamp(22px, 6.2vw, 28px);
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffc2d4;
  -webkit-text-stroke: 1.6px #2b2b2b;
  paint-order: stroke fill;
  text-align: center;
  line-height: 1.35;
  display: inline-block;
  border-bottom: 3px solid #2b2b2b;
  padding: 0 4px 6px;
}

.brand.small {
  font-size: 22px;
}

.tagline {
  margin-top: 14px;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 900;
  text-align: center;
  color: #111;
  letter-spacing: 1px;
}

.home-inner, .select-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 20px 24px;
  overflow: auto;
  touch-action: pan-y;
}

.home-hero {
  width: 120px;
  height: 160px;
  margin: 22px 0 8px;
  animation: bounce 1.1s ease-in-out infinite;
}

.home-hero svg, .hero svg, .toilet svg, .dialog-art svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.home-tip {
  color: #666;
  font-size: 14px;
  margin: 8px 0 22px;
  text-align: center;
}

.progress-hint {
  margin-top: 14px;
  font-size: 13px;
  color: #888;
}

.btn {
  appearance: none;
  border: 3px solid #2b2b2b;
  background: #fff;
  color: #111;
  font-weight: 800;
  font-size: 16px;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  min-width: 210px;
  font-family: inherit;
}

.btn-primary {
  background: #7eb0e0;
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn-ghost {
  margin-top: 12px;
  background: #fff;
}

.btn-small {
  min-width: 0;
  padding: 8px 18px;
  font-size: 14px;
  margin: 0;
}

.btn:active {
  transform: scale(0.97);
}

.level-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0;
}

.level-cell {
  height: 64px;
  border: 3px solid #2b2b2b;
  border-radius: 14px;
  background: #f4f7fb;
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
  color: #222;
}

.level-cell.locked {
  background: #ececec;
  color: #aaa;
  cursor: default;
}

.level-cell.cleared {
  background: #c8e7c0;
}

.game-header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 8px;
}

.meta-row {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-weight: 800;
  font-size: 14px;
}

#level-name {
  color: #668;
  font-weight: 600;
}

.urge-wrap {
  width: 72%;
  height: 10px;
  background: #eee;
  border: 2px solid #2b2b2b;
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}

.urge-bar {
  height: 100%;
  width: 18%;
  background: linear-gradient(90deg, #8fd18f, #f5d76e, #e86b6b);
  background-size: 220px 100%;
  border-radius: 999px;
  transform-origin: left center;
}

#stage {
  flex: 1;
  position: relative;
  min-height: 0;
  margin: 0 6px;
  touch-action: none;
}

#maze {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hero, .toilet, .puddle {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: left, top;
}

.hero {
  width: 58px;
  height: 78px;
  z-index: 3;
  pointer-events: auto;
  cursor: grab;
}

.hero.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.2));
}

.hero.shake {
  animation: shake 0.28s linear;
}

.hero.wiggle {
  animation: wiggle 0.7s ease-in-out infinite;
}

.toilet {
  width: 44px;
  height: 52px;
  z-index: 2;
}

.puddle {
  width: 70px;
  height: 22px;
  z-index: 1;
  background: radial-gradient(ellipse at center, #6ec4ea 0%, #3a9ccc 60%, transparent 70%);
  border-radius: 50%;
  opacity: 0.85;
}

.level-hint {
  min-height: 18px;
  font-size: 12px;
  color: #7a6;
  text-align: center;
  padding: 0 12px 4px;
  font-weight: 700;
}

.game-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px 16px;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}

.dialog {
  width: min(86%, 340px);
  background: #fff;
  border: 3px solid #2b2b2b;
  border-radius: 22px;
  padding: 22px 18px 18px;
  text-align: center;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.08);
}

.dialog-art {
  width: 90px;
  height: 110px;
  margin: 0 auto 8px;
}

.dialog h3 {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 6px;
}

.dialog p {
  color: #555;
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(0); }
  25% { transform: translate(calc(-50% - 4px), -50%) rotate(-6deg); }
  75% { transform: translate(calc(-50% + 4px), -50%) rotate(6deg); }
}

@keyframes wiggle {
  0%, 100% { transform: translate(-50%, -50%) rotate(-3deg); }
  50% { transform: translate(-50%, -50%) rotate(3deg); }
}
