/* 像素风 - 生日刮刮卡 */
@font-face {
  font-family: "PixelFont";
  src: local("Menlo");
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1e2a1a;
  font-family: "PixelFont", "Menlo", "Courier New", monospace;
  color: #fff6e0;
  image-rendering: pixelated;
}

.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ---- 菜单界面 ---- */
#menu-screen, #exit-screen {
  background: linear-gradient(180deg, #ff8a80 0%, #ff5252 55%, #d32f2f 100%);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.15) 0 3px, transparent 4px),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,0.15) 0 3px, transparent 4px),
    radial-gradient(circle at 50% 70%, rgba(255,255,255,0.15) 0 3px, transparent 4px),
    linear-gradient(180deg, #ff8a80 0%, #ff5252 55%, #d32f2f 100%);
}

.menu-panel {
  background: #3b2a1e;
  border: 4px solid #f2d9a1;
  box-shadow:
    0 0 0 4px #6b4a2f,
    0 8px 0 rgba(0,0,0,0.35),
    inset 0 0 0 2px #23160e;
  border-radius: 10px;
  padding: 36px 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 86vw;
}

.menu-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
  text-align: center;
}

.title-line {
  font-size: 28px;
  letter-spacing: 2px;
  color: #ffe9a8;
  text-shadow: 2px 2px 0 #5a3b1f, 4px 4px 0 rgba(0,0,0,0.3);
}

.title-sub {
  font-size: 14px;
  color: #ffccbc;
  margin-top: 6px;
  letter-spacing: 1px;
}

.exit-text {
  font-size: 13px;
  color: #e8dcc0;
  text-align: center;
  max-width: 240px;
  line-height: 1.6;
}

.coin-icon-deco {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c0, #ffcf3f 45%, #d99a1e 80%, #8a5c10 100%);
  box-shadow: 0 0 0 2px #6b4a1f, 0 3px 0 rgba(0,0,0,0.3);
  margin-bottom: 4px;
  animation: coinSpin 1.6s linear infinite;
}

@keyframes coinSpin {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(0.15); }
}

.menu-btn {
  width: 220px;
  padding: 14px 0;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  color: #3b2a1e;
  background: linear-gradient(180deg, #ffe9a8 0%, #f2c869 100%);
  border: 3px solid #6b4a1f;
  border-radius: 6px;
  box-shadow: 0 4px 0 #6b4a1f, inset 0 -3px 0 rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.05s ease;
}

.menu-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #6b4a1f, inset 0 -3px 0 rgba(0,0,0,0.15);
}

.menu-btn-secondary {
  background: linear-gradient(180deg, #d0c4b0 0%, #a99a82 100%);
  color: #3b2a1e;
}

/* ---- 游戏主界面 ---- */
#game-screen {
  flex-direction: column;
  background: #a67c52;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #a67c52;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 14px 0 14px;
  z-index: 10;
  pointer-events: none;
}

#scratch-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(35, 22, 14, 0.75);
  border: 2px solid #f2d9a1;
  border-radius: 20px;
  padding: 6px 14px 6px 8px;
  pointer-events: auto;
}

.progress-icon {
  font-size: 20px;
  flex-shrink: 0;
}

#scratch-progress {
  font-size: 18px;
  color: #ffe9a8;
  text-shadow: 1px 1px 0 #23160e;
  min-width: 3em;
}

#btn-quit {
  pointer-events: auto;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  color: #3b2a1e;
  background: linear-gradient(180deg, #ffe9a8 0%, #f2c869 100%);
  border: 2px solid #6b4a1f;
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 0 3px 0 #6b4a1f;
}

#btn-quit:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #6b4a1f;
}

/* ---- 虚拟方向键（四方向） ---- */
#dpad {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 150px;
  height: 150px;
  z-index: 10;
}

.dpad-btn {
  position: absolute;
  width: 50px;
  height: 50px;
  background: rgba(35, 22, 14, 0.65);
  border: 2px solid rgba(242, 217, 161, 0.85);
  border-radius: 10px;
  color: #ffe9a8;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.dpad-btn:active,
.dpad-btn.active {
  background: rgba(242, 217, 161, 0.85);
  color: #3b2a1e;
}

.dpad-up { top: 0; left: 50px; }
.dpad-left { top: 50px; left: 0; }
.dpad-right { top: 50px; left: 100px; }
.dpad-down { top: 100px; left: 50px; }

@media (min-width: 700px) {
  #dpad { width: 180px; height: 180px; }
  .dpad-btn { width: 60px; height: 60px; font-size: 22px; }
  .dpad-up { left: 60px; }
  .dpad-left { top: 60px; left: 0; }
  .dpad-right { top: 60px; left: 120px; }
  .dpad-down { top: 120px; left: 60px; }
}
