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

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

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

.container {
  margin: 0 auto;
  background: linear-gradient(160deg, #fffbe8 0%, #fff3fa 100%);
  border: 2px solid #333;
  width: min(100%, 1196px);
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-header {
  height: 50px;
  padding: 8px 24px;
  background: linear-gradient(90deg, #ff7eb3, #ff9a3c);
  flex: 0 0 50px;
  display: flex;
  align-items: center;
}

.info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: #fff;
  font-weight: bold;
}

.score-info {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  padding: 4px 18px;
  font-size: 18px;
  white-space: nowrap;
}

#quit-btn {
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  padding: 4px 14px;
  white-space: nowrap;
}

#quit-btn:active {
  transform: translateY(2px);
}

.game-main {
  position: relative;
  background: transparent;
  flex: 1;
  overflow: hidden;
  display: block;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50px;
  pointer-events: none;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.c1 {
  width: 100px;
  height: 36px;
  top: 20px;
  left: 30px;
}

.c1::before {
  width: 50px;
  height: 50px;
  top: -24px;
  left: 10px;
}

.c1::after {
  width: 38px;
  height: 38px;
  top: -18px;
  left: 38px;
}

.c2 {
  width: 80px;
  height: 28px;
  top: 24px;
  right: 80px;
}

.c2::before {
  width: 38px;
  height: 38px;
  top: -20px;
  left: 8px;
}

.c2::after {
  width: 28px;
  height: 28px;
  top: -14px;
  left: 32px;
}

.c3 {
  width: 60px;
  height: 22px;
  bottom: 60px;
  left: 200px;
  opacity: 0.4;
}

.c3::before {
  width: 30px;
  height: 30px;
  top: -16px;
  left: 6px;
}

.c3::after {
  width: 22px;
  height: 22px;
  top: -12px;
  left: 24px;
}

#main {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
  overflow: hidden;
}

#left-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 16px 8px 24px;
}

#problem-text {
  min-height: 28px;
  margin-bottom: 8px;
  color: #c0392b;
  font-size: 24px;
  font-weight: bold;
  line-height: 1.35;
  text-align: center;
}

#problem-text span {
  display: block;
}

#problem-text strong {
  color: #e64a19;
  font-size: 1.35em;
  font-weight: 900;
}

#dango-stage {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 240px;
  padding: 8px;
}

.stick-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: popIn 0.4s cubic-bezier(0.36, 1.6, 0.48, 1) both;
}

@keyframes popIn {
  from {
    transform: scale(0) translateY(30px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.dango-ball {
  position: relative;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb3c6, #ff6b9d);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  user-select: none;
}

.dango-ball::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 8px;
  width: 10px;
  height: 6px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transform: rotate(-30deg);
}

.dango-stick {
  width: 7px;
  height: 56px;
  margin-top: -3px;
  border-radius: 4px;
  background: linear-gradient(180deg, #d4956a, #b07040);
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.2);
}

#right-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.45);
  border-left: 3px dashed #ffb347;
}

#question-box {
  width: 100%;
  padding: 14px 20px;
  border: 3px solid #ffca28;
  border-radius: 20px;
  background: linear-gradient(135deg, #fff9c4, #ffe082);
  box-shadow: 0 4px 12px rgba(255, 180, 0, 0.2);
  text-align: center;
}

#question-box .q-formula {
  color: #e64a19;
  font-size: 44px;
  font-weight: bold;
}

#answer-area {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

#answer-input {
  width: 100px;
  height: 60px;
  border: 4px solid #ff7043;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  color: #333;
  font-family: inherit;
  font-size: 36px;
  text-align: center;
  outline: none;
}

#answer-input:focus {
  border-color: #e91e63;
}

#answer-input.correct {
  border-color: #4caf50;
  background: #e8f5e9;
}

#answer-input.wrong {
  border-color: #f44336;
  background: #ffebee;
  animation: wiggle 0.3s ease;
}

@keyframes wiggle {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

#submit-btn,
#start-btn,
#restart-btn {
  border: none;
  color: #fff;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
}

#submit-btn {
  width: 80px;
  height: 60px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff7043, #e64a19);
  box-shadow: 0 4px 0 #bf360c;
  font-size: 20px;
}

#submit-btn:active,
#start-btn:active,
#restart-btn:active {
  transform: translateY(3px);
}

#submit-btn:disabled {
  background: #bbb;
  box-shadow: 0 4px 0 #999;
  cursor: default;
}

#feedback {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  line-height: 1.25;
  text-align: center;
}

#feedback.correct {
  color: #2e7d32;
}

#feedback.wrong {
  color: #c62828;
}

#feedback.feedback-info {
  color: #555;
}

#numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.np-btn {
  height: 42px;
  border: 2px solid #ce93d8;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff, #f3e5f5);
  box-shadow: 0 2px 0 #ab47bc;
  color: #6a1b9a;
  font-family: inherit;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
}

.np-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.np-btn.del-btn {
  grid-column: span 2;
  border-color: #f06292;
  background: linear-gradient(135deg, #fff, #fce4ec);
  box-shadow: 0 2px 0 #e91e63;
  color: #ad1457;
  font-size: 16px;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(255, 248, 220, 0.96);
  text-align: center;
}

.overlay-icon {
  font-size: 64px;
}

#overlay h2 {
  margin: 0;
  color: #e64a19;
  font-size: 36px;
}

#overlay p {
  margin: 0;
  color: #555;
  font-size: 22px;
}

#overlay .stars {
  font-size: 48px;
}

#start-btn,
#restart-btn {
  height: 56px;
  padding: 0 36px;
  border-radius: 20px;
  background: linear-gradient(135deg, #66bb6a, #2e7d32);
  box-shadow: 0 5px 0 #1b5e20;
  font-size: 24px;
}

.star-burst {
  position: absolute;
  z-index: 200;
  font-size: 28px;
  pointer-events: none;
  animation: burst 0.8s ease-out forwards;
}

@keyframes burst {
  0% {
    transform: translate(0, 0) scale(0.5);
    opacity: 1;
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(1.5);
    opacity: 0;
  }
}

@media (max-width: 760px) {
  .game-header {
    padding: 6px 10px;
  }

  .score-info {
    padding: 3px 8px;
    font-size: 13px;
  }

  #main {
    flex-direction: column;
  }

  #left-panel {
    min-height: 245px;
    padding: 8px;
  }

  #dango-stage {
    min-height: 170px;
    gap: 8px;
  }

  .dango-ball {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .dango-stick {
    height: 38px;
  }

  #right-panel {
    width: 100%;
    min-height: 245px;
    gap: 8px;
    padding: 10px;
    border-top: 3px dashed #ffb347;
    border-left: none;
  }

  #question-box {
    padding: 8px 12px;
  }

  #question-box .q-formula {
    font-size: 34px;
  }

  #answer-input,
  #submit-btn {
    height: 48px;
  }

  #feedback {
    min-height: 24px;
    font-size: 16px;
  }

  .np-btn {
    height: 34px;
  }
}
