* {
  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:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
  background: #f2f2f2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  margin: 0 auto;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: linear-gradient(to bottom, #8fd3ff 0%, #8fd3ff 38%, #9ee06a 38%, #9ee06a 50%, #a9713f 50%, #7a4d28 78%, #5c3a1f 100%);
}

.game-header {
  height: 50px;
  flex: 0 0 50px;
  align-items: center;
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  padding: 4px 12px;
  background: transparent;
}

.info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: bold;
  flex-wrap: wrap;
  width: auto;
}

.game-main {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 0;
  background: transparent;
}

.sun {
  position: absolute;
  top: 22px;
  right: 40px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffd23f 70%);
  box-shadow: 0 0 30px 10px rgba(255,210,63,0.6);
}

.cloud {
  position: absolute;
  background: #ffffff;
  border-radius: 50px;
  opacity: 0.9;
}

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

.cloud.c1 {
  top: 30px;
  left: 60px;
  width: 80px;
  height: 26px;
  animation: float1 18s ease-in-out infinite;
}

.cloud.c1::before {
  width: 40px;
  height: 40px;
  top: -18px;
  left: 10px;
}

.cloud.c1::after {
  width: 30px;
  height: 30px;
  top: -12px;
  left: 42px;
}

.cloud.c2 {
  top: 55px;
  left: 260px;
  width: 60px;
  height: 20px;
  animation: float2 22s ease-in-out infinite;
}

.cloud.c2::before {
  width: 30px;
  height: 30px;
  top: -14px;
  left: 6px;
}

.cloud.c2::after {
  width: 22px;
  height: 22px;
  top: -10px;
  left: 30px;
}

  @keyframes float1 { 0%,100% { transform: translateX(0);} 50% { transform: translateX(40px);} }
  @keyframes float2 { 0%,100% { transform: translateX(0);} 50% { transform: translateX(-30px);} }
.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

#startScreen {
  text-align: center;
  padding: 20px;
}

.panel {
  background: rgba(255,255,255,0.88);
  border-radius: 26px;
  padding: 28px 40px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}

.title {
  font-size: 44px;
  margin: 0 0 8px 0;
  color: #6b3f1d;
  text-shadow: 2px 2px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
}

.subtitle {
  font-size: 22px;
  margin: 8px 0 20px 0;
  color: #4a3320;
}

.big-btn {
  font-size: 30px;
  font-weight: bold;
  padding: 18px 48px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(#ffd76a, #ffb400);
  color: #5b3600;
  box-shadow: 0 6px 0 #c98600, 0 10px 16px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.1s;
}

.big-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 #c98600;
}

#gameScreen {
  position: absolute;
  padding: 0 0 8px;
}

.quit-btn {
  font-weight: bold;
  border: none;
  border-radius: 40px;
  background: linear-gradient(#ff8a80, #e64a3f);
  color: #fff;
  box-shadow: 0 4px 0 #a8251c;
  cursor: pointer;
  padding: 6px 18px;
  font-size: 18px;
  height: 38px;
}

.quit-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #a8251c;
}

.instruction {
  flex: 0 0 30px;
  margin: 0;
  text-align: center;
  font-size: 19px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

.amida-wrap {
  position: relative;
  flex: 1;
  width: 100%;
}

.top-row, .bottom-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 50px;
  height: 92px;
}

.top-row {
  top: 0;
}

.bottom-row {
  bottom: 0;
}

.amida-svg {
  position: absolute;
  left: 0;
  right: 0;
  top: 92px;
  bottom: 92px;
  width: 100%;
  height: calc(100% - 184px);
}

.grid-line {
  stroke: #6b4423;
  stroke-width: 5;
  stroke-linecap: round;
}

.trace-path {
  stroke: #ff6f00;
  stroke-width: 8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(255,111,0,0.7));
}

.lane-btn {
  width: 92px;
  height: 78px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(#a9e07a, #6fbf3f);
  box-shadow: 0 5px 0 #4a8b23, 0 8px 14px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: bold;
  color: #2e4d15;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.lane-btn .leaf {
  position: relative;
  font-size: 30px;
  line-height: 1;
}

.show-leaf-hint .leaf::after {
  content: '\1F446';
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 2;
  font-size: 36px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
  animation: leafHintTap 1s ease-in-out infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .show-leaf-hint .leaf::after {
    animation: none;
    transform: translate(-50%, 0);
  }
}

.lane-btn .num {
  font-size: 26px;
  line-height: 1.1;
}

.lane-btn:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 #4a8b23;
}

.lane-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.lane-btn.selected {
  outline: 5px solid #fff176;
  box-shadow: 0 0 0 5px #fff176, 0 5px 0 #4a8b23;
}

.hole {
  width: 96px;
  height: 82px;
  border-radius: 50% / 45%;
  background: radial-gradient(ellipse at center, #2e1c0f 0%, #4a2f18 55%, #6d4526 100%);
  border: 4px solid #3a2412;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.5);
}

.hole .hole-inner {
  white-space: nowrap;
  font-size: 26px;
}

.hole.revealed {
  background: radial-gradient(ellipse at center, #fff7dc 0%, #f4dfa3 60%, #e0c27a 100%);
}

.hole.revealed .hole-inner {
  animation: popIn 0.5s ease;
}

  @keyframes popIn {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
  }
.overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 56px;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  inset: 0;
  background: #281e1447;
}

.result-box {
  text-align: center;
  max-width: 80%;
  padding: 25px 45px;
  border-radius: 30px;
  background: #fff;
  box-shadow: 0 14px 25px #0004;
}

.result-emoji {
  font-size: 66px;
  margin-bottom: 6px;
}

.result-msg {
  font-weight: bold;
  color: #5b3600;
  margin-bottom: 18px;
  font-size: 20px;
  margin: 10px 0 18px;
}

#finalScreen {
  text-align: center;
}

.final-summary {
  margin-bottom: 10px;
  font-size: 30px;
  max-width: 750px;
  overflow-wrap: anywhere;
}

.final-count {
  font-size: 22px;
  color: #6b3f1d;
  margin-bottom: 10px;
  font-weight: bold;
  margin-top: 8px;
}

.final-praise {
  font-size: 26px;
  color: #6b3f1d;
  font-weight: bold;
  margin-bottom: 20px;
}

button {
  font-family: inherit;
}

.game-header h1 {
  margin: 0;
  font-size: 24px;
  color: #6b3f1d;
  text-align: center;
}

.header-actions {
  display: flex;
  gap: 8px;
  justify-self: end;
  align-items: center;
}

.info-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 40px;
  padding: 6px 16px;
  font-size: 18px;
  font-weight: bold;
  color: #444;
  box-shadow: 0 2px 0 #e8a000;
}

.info-box .val {
  font-size: 22px;
  color: #ff6f3c;
  min-width: 24px;
  text-align: center;
}

.sound-btn {
  border: 3px solid #f2b321;
  border-radius: 50px;
  padding: 6px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #694100;
  cursor: pointer;
  background: #fff0ad;
  box-shadow: 0 3px 0 #d89500;
  min-width: 104px;
  height: 38px;
}

.sound-btn:hover {
  background: #ffe680;
  border-color: #dc9700;
  color: #5a3500;
}

.sound-btn.sound-off {
  background: #e9edf1;
  border-color: #aeb7c0;
  color: #66717b;
  box-shadow: 0 3px 0 #929ba4;
}

.top-sound {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 30;
}

.progress-wrap {
  height: 30px;
  flex: 0 0 30px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.progress-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ddd;
}

.progress-dot.done {
  background: #6ecb63;
}

.progress-dot.current {
  background: #f9a825;
  border: 3px solid #c77c00;
}

.feedback-title {
  display: block;
  font-size: 39px;
  color: #2fb768;
}

.feedback-title.wrong {
  color: #d9534f;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.result-actions .big-btn {
  font-size: 22px;
  padding: 14px 26px;
}

.home-btn {
  background: linear-gradient(#a9e0f5, #7ec8e3);
  box-shadow: 0 6px 0 #4898b5, 0 10px 16px #0003;
  color: #0a3a5a;
}

.sun, .cloud {
  pointer-events: none;
}

button:focus-visible {
  outline: 4px solid #ff6f00;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  .game-header { padding: 4px 5px; gap: 4px; }
  .game-header h1 { font-size: 18px; }
  .header-actions { gap: 4px; }
  .info-box { padding: 6px 8px; gap: 4px; font-size: 13px; }
  .info-box .val { font-size: 18px; min-width: 14px; }
  .quit-btn { font-size: 14px; padding: 5px 9px; }
  .sound-btn { min-width: 66px; font-size: 14px; padding: 5px 7px; }
  .top-row, .bottom-row { padding: 0 8px; }
  .lane-btn { width: 64px; }
  .hole { width: 70px; }
  .hole .hole-inner { font-size: 19px; }
  .panel { padding: 24px 16px; max-width: 96%; }
  .title { font-size: 34px; }
  .subtitle { font-size: 18px; }
  .result-box { max-width: 94%; padding: 22px 18px; }
  .result-actions { gap: 10px; }
  .result-actions .big-btn { font-size: 17px; padding: 14px 16px; }
  .final-praise { font-size: 20px; }
  .final-summary { font-size: 23px; }
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: confettiFall 3s linear both;
}
@keyframes confettiFall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate3d(var(--drift), var(--fall), 0) rotate(var(--spin)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-layer { display: none; }
}
.final-title { font-size: 36px; }
