* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html {
  margin: 0;
  height: 100%;
}

body {
  margin: 0;
  height: 100vh;
  font-family: "Hiragino Maru Gothic Pro", "BIZ UDPGothic", "Rounded Mplus 1c", sans-serif;
  background: #f2f2f2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
}

.game-header {
  height: 50px;
  padding: 10px 16px;
  background: #ffffff;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.header-message {
  font-weight: bold;
  text-align: center;
  color: #224;
}

.header-actions {
  position: absolute;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-chip {
  background: #eef9ff;
  border: 2px solid #8fd3ff;
  border-radius: 999px;
  color: #18506f;
  font-size: 13px;
  font-weight: bold;
  padding: 5px 10px;
  white-space: nowrap;
}

.btn-quit {
  background: #ffffff;
  border: 2px solid #ff8e8e;
  border-radius: 999px;
  color: #c0392b;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: bold;
  padding: 5px 12px;
  white-space: nowrap;
}

.btn-quit:hover {
  background: #fff0f0;
}

.game-main {
  position: relative;
  background: #ffffff;
  flex: 1;
  overflow: hidden;
}

#game-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#bg-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #87ceeb 0%, #b8e8f7 55%, #d4f1ff 70%);
  z-index: 0;
}

.cloud {
  position: absolute;
  background: white;
  border-radius: 50px;
  opacity: 0.85;
  z-index: 1;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: white;
  border-radius: 50%;
}

.c1 { width: 110px; height: 36px; top: 40px; left: 60px; animation: cloudMove 20s linear infinite; }
.c1::before { width: 60px; height: 55px; top: -28px; left: 15px; }
.c1::after { width: 45px; height: 42px; top: -20px; left: 48px; }
.c2 { width: 80px; height: 28px; top: 70px; left: 300px; animation: cloudMove 28s linear infinite; }
.c2::before { width: 50px; height: 44px; top: -24px; left: 10px; }
.c2::after { width: 38px; height: 34px; top: -16px; left: 36px; }
.c3 { width: 130px; height: 38px; top: 25px; left: 700px; animation: cloudMove 24s linear infinite 5s; }
.c3::before { width: 70px; height: 60px; top: -32px; left: 20px; }
.c3::after { width: 55px; height: 48px; top: -22px; left: 60px; }
.c4 { width: 90px; height: 30px; top: 60px; left: 950px; animation: cloudMove 22s linear infinite 10s; }
.c4::before { width: 55px; height: 46px; top: -26px; left: 12px; }
.c4::after { width: 40px; height: 36px; top: -18px; left: 40px; }

@keyframes cloudMove {
  from { transform: translateX(0); }
  to { transform: translateX(-1300px); }
}

#sun {
  position: absolute;
  top: 18px;
  right: 60px;
  width: 64px;
  height: 64px;
  background: radial-gradient(circle, #ffe44d 60%, #ffb800 100%);
  border-radius: 50%;
  box-shadow: 0 0 24px 8px rgba(255, 220, 0, 0.45);
  z-index: 2;
  animation: sunPulse 3s ease-in-out infinite;
}

@keyframes sunPulse {
  0%, 100% { box-shadow: 0 0 24px 8px rgba(255, 220, 0, 0.45); }
  50% { box-shadow: 0 0 40px 16px rgba(255, 220, 0, 0.65); }
}

#sea {
  position: absolute;
  bottom: 170px;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(180deg, #29b6f6 0%, #1565c0 100%);
  z-index: 3;
  overflow: hidden;
}

.wave,
.wave2 {
  position: absolute;
  width: 200%;
  background-repeat: repeat-x;
}

.wave {
  height: 32px;
  top: -12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20'%3E%3Cpath d='M0,10 C30,0 70,20 100,10 C130,0 170,20 200,10 L200,20 L0,20Z' fill='%2329b6f6'/%3E%3C/svg%3E");
  background-size: 200px 32px;
  animation: waveMov 2.5s linear infinite;
}

.wave2 {
  height: 28px;
  top: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20'%3E%3Cpath d='M0,12 C40,2 60,18 100,12 C140,2 160,18 200,12 L200,20 L0,20Z' fill='%2381d4fa'/%3E%3C/svg%3E");
  background-size: 220px 28px;
  animation: waveMov2 3.2s linear infinite;
  opacity: 0.6;
}

@keyframes waveMov {
  from { transform: translateX(0); }
  to { transform: translateX(-200px); }
}

@keyframes waveMov2 {
  from { transform: translateX(0); }
  to { transform: translateX(-220px); }
}

#beach {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 170px;
  background: linear-gradient(180deg, #f9d877 0%, #e6b84a 60%, #c99a30 100%);
  z-index: 4;
  overflow: hidden;
}

#beach::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    radial-gradient(circle, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
  background-size: 14px 14px, 22px 22px;
  background-position: 0 0, 7px 7px;
}

#beach::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent);
}

#game-area {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.item {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  transition: transform 0.1s;
  z-index: 11;
  filter: drop-shadow(2px 3px 3px rgba(0, 0, 0, 0.3));
  touch-action: manipulation;
}

.item:hover {
  transform: translate(-50%, -50%) scale(1.12) rotate(-3deg);
}

.item:active {
  transform: translate(-50%, -50%) scale(0.9);
}

.item-emoji {
  font-size: 48px;
  line-height: 1;
}

.item.trash .item-emoji {
  animation: wobble 2s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-8deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-4deg); }
}

.particle {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  border-radius: 50%;
  animation: particleFly 0.7s ease-out forwards;
}

@keyframes particleFly {
  0% { opacity: 1; transform: scale(1) translate(0, 0); }
  100% { opacity: 0; transform: scale(0) translate(var(--dx), var(--dy)); }
}

.wrong-mark {
  position: absolute;
  font-size: 48px;
  pointer-events: none;
  z-index: 25;
  animation: wrongAnim 0.6s ease-out forwards;
}

@keyframes wrongAnim {
  0% { opacity: 1; transform: scale(1.4); }
  100% { opacity: 0; transform: scale(0.8) translateY(-30px); }
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(0, 80, 160, 0.72) 0%, rgba(0, 80, 160, 0) 100%);
  pointer-events: none;
}

.hud-box {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  color: #224;
  font-size: 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.hud-icon {
  font-size: 24px;
}

.hud-small {
  font-size: 14px;
  color: #667;
}

#timer-bar-wrap {
  flex: 1;
  margin: 0 18px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  height: 18px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#timer-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #43e97b, #f9d423);
  border-radius: 12px;
  transition: width 0.3s linear, background 0.5s;
}

#score-box {
  min-width: 120px;
  justify-content: center;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 40, 100, 0.68);
  backdrop-filter: blur(3px);
}

#countdown-overlay,
#result-overlay {
  display: none;
}

.overlay-card {
  background: linear-gradient(135deg, #fff9e6 0%, #e0f7fa 100%);
  border-radius: 24px;
  padding: 28px 40px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
  border: 4px solid #ffd700;
  box-sizing: border-box;
  max-width: 620px;
  width: 94%;
}

.overlay-title {
  font-size: 38px;
  font-weight: bold;
  margin-bottom: 10px;
  line-height: 1.2;
}

.overlay-sub {
  font-size: 18px;
  color: #555;
  margin-bottom: 18px;
  line-height: 1.6;
}

.overlay-sub span {
  display: block;
  font-size: 13px;
  color: #888;
  margin-top: 4px;
}

.overlay-score {
  font-size: 28px;
  font-weight: bold;
  color: #e67e00;
  margin-bottom: 24px;
}

.result-line {
  display: block;
  white-space: nowrap;
}

.btn-start {
  background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: white;
  border: 0;
  border-radius: 50px;
  padding: 14px 44px;
  font-size: 25px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 20px rgba(255, 100, 80, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-start:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 28px rgba(255, 100, 80, 0.55);
}

.btn-start:active {
  transform: scale(0.96);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: nowrap;
}

.result-actions .btn-start {
  padding: 12px 28px;
  font-size: 22px;
}

.btn-next {
  background: linear-gradient(135deg, #43e97b, #38bdf8);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.38);
}

.btn-next:hover {
  box-shadow: 0 10px 28px rgba(56, 189, 248, 0.48);
}

#countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 45;
  align-items: center;
  justify-content: center;
  background: rgba(0, 40, 100, 0.5);
}

#countdown-num {
  font-size: 140px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 30px #43e97b, 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: countPop 0.5s ease-out;
}

@keyframes countPop {
  0% { transform: scale(2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pickup-badge {
  position: absolute;
  pointer-events: none;
  z-index: 22;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: badgeFloat 2.2s ease-out forwards;
  white-space: nowrap;
}

@keyframes badgeFloat {
  0% { opacity: 1; transform: translateY(0) scale(1.2); }
  70% { opacity: 1; transform: translateY(-30px) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1); }
}

.title-char {
  display: inline-block;
  animation: titleWave 1.5s ease-in-out infinite;
}

.title-spacer {
  display: inline-block;
  width: 8px;
}

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

.diff-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 22px;
  flex-wrap: nowrap;
}

.diff-btn {
  background: white;
  border: 3px solid #ccc;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.15s;
  white-space: nowrap;
}

.diff-btn:hover {
  transform: scale(1.06);
}

.diff-btn.selected {
  border-color: #ff6b6b;
  background: #fff0ee;
  color: #e03000;
}

@media (max-width: 720px) {
  .game-header {
    padding: 8px 10px;
    font-size: 12px;
  }

  .header-message {
    max-width: calc(100% - 142px);
    line-height: 1.2;
  }

  .header-actions {
    right: 8px;
    gap: 4px;
  }

  .level-chip,
  .btn-quit {
    font-size: 11px;
    padding: 4px 7px;
  }

  #hud {
    padding: 0 8px;
  }

  .hud-box {
    min-width: 74px;
    padding: 5px 8px;
    gap: 4px;
    font-size: 16px;
  }

  #score-box {
    min-width: 74px;
  }

  #timer-bar-wrap {
    margin: 0 8px;
  }

  .overlay-card {
    padding: 22px 16px;
  }

  .overlay-title {
    font-size: 30px;
  }

  .overlay-sub {
    font-size: 16px;
  }

  .item-emoji {
    font-size: 44px;
  }

  .btn-start {
    padding: 12px 32px;
    font-size: 22px;
  }

  .result-actions {
    gap: 8px;
  }

  .result-actions .btn-start {
    padding: 10px 14px;
    font-size: 18px;
  }

  .diff-btns {
    gap: 8px;
  }

  .diff-btn {
    padding: 8px 10px;
    font-size: 15px;
  }
}
