/* ============ ポテトくんキャッチ！ ============ */
:root {
  --c-yellow: #ffcc00;
  --c-red: #e60023;
  --c-orange: #ff8a00;
  --c-blue: #1a9fe0;
  --c-cream: #fff6e0;
  --c-ink: #221a14;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: "Zen Maru Gothic", sans-serif;
  background: var(--c-yellow);
  background-image:
    radial-gradient(rgba(230, 0, 35, .14) 18%, transparent 19%),
    radial-gradient(rgba(230, 0, 35, .14) 18%, transparent 19%);
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: none;
  touch-action: none;
}

.game-wrap {
  width: min(480px, 100vw);
  padding: 8px;
}

.game-frame {
  position: relative;
  border: 5px solid var(--c-ink);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 8px 8px 0 rgba(34, 26, 20, .35);
  background: var(--c-cream);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ============ オーバーレイ ============ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: rgba(255, 246, 224, .94);
  padding: 20px;
  z-index: 10;
}

.overlay.is-hidden { display: none; }

.overlay__fes {
  font-family: "Bangers", cursive;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--c-red);
}

.overlay__title {
  font-size: 44px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--c-ink);
  text-shadow: 3px 3px 0 var(--c-yellow);
}

.overlay__title span { color: var(--c-red); }

.overlay__char {
  width: 180px;
  max-width: 45%;
  height: auto;
  animation: bounce 1.6s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-12px) rotate(3deg); }
}

.overlay__desc {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.8;
  color: var(--c-ink);
}

.overlay__items {
  font-size: 12px;
  color: #7a6a55;
}

.overlay--over { gap: 10px; padding: 14px; }

.overlay__over {
  font-family: "Bangers", cursive;
  font-size: 44px;
  letter-spacing: 4px;
  color: var(--c-red);
  text-shadow: 3px 3px 0 var(--c-ink);
}

.overlay__result {
  font-size: 22px;
  font-weight: 900;
  color: var(--c-ink);
}

.overlay__result span {
  font-size: 40px;
  color: var(--c-orange);
  text-shadow: 2px 2px 0 var(--c-ink);
}

.overlay__hiscore {
  font-size: 14px;
  font-weight: 700;
  color: #7a6a55;
}

.overlay__newrecord {
  font-size: 18px;
  font-weight: 900;
  color: var(--c-red);
  animation: flash .6s steps(2) infinite;
}

@keyframes flash { 50% { opacity: .25; } }

/* ============ ボタン ============ */
.btn {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  background: var(--c-red);
  border: 4px solid var(--c-ink);
  border-radius: 999px;
  padding: 12px 44px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--c-ink);
  transition: transform .08s, box-shadow .08s;
}

.btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--c-ink);
}

.btn--sub {
  font-size: 15px;
  padding: 8px 24px;
  background: var(--c-blue);
  box-shadow: 0 4px 0 var(--c-ink);
}

/* ============ ランキング ============ */
.overlay__ranktitle {
  font-size: 26px;
  font-weight: 900;
  color: var(--c-ink);
  text-shadow: 2px 2px 0 var(--c-yellow);
}

.rank-list {
  list-style: none;
  width: min(320px, 84%);
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-list--over { max-height: 150px; }

.rank-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 3px solid var(--c-ink);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--c-ink);
}

.rank-list li .rank-no {
  font-family: "Bangers", cursive;
  font-size: 20px;
  color: var(--c-orange);
  min-width: 28px;
}

.rank-list li:nth-child(1) .rank-no { color: #d4a800; font-size: 24px; }
.rank-list li:nth-child(2) .rank-no { color: #8a9299; }
.rank-list li:nth-child(3) .rank-no { color: #b0662a; }

.rank-list li .rank-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.rank-list li .rank-score { font-weight: 900; }

.rank-list li.is-me {
  background: var(--c-yellow);
  animation: flash 1s steps(2) 3;
}

.rank-list .rank-empty {
  border-style: dashed;
  color: #9a8a70;
  justify-content: center;
}

.rank-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.rank-form input {
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  border: 3px solid var(--c-ink);
  border-radius: 12px;
  padding: 8px 12px;
  width: 220px;
  background: #fff;
  color: var(--c-ink);
}

.rank-form input:focus { outline: 3px solid var(--c-blue); }

.rank-msg {
  font-size: 14px;
  font-weight: 900;
  color: var(--c-red);
}

.game-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: rgba(34, 26, 20, .6);
}
