﻿* {
  box-sizing: border-box;
  touch-action: manipulation; /*タブレット連打時の拡大防止 */
}

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

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #1a6b2e;
  background-image:
    radial-gradient(ellipse at 20% 0%, #2d9e4a 0%, transparent 50%),
    radial-gradient(ellipse at 80% 0%, #1a8c35 0%, transparent 50%),
    repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(0,0,0,0.03) 40px, rgba(0,0,0,0.03) 41px);
  font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 2px solid rgba(0,0,0,0.45);
  border-radius: 18px;
  box-shadow: 0 8px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}

.game-header {
  height: 50px;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: #fff8e6;
  border-bottom: 2px solid rgba(145, 93, 24, 0.28);
}

.info {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a3f00;
  font-weight: 900;
}

.info-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  text-align: center;
  white-space: nowrap;
}

.header-btn {
  position: absolute;
  left: 0;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 34px;
  padding: 0 16px;
  border: 3px solid #d89b11;
  border-radius: 999px;
  background: linear-gradient(180deg, #fffdf4 0%, #ffe083 100%);
  color: #7a3f00;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 #b97800, 0 6px 12px rgba(0,0,0,0.16);
  text-shadow: 0 1px 0 rgba(255,255,255,0.8);
  transform: translateY(0);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
}

.header-btn.is-visible {
  display: inline-flex;
}

.header-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #ffdf73 100%);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #b97800, 0 8px 14px rgba(0,0,0,0.16);
}

.header-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b97800, 0 3px 8px rgba(0,0,0,0.14);
}

.high-record {
  position: absolute;
  right: 0;
  font-size: 13px;
  color: #9a6a18;
  white-space: nowrap;
}

.game-main {
  position: relative;
  flex: 1;
  min-height: 0;
}

#app {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg,
    #87CEEB 0%,
    #b0e0f8 35%,
    #c8eeaa 60%,
    #8BC34A 60%,
    #6aaa2e 100%
  );
  cursor: none;
}

  .cloud {
    position: absolute;
    background: white;
    border-radius: 50px;
    opacity: 0.85;
    animation: cloudDrift linear infinite;
  }
  .cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 50%;
  }
  .cloud-1 { width: 120px; height: 40px; top: 30px; animation-duration: 25s; animation-delay: 0s; }
  .cloud-1::before { width: 60px; height: 60px; top: -30px; left: 15px; }
  .cloud-1::after  { width: 40px; height: 40px; top: -20px; left: 50px; }
  .cloud-2 { width: 80px;  height: 28px; top: 70px; animation-duration: 32s; animation-delay: -12s; opacity: 0.7; }
  .cloud-2::before { width: 40px; height: 40px; top: -22px; left: 10px; }
  .cloud-2::after  { width: 30px; height: 30px; top: -15px; left: 35px; }
  .cloud-3 { width: 100px; height: 34px; top: 15px; animation-duration: 28s; animation-delay: -8s; opacity: 0.75; }
  .cloud-3::before { width: 50px; height: 50px; top: -28px; left: 12px; }
  .cloud-3::after  { width: 36px; height: 36px; top: -18px; left: 44px; }
  @keyframes cloudDrift {
    from { transform: translateX(-200px); }
    to   { transform: translateX(1400px); }
  }

  .tree {
    position: absolute;
    bottom: 50px;
    display: flex; flex-direction: column; align-items: center;
  }
  .tree-top {
    width: 0; height: 0;
    border-left: 22px solid transparent;
    border-right: 22px solid transparent;
    border-bottom: 44px solid #2d7a1e;
    position: relative;
  }
  .tree-top::after {
    content: '';
    position: absolute;
    top: 16px; left: -18px;
    width: 0; height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-bottom: 36px solid #3a9a27;
  }
  .tree-trunk {
    width: 10px; height: 20px;
    background: #7B4B2A;
    border-radius: 2px;
  }

  .grass-strip {
    position: absolute;
    bottom: 46px;
    left: 0; right: 0;
    height: 8px;
    background: #5aac20;
    border-radius: 4px 4px 0 0;
  }

  #hud {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    display: flex;
    align-items: stretch;
    gap: 10px;
    z-index: 50;
    pointer-events: none;
  }
  .hud-panel {
    background: rgba(255,255,255,0.88);
    border-radius: 14px;
    padding: 6px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 6px;
    pointer-events: auto;
    min-height: 48px;
  }
  .hud-label { font-size: 13px; color: #555; font-weight: 700; }
  .hud-value { font-size: 18px; font-weight: 900; color: #e05522; font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif; }
  .hud-value.blue { color: #2060cc; }

  .level-panel {
    min-width: 132px;
  }

  #target-panel {
    position: relative;
    flex: 1;
    background: linear-gradient(135deg, #fff9e6, #fff3cc);
    border: 3px solid #f5c518;
    border-radius: 14px;
    min-height: 48px;
    padding: 4px 16px;
    display: flex; align-items: center;
    box-shadow: 0 2px 12px rgba(245,197,24,0.4);
  }
  .target-center {
    position: absolute;
    left: 50%;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    transform: translateX(-50%);
    white-space: nowrap;
  }
  .target-char {
    font-size: 34px; font-weight: 900;
    color: #e05000;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    line-height: 0.95;
    font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
    animation: targetPulse 2s ease-in-out infinite;
  }
  @keyframes targetPulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
  }
  .target-hint {
    font-size: 12px;
    color: #b07a00;
    font-weight: 900;
  }

  .apple {
    position: absolute;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center;
    user-select: none;
    transition: none;
    z-index: 20;
    animation: appleSway 2s ease-in-out infinite;
  }
  @keyframes appleSway {
    0%,100% { transform: rotate(-3deg); }
    50%      { transform: rotate(3deg); }
  }
  .apple-body {
    width: 64px; height: 64px;
    border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    box-shadow: inset -8px -6px 0 rgba(0,0,0,0.1), 3px 4px 10px rgba(0,0,0,0.25);
    font-size: 26px;
    font-weight: 900;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.35);
    font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  }
  .apple-body.red    { background: radial-gradient(circle at 35% 30%, #ff7070, #c0192c); }
  .apple-body.green  { background: radial-gradient(circle at 35% 30%, #a0e060, #3a8a1a); }
  .apple-body.yellow { background: radial-gradient(circle at 35% 30%, #ffe090, #e0a010); }
  .apple-body::before {
    content: '';
    position: absolute;
    top: 8px; left: 14px;
    width: 16px; height: 10px;
    background: rgba(255,255,255,0.4);
    border-radius: 50%;
    transform: rotate(-30deg);
  }
  .apple-stem {
    width: 4px; height: 12px;
    background: #5c3a1e;
    border-radius: 2px;
    margin-bottom: -3px;
    position: relative; z-index: 1;
  }
  .apple-leaf {
    position: absolute;
    top: -8px; right: -4px;
    width: 16px; height: 10px;
    background: #3aaa20;
    border-radius: 50% 0 50% 0;
    transform: rotate(-20deg);
  }

  #basket-wrap {
    position: absolute;
    bottom: 50px;
    z-index: 30;
    display: flex; flex-direction: column; align-items: center;
    cursor: none;
    transition: left 0.04s linear;
    pointer-events: none;
  }
  #basket {
    width: 110px; height: 80px;
    position: relative;
  }
  .basket-body {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 65px;
    background: linear-gradient(180deg, #d4a04a, #a06018);
    clip-path: polygon(6% 0%, 94% 0%, 100% 100%, 0% 100%);
    overflow: hidden;
  }
  .basket-body::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      90deg,
      transparent 0px, transparent 9px,
      rgba(0,0,0,0.12) 9px, rgba(0,0,0,0.12) 11px
    ), repeating-linear-gradient(
      180deg,
      transparent 0px, transparent 9px,
      rgba(0,0,0,0.08) 9px, rgba(0,0,0,0.08) 11px
    );
  }
  .basket-rim {
    position: absolute;
    top: 0; left: -4px; right: -4px;
    height: 14px;
    background: linear-gradient(180deg, #e8b860, #c07828);
    border-radius: 6px 6px 0 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  }
  .basket-handle-left, .basket-handle-right {
    position: absolute;
    top: -22px;
    width: 14px; height: 30px;
    border: 5px solid #a06018;
    border-bottom: none;
    border-radius: 14px 14px 0 0;
  }
  .basket-handle-left  { left: 10px;  transform: rotate(-8deg); }
  .basket-handle-right { right: 10px; transform: rotate(8deg); }

  .screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    z-index: 100;
    gap: 16px;
    cursor: auto;
  }
  .screen h1 {
    font-size: 52px; font-weight: 900;
    color: #fff8e0;
    text-shadow: 3px 3px 0 #c05000, 6px 6px 12px rgba(0,0,0,0.4);
    font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
    animation: titleBounce 1s ease-in-out infinite alternate;
  }
  @keyframes titleBounce {
    from { transform: translateY(0); }
    to   { transform: translateY(-8px); }
  }
  .screen p { font-size: 18px; color: #ffe0b0; text-align: center; line-height: 1.8; }
  .btn {
    padding: 16px 48px;
    font-size: 22px;
    font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
    font-weight: 900;
    color: white;
    background: linear-gradient(135deg, #ff6b35, #e02000);
    border: none; border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #900, 0 8px 20px rgba(0,0,0,0.3);
    transform: translateY(0);
    transition: transform 0.1s, box-shadow 0.1s;
    letter-spacing: 2px;
  }
  .btn:hover  { transform: translateY(-3px); box-shadow: 0 9px 0 #900, 0 12px 24px rgba(0,0,0,0.3); }
  .btn:active { transform: translateY(3px);  box-shadow: 0 3px 0 #900; }
  .btn.secondary {
    background: linear-gradient(135deg, #4aa3ff, #1f62c9);
    box-shadow: 0 6px 0 #123b80, 0 8px 20px rgba(0,0,0,0.3);
  }
  .btn.secondary:hover {
    box-shadow: 0 9px 0 #123b80, 0 12px 24px rgba(0,0,0,0.3);
  }
  .btn.secondary:active {
    box-shadow: 0 3px 0 #123b80;
  }

  .result-score {
    margin-top: -16px;
    margin-bottom: 10px;
    padding: 8px 22px;
    border: 3px solid rgba(255, 210, 60, 0.95);
    border-radius: 999px;
    background: rgba(255, 248, 224, 0.18);
    box-shadow: 0 4px 16px rgba(255, 198, 0, 0.25), inset 0 1px 0 rgba(255,255,255,0.28);
    font-size: 32px;
    font-weight: 900;
    color: #fff8e0;
    text-shadow: 2px 2px 0 #b85a00, 0 4px 10px rgba(0,0,0,0.45);
  }
  .result-actions {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
  }

  .effect-text {
    position: absolute;
    font-size: 28px;
    font-weight: 900;
    font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
    pointer-events: none;
    z-index: 60;
    animation: floatUp 0.9s ease-out forwards;
  }
  .effect-text.good  { color: #ff4a00; text-shadow: 0 0 10px #ffaa00, 2px 2px 0 #800; }
  .effect-text.miss  { color: #2266ee; text-shadow: 0 0 10px #aaccff, 2px 2px 0 #004; }
  @keyframes floatUp {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    80%  { opacity: 1; transform: translateY(-60px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-80px) scale(0.9); }
  }

  .splat {
    position: absolute;
    width: 70px; height: 70px;
    border-radius: 50%;
    z-index: 15;
    animation: splatAnim 0.6s ease-out forwards;
    pointer-events: none;
  }
  @keyframes splatAnim {
    0%   { transform: scale(0); opacity: 0.9; }
    60%  { transform: scale(1.4); opacity: 0.7; }
    100% { transform: scale(1.8); opacity: 0; }
  }

  #progress-bar-wrap {
    position: absolute;
    bottom: 8px; left: 50%; transform: translateX(-50%);
    width: 300px; height: 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    overflow: hidden;
    z-index: 50;
  }
  #progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #ff6b35, #ffcc00);
    border-radius: 6px;
    transition: width 0.3s;
  }

  .hearts {
    display: inline-flex;
    gap: 3px;
    font-size: 20px;
    letter-spacing: 0;
  }
  .heart {
    color: #e94b6d;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
  }
  .heart.empty {
    color: #b9b9b9;
    filter: none;
  }

  .difficulty-btns { display: flex; gap: 12px; }
  .diff-btn {
    padding: 10px 24px;
    font-size: 16px;
    font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
    font-weight: 900;
    border: none; border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.3);
    transform: translateY(0);
    transition: transform 0.1s, box-shadow 0.1s;
  }
  .diff-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(0,0,0,0.3); }
  .diff-btn.easy   { background: linear-gradient(135deg, #60cc40, #2a9a10); color: white; }
  .diff-btn.normal { background: linear-gradient(135deg, #ffc030, #e08000); color: white; }
  .diff-btn.hard   { background: linear-gradient(135deg, #ff5050, #cc1010); color: white; }
