:root {
  --bg-top: #fff3d2;
  --bg-bottom: #ffbc6d;
  --card-bg: #fff8eb;
  --ink: #7f1a11;
  --red-1: #ff5450;
  --red-2: #d81e24;
  --gold-1: #ffe38e;
  --gold-2: #f7a21c;
  --danger-1: #5f5f68;
  --danger-2: #252633;
  --line: rgba(169, 63, 29, 0.22);
  --shadow: 0 14px 34px rgba(140, 45, 8, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(255, 255, 255, 0.85) 0 26%, transparent 27%),
    radial-gradient(circle at 92% 2%, rgba(255, 228, 170, 0.9) 0 18%, transparent 19%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.55;
}

.app-shell {
  position: relative;
  margin: 0 auto;
  width: min(100vw, 460px);
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
}

.screen {
  display: none;
  min-height: calc(100vh - max(12px, env(safe-area-inset-top)) - max(14px, env(safe-area-inset-bottom)));
}

.screen.active {
  display: flex;
}

#start-screen,
#result-screen {
  align-items: center;
  justify-content: center;
}

.card {
  width: 100%;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(255, 241, 220, 0.9);
  padding: 22px 18px;
}

.chip {
  margin: 0 0 8px;
  display: inline-block;
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 999px;
  color: #8f2c13;
  background: linear-gradient(180deg, #ffe8ac, #ffd17d);
}

h1 {
  margin: 0;
  font-size: 38px;
  letter-spacing: 2px;
  color: #bf1616;
  text-shadow: 0 3px 0 rgba(255, 216, 135, 0.7);
}

.subtitle {
  margin: 10px 0 12px;
  line-height: 1.45;
  font-size: 15px;
}

.best-line {
  margin: 10px 0;
  font-size: 16px;
}

.rules {
  margin: 12px 0 20px;
  padding-left: 18px;
  line-height: 1.5;
  font-size: 14px;
}

.btn {
  border: 0;
  border-radius: 14px;
  height: 48px;
  font-size: 17px;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  color: #fff8d8;
  background: linear-gradient(180deg, #ff5d46, #dd1d24);
  box-shadow: 0 8px 20px rgba(174, 39, 29, 0.3);
}

.btn-secondary {
  color: #8f240f;
  background: linear-gradient(180deg, #ffe8bf, #ffd488);
  box-shadow: 0 7px 18px rgba(189, 130, 39, 0.22);
}

#game-screen {
  flex-direction: column;
  gap: 10px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hud-block {
  background: rgba(255, 248, 233, 0.9);
  border-radius: 14px;
  text-align: center;
  padding: 6px 4px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: 0 8px 16px rgba(130, 52, 20, 0.15);
}

.hud-block span {
  display: block;
  font-size: 12px;
}

.hud-block strong {
  display: block;
  margin-top: 2px;
  font-size: 21px;
  color: #b31615;
  line-height: 1;
}

.combo-meter {
  background: rgba(255, 246, 220, 0.88);
  border-radius: 14px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.combo-track {
  width: 100%;
  height: 10px;
  background: rgba(185, 89, 29, 0.16);
  border-radius: 999px;
  overflow: hidden;
}

.combo-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffe178, #ff9636);
  transition: width 0.12s linear;
}

.combo-stage {
  margin: 6px 0 0;
  font-size: 13px;
  text-align: center;
}

#game-field {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 420px;
  border-radius: 22px;
  border: 2px solid rgba(255, 245, 225, 0.88);
  box-shadow: inset 0 5px 22px rgba(225, 110, 47, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 248, 231, 0.94), rgba(255, 204, 111, 0.95) 75%, rgba(255, 176, 82, 0.98)),
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.35), transparent 40%);
  touch-action: manipulation;
}

#game-field.stunned .packet {
  filter: grayscale(0.45) brightness(0.78);
}

.packet {
  position: absolute;
  left: 0;
  top: 0;
  border: 0;
  border-radius: 18px 18px 20px 20px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), 0 12px 18px rgba(113, 34, 8, 0.25);
  color: #ffeec7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 29px;
  font-weight: 700;
  padding-top: 8px;
  touch-action: manipulation;
  cursor: pointer;
  will-change: transform;
  outline: none;
}

.packet::before {
  content: "";
  position: absolute;
  left: 0;
  top: 30%;
  width: 100%;
  height: 16%;
  background: rgba(255, 239, 194, 0.34);
}

.packet::after {
  content: "";
  position: absolute;
  top: 8%;
  width: 28%;
  height: 14%;
  border-radius: 0 0 999px 999px;
  background: rgba(255, 255, 255, 0.31);
}

.packet-symbol {
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 0 rgba(101, 34, 9, 0.28);
}

.packet-badge {
  position: absolute;
  right: 6px;
  top: 6px;
  z-index: 1;
  line-height: 1;
  font-size: 12px;
  border-radius: 8px;
  padding: 2px 5px;
  color: #fff;
}

.packet-normal {
  background: linear-gradient(180deg, var(--red-1), var(--red-2));
}

.packet-gold {
  color: #984707;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  box-shadow: 0 8px 0 rgba(184, 116, 17, 0.24), 0 12px 24px rgba(183, 120, 24, 0.35);
}

.packet-gold .packet-badge {
  background: rgba(173, 82, 3, 0.86);
}

.packet-fake {
  background: linear-gradient(180deg, #ff6961, #d71f27);
  border: 2px dashed rgba(255, 213, 118, 0.78);
}

.packet-fake .packet-badge {
  background: rgba(76, 26, 16, 0.82);
}

.packet-bomb {
  color: #ffce73;
  background: linear-gradient(180deg, var(--danger-1), var(--danger-2));
  box-shadow: 0 8px 0 rgba(20, 20, 28, 0.4), 0 12px 24px rgba(32, 32, 46, 0.45);
}

.packet-bomb .packet-badge {
  background: rgba(201, 45, 36, 0.9);
}

.packet.pop {
  transform: scale(0.78);
  opacity: 0;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.float-text {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 800;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(66, 18, 7, 0.2);
  animation: score-float 560ms ease-out forwards;
}

.float-text.good {
  color: #be1a16;
}

.float-text.gold {
  color: #cb6900;
}

.float-text.bad {
  color: #213f83;
}

.freeze-mask {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(22, 40, 69, 0.4);
  color: #e7f0ff;
  font-size: 30px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.freeze-mask small {
  font-size: 14px;
  font-weight: 600;
}

.freeze-mask.active {
  opacity: 1;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: #8f3118;
}

#game-screen.shake {
  animation: shake 230ms linear 1;
}

h2 {
  margin: 0;
  font-size: 34px;
  color: #bf1616;
  text-align: center;
}

.result-title {
  margin: 8px 0 14px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 12px;
  padding: 12px;
  background: rgba(255, 239, 203, 0.56);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.result-grid p {
  margin: 0;
  font-size: 15px;
}

.result-grid p:nth-child(2n) {
  font-weight: 700;
  color: #b20f11;
}

.share-label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 14px;
}

#share-text {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(157, 66, 30, 0.4);
  background: #fffef9;
  color: #6f180f;
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  padding: 9px;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.toast {
  margin: 10px 0 0;
  min-height: 18px;
  text-align: center;
  font-size: 13px;
  color: #8f1d0f;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.toast.visible {
  opacity: 1;
}

@keyframes score-float {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.92);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -90px) scale(1.08);
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-4px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 34px;
  }

  .hud-block strong {
    font-size: 18px;
  }

  #game-field {
    min-height: 390px;
  }
}
