* {
  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;
  background: #ffffff;
  border: 2px solid #333;
  width: 100%;
  max-width: 1196px;
  height: 540px;
  display: flex;
  flex-direction: column;
}
.game-header {
  height: 50px;
  padding: 10px;
  background: #ffffff;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
}
.info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: bold;
  flex-wrap: wrap;
  width: 100%;
}
.game-main {
  position: relative;
  background: #ffffff;
  flex: 1;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.cloud {
  position: absolute;
  background: #ffffff;
  border-radius: 50px;
  opacity: 0.85;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
}
.c1 {
  width: 90px;
  height: 34px;
  top: 6%;
  left: 4%;
}
.c1::before {
  width: 46px;
  height: 46px;
  top: -24px;
  left: 10px;
}
.c1::after {
  width: 34px;
  height: 34px;
  top: -16px;
  left: 50px;
}
.c2 {
  width: 70px;
  height: 26px;
  top: 12%;
  right: 6%;
}
.c2::before {
  width: 36px;
  height: 36px;
  top: -18px;
  left: 8px;
}
.c2::after {
  width: 26px;
  height: 26px;
  top: -12px;
  left: 38px;
}
.sun {
  position: absolute;
  top: 5%;
  right: 10%;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffd24c 70%);
  box-shadow: 0 0 30px 10px rgba(255,210,76,0.6);
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}
.screen.active {
  display: flex;
}
h1.title {
  font-size: 50px;
  color: #ff6f61;
  margin: 0 0 10px 0;
  text-shadow: 3px 3px 0 #fff, 5px 5px 0 rgba(0,0,0,0.08);
  letter-spacing: 4px;
}
.marble-deco {
  display: inline-block;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffffff, #ffd166 35%, #ff7b54 75%, #b23c17 100%);
  vertical-align: middle;
  margin: 0 8px;
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.25);
}
.level-row {
  display: flex;
  gap: 22px;
  margin-bottom: 26px;
  flex-wrap: wrap;
  justify-content: center;
}
.level-btn {
  font-size: 28px;
  padding: 22px 30px;
  min-width: 150px;
  min-height: 74px;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  font-weight: bold;
  color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,0.2);
  transition: transform 0.08s;
}
.level-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 rgba(0,0,0,0.2);
}
.lv1 {
  background: #4fc0e8;
}
.lv2 {
  background: #ffb64f;
}
.lv3 {
  background: #ff6f7f;
}
.big-btn {
  font-size: 32px;
  padding: 22px 54px;
  min-height: 78px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  color: #fff;
  background: #52b859;
  box-shadow: 0 6px 0 #33843a;
  transition: transform 0.08s;
}
.big-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 #33843a;
}
.btn-row {
  display:flex;
  gap: 20px;
  justify-content: center;
  margin-top: 6px;
}
#gameScreen {
  justify-content: flex-start;
  padding-top: 10px;
}
.quit-btn {
  background: #ff6f61;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 24px;
  font-weight: bold;
  padding: 14px 26px;
  cursor: pointer;
  box-shadow: 0 5px 0 #c9483d;
  min-height: 56px;
}
.quit-btn:active {
  transform: translateY(5px);
  box-shadow: none;
}
.message {
  font-size: 30px;
  color: #3d3320;
  margin: 6px 0 4px 0;
  min-height: 44px;
  font-weight: bold;
  text-shadow: 1px 1px 0 #fff;
}
.cups-area {
  position: relative;
  width: 720px;
  max-width: 92%;
  height: 300px;
  margin: 6px auto 0 auto;
}
.ground-line {
  position: absolute;
  bottom: 46px;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}
.marble {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  bottom: 46px;
  background: radial-gradient(circle at 32% 28%, #ffffff, #ffd166 35%, #ff7b54 75%, #b23c17 100%);
  box-shadow: inset -6px -6px 10px rgba(0,0,0,0.3), 0 4px 6px rgba(0,0,0,0.3);
  opacity: 0;
  transition: left 0.4s ease, opacity 0.15s ease;
  z-index: 1;
}
.cup {
  position: absolute;
  width: 160px;
  height: 150px;
  bottom: 46px;
  cursor: pointer;
  transition: left 0.4s ease, transform 0.5s cubic-bezier(.34,1.6,.64,1);
  z-index: 2;
}
.cup .cup-shape {
  width: 100%;
  height: 100%;
  clip-path: polygon(24% 0%, 76% 0%, 100% 100%, 0% 100%);
  box-shadow: inset 8px 0 0 rgba(255,255,255,0.25), inset -10px 0 14px rgba(0,0,0,0.25);
  border-radius: 0 0 10px 10px;
}
.cup.lifted {
  transform: translateY(-140px);
}
.cup.fall-start {
  transform: translateY(-420px);
}
.cup.correct .cup-shape {
  box-shadow: 0 0 0 6px #ffe14d, inset 8px 0 0 rgba(255,255,255,0.25);
}
.score-text {
  font-size: 34px;
  color: #3d3320;
  font-weight: bold;
  margin-bottom: 20px;
}
@media (max-width: 700px) {
  h1.title {
    font-size: 34px;
  }
  .level-btn {
    font-size: 22px;
    padding: 16px 20px;
    min-width: 110px;
  }
  .big-btn {
    font-size: 24px;
    padding: 16px 34px;
  }
  .cups-area {
    height: 230px;
  }
  .cup {
    width: 110px;
    height: 100px;
  }
  .marble {
    width: 38px;
    height: 38px;
    bottom: 30px;
  }
  .message {
    font-size: 22px;
  }
}
.container {
  position:relative;
  overflow:hidden;
  background:linear-gradient(180deg,#cdeeff 0%,#cdeeff 62%,#8bd47a 62%,#6fc35f 100%);
}
.game-main {
  min-height:0;
  background:transparent;
}
[hidden] {
  display:none !important;
}
.game-header {
  position:relative;
  z-index:5;
  background:transparent;
  padding:4px 12px;
  justify-content:space-between;
  gap:8px;
}
.info {
  width:auto;
  flex-wrap:nowrap;
  font-size:18px;
  color:#4a3b2a;
}
.header-center {
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  text-align:center;
}
.header-center h1 {
  margin:0 0 3px;
  font-size:20px;
}
.header-actions {
  display:flex;
  align-items:center;
  gap:8px;
}
.game-header .quit-btn {
  font-size:16px;
  padding:6px 14px;
  min-height:34px;
}
button {
  font-family:inherit;
}
.sound-btn {
  background:#fff0ad;
  border:3px solid #f2b321;
  border-radius:50px;
  padding:9px 22px;
  font-size:18px;
  font-weight:700;
  color:#694100;
  box-shadow:0 3px 0 #d89500;
  cursor:pointer;
  letter-spacing:1px;
  transition:border-color .15s,color .15s;
  min-width:104px;
}
.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;
  right:12px;
  top:10px;
  z-index:6;
}
.cup {
  border:0;
  padding:0;
  background:transparent;
}
.cup:focus-visible {
  outline:4px solid white;
  outline-offset:5px;
}
.cup:disabled {
  cursor:default;
}
.overlay {
  position:absolute;
  inset:0;
  z-index:10;
  display:grid;
  place-items:center;
  background:#281e1447;
}
.overlay > div {
  padding:25px 45px;
  border-radius:30px;
  background:white;
  text-align:center;
  box-shadow:0 14px 25px #0004;
}
.overlay strong {
  display:block;
  font-size:39px;
  color:#2fb768;
}
.overlay.wrong strong {
  color:#d9534f;
}
.overlay p {
  font-size:20px;
  font-weight:800;
}
#resultScreen .title {
  font-size:40px;
}
@media(max-width:700px) {
  .header-center h1 {
    font-size:16px;
  }
  .info {
    font-size:14px;
  }
  .cups-area {
    height:300px;
    max-width:100%;
  }
  .cup {
    width:min(110px,30%);
  }
  .marble {
    bottom:46px;
  }
  .level-row {
    gap:12px;
  }
  .level-btn {
    min-width:0;
    padding:16px 14px;
    font-size:20px;
  }
  .btn-row {
    gap:12px;
    flex-wrap:wrap;
  }
  .score-text {
    font-size:25px;
  }
  h1.title {
    font-size:clamp(24px,5vw,34px);
    letter-spacing:1px;
  }
  .marble-deco {
    width:25px;
    height:25px;
    margin:0 4px;
  }
}
@media(max-width:440px) {
  .game-header {
    padding:4px;
    gap:3px;
  }
  .header-center h1 {
    font-size:13px;
  }
  .header-actions {
    gap:4px;
  }
  .game-header .quit-btn {
    padding:6px;
    font-size:12px;
  }
  .game-header .sound-btn {
    padding:7px 12px;
    font-size:16px;
    min-width:0;
  }
  .info {
    font-size:12px;
  }
  .screen {
    padding:12px;
  }
}
.cup .cup-shape {
  background:linear-gradient(#7fc9ff,#2f8fe0);
}
#startScreen {
  padding:76px 20px 18px;
}
#startScreen .level-row {
  margin-bottom:12px;
}
.tutorial {
  width:min(380px,100%);
  border-radius:24px;
  background:#ffffffb8;
  padding:6px 10px;
}
.tutorial p {
  margin:4px 0;
  font-size:17px;
  font-weight:bold;
  color:#3d3320;
}
.demo-stage {
  position:relative;
  width:270px;
  height:130px;
  margin:auto;
}
.demo-cup {
  position:absolute;
  bottom:24px;
  width:60px;
  height:56px;
  background:linear-gradient(#7fc9ff,#2f8fe0);
  clip-path:polygon(24% 0,76% 0,100% 100%,0 100%);
}
.first {
  left:15px;
  animation:demo-first 7s infinite;
}
.second {
  left:105px;
  animation:demo-second 7s infinite;
}
.third {
  left:195px;
  animation:demo-third 7s infinite;
}
.demo-ball {
  position:absolute;
  left:33px;
  bottom:24px;
  width:24px;
  height:24px;
  border-radius:50%;
  background:radial-gradient(circle at 30% 25%,#fff,#ffd166 35%,#ff7b54 80%);
  animation:demo-ball 7s infinite;
}
.demo-hand {
  position:absolute;
  left:112px;
  bottom:0;
  font-size:36px;
  line-height:1;
  animation:demo-hand 7s infinite;
}
@keyframes demo-first {
  0%,18% {
    transform:translateY(-48px);
  }
  28%,35% {
    transform:translate(0,0);
  }
  53%,78% {
    transform:translate(90px,0);
  }
  86%,100% {
    transform:translate(90px,-48px);
  }
}
@keyframes demo-second {
  0%,35% {
    transform:translateX(0);
  }
  53%,100% {
    transform:translateX(-90px);
  }
}
@keyframes demo-third {
  0%,18% {
    transform:translateY(-48px);
  }
  28%,100% {
    transform:translateY(0);
  }
}
@keyframes demo-ball {
  0%,28% {
    opacity:1;
    transform:translateX(0);
  }
  29%,78% {
    opacity:0;
    transform:translateX(90px);
  }
  86%,100% {
    opacity:1;
    transform:translateX(90px);
  }
}
@keyframes demo-hand {
  0%,57%,100% {
    opacity:0;
    transform:translateY(14px);
  }
  65%,73% {
    opacity:1;
    transform:translateY(0);
  }
  78%,90% {
    opacity:1;
    transform:translateY(-10px) scale(.9);
  }
}
#retryBtn {
  background:#9560d2;
  box-shadow:0 6px 0 #663ca0;
}
#retryBtn:active {
  box-shadow:none;
}
.confetti {
  position:absolute;
  inset:0;
  z-index:11;
  pointer-events:none;
  overflow:hidden;
}
.confetti i {
  position:absolute;
  top:-20px;
  width:10px;
  height:16px;
  animation:confetti-fall 1.7s ease-in forwards;
}
@keyframes confetti-fall {
  to {
    transform:translate(var(--drift),560px) rotate(650deg);
    opacity:0;
  }
}
@media(max-width:440px) {
  #startScreen .title {
    font-size:25px;
  }
  #startScreen .level-row {
    gap:9px;
  }
  #startScreen .level-btn {
    padding:14px 10px;
    font-size:18px;
  }
}
@media(prefers-reduced-motion:reduce) {
  .tutorial * {
    animation:none;
  }
  .first {
    transform:translateY(-48px);
  }
  .demo-hand {
    left:22px;
  }
  .confetti {
    display:none;
  }
}
#startScreen > .title {
  position:absolute;
  top:10px;
  left:140px;
  right:140px;
  margin:0;
  height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:clamp(26px,4vw,40px);
  letter-spacing:2px;
  white-space:nowrap;
}
#startScreen > .title .marble-deco {
  flex-shrink:0;
  width:32px;
  height:32px;
}
.tutorial {
  width:min(460px,100%);
}
.demo-stage {
  transform:scale(1.35);
  transform-origin:center bottom;
  margin-top:46px;
  margin-bottom:8px;
}
#gameScreen .cup {
  transition:left var(--shuffle-duration,.85s) ease, transform .5s cubic-bezier(.34,1.6,.64,1);
}
#gameScreen.easy-level .cup {
  transition:left var(--shuffle-duration) ease, transform 1.2s cubic-bezier(.34,1.6,.64,1);
}
#gameScreen.easy-level .cup.lifted {
  transition:left var(--shuffle-duration) ease, transform .5s cubic-bezier(.34,1.6,.64,1);
}
@media(max-width:700px) {
  #startScreen > .title {
    left:12px;
    right:132px;
    font-size:clamp(18px,4vw,28px);
    letter-spacing:0;
  }
  #startScreen > .title .marble-deco {
    width:20px;
    height:20px;
    margin:0 3px;
  }
  .demo-stage {
    transform:scale(1.15);
    margin-top:25px;
  }
}
@media(max-width:360px) {
  #startScreen > .title .marble-deco {
    display:none;
  }
}
#startScreen .level-row {
  margin-top:64px;
}
#startScreen .level-btn {
  min-width:190px;
  min-height:96px;
  padding:26px 36px;
  font-size:32px;
}
@media(max-width:700px) {
  #startScreen .level-row {
    width:100%;
    gap:10px;
    flex-wrap:nowrap;
  }
  #startScreen .level-btn {
    flex:1;
    min-width:0;
    min-height:88px;
    padding:22px 6px;
    font-size:clamp(18px,3.8vw,26px);
  }
}
.result-header {
  position:absolute;
  top:10px;
  left:12px;
  right:132px;
  min-height:44px;
  display:flex;
  align-items:center;
  text-align:left;
}
.best-score {
  color:#663ca0;
  font-size:24px;
  font-weight:bold;
  margin:0;
}
#resultScreen {
  padding-top:76px;
}
.new-record {
  color:#e85c36;
  font-size:28px;
  font-weight:bold;
  margin:0 0 24px;
}
@media(max-width:700px) {
  .best-score {
    font-size:19px;
  }
  .new-record {
    font-size:23px;
  }
}
#backBtn {
  background:#4fc0e8;
  box-shadow:0 6px 0 #2f8fb8;
}
.cup-shape {
  display:block;
}
