* {
  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;
}

.game-header {
  height: 50px;
  flex: 0 0 50px;
  align-items: center;
}

.info {
  display: flex;
  gap: 10px;
  font-weight: bold;
  flex-wrap: wrap;
}

.game-main {
  position: relative;

  flex: 1;

  overflow: hidden;

  display: grid;
  place-items: center;
}
.sun {
  position: absolute;
  right: 70px;
  top: 24px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #ffd23f;
  box-shadow: 0 0 0 14px #ffe58a88;
}
.cloud {
  position: absolute;
  width: 130px;
  height: 44px;
  background: #fff;
  border-radius: 44px;
}
.cloud:before,
.cloud:after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud:before {
  width: 60px;
  height: 60px;
  left: 20px;
  top: -28px;
}
.cloud:after {
  width: 48px;
  height: 48px;
  left: 68px;
  top: -20px;
}
.c1 {
  left: 6%;
  top: 50px;
  animation: drift 40s linear infinite;
}
.c2 {
  left: 48%;
  top: 100px;
  transform: scale(0.7);
  animation: drift 55s linear infinite -20s;
}
@keyframes drift {
  from {
    margin-left: -160px;
  }
  to {
    margin-left: 240px;
  }
}
.grass {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 150px;
  background: linear-gradient(#8fdc5a, #5fb83a);
}
.hill {
  position: absolute;
  bottom: 90px;
  width: 420px;
  height: 160px;
  border-radius: 50%;
  background: #a6e870;
}
.h1 {
  left: -80px;
}
.h2 {
  right: -100px;
  width: 520px;
  background: #94dd5e;
}
.scr {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
}
.scr.on {
  display: flex;
}
.btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: 28px;
  color: #fff;
  background: #ff7a2f;
  box-shadow: 0 8px 0 #c4501a;
  font-size: 40px;
  padding: 18px 60px;
  min-height: 84px;
}
.btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #c4501a;
}
.btn.blue {
  background: #2f9bff;
  box-shadow: 0 8px 0 #1b6fc4;
}
.btn.blue:active {
  box-shadow: 0 2px 0 #1b6fc4;
}
.title {
  font-size: 64px;
  line-height: 1.2;
  margin: 0 0 10px;
  color: #ff6a1a;
  text-shadow:
    0 5px 0 #fff,
    0 8px 0 #ffd9b8;
}
.sub {
  font-size: 30px;
  margin: 0 0 26px;
}
.parade {
  font-size: 70px;
  margin-bottom: 10px;
  letter-spacing: 6px;
}
.q {
  margin: 0 0 4px;
  color: #ff6a1a;
  text-shadow: 0 4px 0 #fff;
}
.choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  width: 92%;
}
.ch {
  font: inherit;
  border: 6px solid #fff;
  border-radius: 30px;
  background: #fff7d6;
  cursor: pointer;
  touch-action: manipulation;
  height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 0 #e0a93a;
  color: #4a2c10;
}
.ch:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #e0a93a;
  background: #ffe9a0;
}
.ch .e {
  font-size: 110px;
  line-height: 1;
}
.ch .n {
  font-size: 38px;
}
#race {
  justify-content: flex-start;
}
.lanes {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lane {
  position: relative;
  flex: 1;
  border-radius: 16px;
  background: repeating-linear-gradient(
    90deg,
    #f5e7d3 0 40px,
    #efdfc7 40px 80px
  );
  border: 4px solid #fff0;
}
.lane.me {
  border-color: #ff4f81;
  box-shadow: 0 0 0 3px #fff;
}
.tag {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  border-radius: 14px;
  padding: 2px 12px;
  font-size: 24px;
  z-index: 2;
}
.goal {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 36px;
  border-radius: 0 12px 12px 0;
  background: repeating-conic-gradient(#222 0 25%, #fff 0 50%) 0 0/18px 18px;
}
.run {
  position: absolute;
  top: 50%;
  left: 0;
  font-size: 62px;
  line-height: 1;
  transform: translateY(-52%);
  z-index: 3;
}
.run i {
  display: block;
  font-style: normal;
  transform: scaleX(-1);
}
.rank {
  position: absolute;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: none;
  background: #ffd23f;
  color: #4a2c10;
  border: 4px solid #fff;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 0 #0003;
}
.rank.on {
  display: flex;
  animation: pop 0.35s ease-out;
}
.rank.r1 {
  background: #ff4f81;
  color: #fff;
}
.order {
  display: flex;
  flex-direction: column;
  margin: 0 0 16px;
  width: 100%;
}
.order div {
  display: flex;
  align-items: center;
  gap: 22px;
  background: #fff7d6;
  border: 4px solid #ffd23f;
  border-radius: 18px;
  line-height: 1.3;
}
.order div b {
  color: #ff6a1a;
  min-width: 64px;
}
.order div:first-child {
  background: #ffe3ec;
  border-color: #ff4f81;
}
.star {
  position: absolute;
  right: -8px;
  top: -18px;
  font-size: 26px;
  font-style: normal;
}
.big {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 130px;
  color: #fff;
  text-shadow:
    0 8px 0 #ff6a1a,
    0 0 30px #ff6a1a;
  background: #0000002e;
  pointer-events: none;
}
.big.on {
  display: flex;
  animation: pop 0.5s ease-out;
}
@keyframes popc {
  from {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}
@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  display: none;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 8px solid #ffd23f;
  border-radius: 36px;
  box-shadow: 0 10px 0 #0003;
}
.panel.on {
  display: flex;
  animation: popc 0.4s ease-out;
}
.panel .r {
  margin: 0;
}
.panel .d {
  margin: 2px 0 10px;
}
.ok {
  color: #ff4f81;
}
.ng {
  color: #2f9bff;
}
.score {
  font-size: 60px;
  margin: 10px 0 24px;
  letter-spacing: 6px;
}
.final-msg {
  font-size: 46px;
  margin: 0;
}
@media (prefers-reduced-motion: reduce) {
  .cloud {
    animation: none;
  }
  .big.on,
  .panel.on,
  .rank.on {
    animation: none;
  }
}

.container {
  position: relative;
  overflow: hidden;
  background: linear-gradient(#7fd0f0 0%, #c9efff 55%, #fff3c4 100%);
  font-weight: 700;
  color: #4a2c10;
}
.game-main {
  min-height: 0;
  background: transparent;
}
.game-header {
  position: relative;
  z-index: 30;
  padding: 3px 12px;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
}
.game-header[hidden] {
  display: none;
}
.info {
  width: auto;
  justify-content: flex-start;
}
.info-box {
  background: #fff;
  border-radius: 18px;
  padding: 5px 12px;
  font-size: 18px;
}
.val {
  color: #ff6a1a;
  font-size: 22px;
}
.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.header-title {
  font-size: 22px;
  margin: 0;
  line-height: 1.1;
}
.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}
.header-actions .btn {
  font-size: 17px;
  min-height: 34px;
  padding: 5px 16px;
  border-radius: 18px;
  background: #9a6bd6;
  box-shadow: 0 3px 0 #6b43a3;
}
.sound-btn {
  font: inherit;
  border: 3px solid #f2b321;
  border-radius: 50px;
  padding: 5px 12px;
  font-size: 18px;
  color: #694100;
  background: #fff0ad;
  box-shadow: 0 3px 0 #d89500;
  cursor: pointer;
  min-width: 90px;
}
.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;
}
.start-sound {
  position: absolute;
  right: 12px;
  top: 8px;
  z-index: 30;
}
.progress-wrap {
  display: flex;
  gap: 7px;
}
.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
  transition: background 0.3s;
}
.progress-dot.done {
  background: #6ecb63;
}
.progress-dot.current {
  background: #f9a825;
  border: 2px solid #c77c00;
}
#race {
  padding: 20px 24px 16px;
}
.q {
  font-size: clamp(24px, 4.2vw, 50px);
}
.panel {
  max-width: 94%;
  min-width: 0;
  width: 650px;
  padding: 10px 24px 16px;
  border-width: 6px;
}
.panel .r {
  font-size: 40px;
}
.panel .d {
  font-size: 22px;
}
.panel .btn {
  font-size: 28px;
  min-height: 56px;
  padding: 10px 40px;
}
.order {
  gap: 4px;
  margin-bottom: 10px;
}
.order div {
  font-size: 26px;
  padding: 1px 18px;
}
.order div b {
  font-size: 28px;
}
.end-actions {
  display: flex;
  gap: 28px;
  margin-top: 26px;
}
.end-actions .btn {
  font-size: 30px;
  padding: 16px 30px;
}
.result-decor {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.result-decor span {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 9px;
  height: 15px;
  background: var(--color);
  opacity: 0;
  border-radius: 1px;
}
#end.on .result-decor span {
  animation: confetti-fall var(--duration) linear var(--delay) both;
}
.result-decor span:nth-child(3n) {
  width: 7px;
  height: 11px;
}
#end > *:not(.result-decor) {
  position: relative;
  z-index: 1;
}
@keyframes confetti-fall {
  0% {
    top: -20px;
    transform: translateX(0) rotate(0);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    top: 110%;
    transform: translateX(var(--drift)) rotate(var(--turn));
    opacity: 0;
  }
}
@media (max-width: 700px) {
  .game-header {
    padding: 3px 5px;
    gap: 3px;
  }
  .header-title {
    font-size: 16px;
  }
  .info-box {
    padding: 5px;
    font-size: 12px;
  }
  .val {
    font-size: 18px;
  }
  .header-actions {
    gap: 4px;
  }
  .header-actions .btn {
    padding: 5px 8px;
    font-size: 14px;
  }
  .sound-btn {
    padding: 5px 7px;
    font-size: 14px;
    min-width: 65px;
  }
  .title {
    font-size: 42px;
  }
  .parade {
    font-size: 48px;
  }
  .sub {
    font-size: 22px;
  }
  .choices {
    gap: 10px;
    width: 98%;
    grid-template-columns: repeat(2, 1fr);
  }
  .ch {
    height: 150px;
    gap: 3px;
    border-radius: 22px;
  }
  .ch .e {
    font-size: 75px;
  }
  .ch .n {
    font-size: 26px;
  }
  .big {
    font-size: 70px;
  }
  .panel .d {
    font-size: 17px;
  }
  .panel .r {
    font-size: 32px;
  }
  .order div {
    font-size: 22px;
    gap: 12px;
  }
  .final-msg {
    font-size: 28px;
  }
  .score {
    font-size: 42px;
  }
  .end-actions {
    gap: 14px;
  }
  .end-actions .btn {
    font-size: 22px;
    padding: 14px 18px;
  }
  .tag {
    font-size: 16px;
    padding: 2px 5px;
  }
  .run {
    font-size: 48px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #end.on .result-decor span {
    animation: none;
    display: none;
  }
}
.animal-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.parade {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
}
.parade .animal-image {
  width: 90px;
  height: 90px;
  min-width: 0;
}
.ch .e {
  display: block;
  width: 100%;
  height: 140px;
}
.run i:not(.star) {
  width: 80px;
  height: 80px;
}
.order .animal-image {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
@media (max-width: 700px) {
  .parade .animal-image {
    width: 54px;
    height: 64px;
  }
  .ch .e {
    height: 90px;
  }
  .run i:not(.star) {
    width: 62px;
    height: 62px;
  }
  .order .animal-image {
    width: 34px;
    height: 34px;
  }
}
