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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #060918;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Hiragino Maru Gothic Pro', 'Rounded Mplus 1c', 'Yu Gothic', sans-serif;
  overflow: hidden;
}

.container {
  width: 100%;
  max-width: 1196px;
  height: 540px;
  margin: 0 auto;
  background: #060918;
  border: 2px solid #1e3080;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.game-header {
  height: 50px;
  flex: 0 0 50px;
  padding: 0 20px;
  background: #080d24;
  display: flex;
  align-items: center;
}

.info {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #a8d8ea;
  font-size: 0.95rem;
  font-weight: bold;
  line-height: 1.2;
}

.game-main {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #060918;
  overflow: hidden;
}
.bg-stars { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: twinkle var(--dur,3s) ease-in-out infinite; opacity: var(--op,.4);
}
@keyframes twinkle {
  0%,100% { opacity: var(--op,.4); transform: scale(1); }
  50%      { opacity: .07; transform: scale(.4); }
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #0f1a4a 0%, #060918 80%);
}

#start-screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
}
.title-emoji { font-size: 3.8rem; animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}
#start-screen h1 {
  font-size: 2.5rem; color: #FFE66D;
  text-shadow: 0 0 30px #ffe66daa;
  letter-spacing: .1em; line-height: 1.2; text-align: center;
}
.subtitle { font-size: 1rem; color: #a8d8ea; text-align: center; line-height: 1.9; }

.start-bottom {
  display: flex; align-items: flex-start; gap: 32px;
  margin-top: 4px;
}
#start-btn {
  background: linear-gradient(135deg, #FFE66D, #f0a500);
  border: none; border-radius: 50px; padding: 16px 56px;
  font-size: 1.55rem; font-weight: bold; font-family: inherit; color: #060918;
  cursor: pointer;
  box-shadow: 0 0 30px #ffe66d88, 0 8px 24px #0004;
  animation: pulse-btn 2s ease-in-out infinite;
  transition: transform .15s; align-self: center;
}
@keyframes pulse-btn {
  0%,100% { box-shadow: 0 0 30px #ffe66d88, 0 8px 24px #0004; }
  50%      { box-shadow: 0 0 60px #ffe66dcc, 0 8px 24px #0004; }
}
#start-btn:hover { transform: scale(1.07); }
#start-btn:active { transform: scale(.97); }

#history-box {
  background: #0d1240cc;
  border: 1.5px solid #1e3080;
  border-radius: 16px;
  padding: 10px 18px;
  min-width: 200px;
  max-width: 240px;
}
#history-box .hist-title {
  font-size: .8rem; color: #ffe66d; font-weight: bold; margin-bottom: 6px;
  letter-spacing: .05em;
}
#history-list { list-style: none; }
#history-list li {
  font-size: .82rem; color: #a8d8ea;
  padding: 2px 0; border-bottom: 1px solid #1e2d6e22;
  display: flex; justify-content: space-between; gap: 8px;
}
#history-list li:last-child { border-bottom: none; }
#history-list li .rank { color: #ffe66daa; width: 18px; }
#history-list li .rec-time { color: #fff; font-weight: bold; }
.hist-empty { font-size: .8rem; color: #a8d8ea66; }

#game-screen {
  position: absolute; inset: 0; z-index: 10;
  display: none; flex-direction: column;
}
#game-screen.show { display: flex; }

#top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 4px; flex-shrink: 0; gap: 12px;
}

#round-indicator {
  display: flex; align-items: center; gap: 6px;
}
.round-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: bold;
  border: 2px solid #1e3080; background: #0d1240; color: #a8d8ea44;
  transition: all .3s;
}
.round-dot.done   { background: #ffe66d; color: #060918; border-color: #ffe66d; }
.round-dot.active { background: #1a3a8a; color: #ffe66d; border-color: #ffe66d;
                    box-shadow: 0 0 10px #ffe66d66; }

#timer-display {
  font-size: 1.5rem; font-weight: bold; color: #a8d8ea;
  letter-spacing: .05em; min-width: 80px; text-align: center;
  font-variant-numeric: tabular-nums;
}

#con-area { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: center; }
#con-name {
  font-size: 1.3rem; font-weight: bold; color: #FFE66D;
  text-shadow: 0 0 14px #ffe66d88; letter-spacing: .05em;
}
#star-count { font-size: .9rem; color: #ffe66d99; }

#canvas-wrap { flex: 1; position: relative; overflow: hidden; }
#star-canvas { display: block; width: 100%; height: 100%; }

#touch-guide {
  position: absolute; pointer-events: none; display: none; z-index: 5;
  transform: translate(-50%, 0%); font-size: 2.2rem;
  filter: drop-shadow(0 2px 8px #000a);
  animation: guide-bounce .9s ease-in-out infinite;
}
@keyframes guide-bounce {
  0%,100% { transform: translate(-50%,0) translateY(0); }
  50%      { transform: translate(-50%,0) translateY(8px); }
}

#complete-banner {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(0deg,#060918f8 0%,#0d1240ee 70%,transparent 100%);
  display: none; flex-direction: column; align-items: center;
  padding: 16px 36px 20px; gap: 8px; z-index: 30;
  transform: translateY(100%);
  transition: transform .45s cubic-bezier(.22,1,.36,1);
}
#complete-banner.show { display: flex; transform: translateY(0); }
.banner-inner {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; width: 100%; max-width: 860px;
}
.banner-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.banner-emoji { font-size: 2.4rem; animation: pop .5s cubic-bezier(.36,1.6,.58,1); }
@keyframes pop {
  0% { transform: scale(0) rotate(-20deg); }
  100% { transform: scale(1) rotate(0); }
}
.banner-texts { display: flex; flex-direction: column; gap: 2px; }
.comp-title {
  font-size: 1.55rem; font-weight: bold; color: #FFE66D;
  animation: glow 1.5s ease-in-out infinite alternate; white-space: nowrap;
}
@keyframes glow {
  from { text-shadow: 0 0 10px #ffe66d88; }
  to   { text-shadow: 0 0 30px #ffe66ddd, 0 0 50px #a8d8ea44; }
}
#next-btn {
  background: linear-gradient(135deg, #ffe66d, #f0a500);
  border: none; color: #060918; border-radius: 30px; padding: 12px 32px;
  font-size: 1.05rem; font-weight: bold; font-family: inherit; cursor: pointer;
  box-shadow: 0 0 20px #ffe66d66; transition: transform .15s; white-space: nowrap; flex-shrink: 0;
}
#next-btn:hover { transform: scale(1.06); }

#bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 20px 10px; flex-shrink: 0;
}
#guide-msg { font-size: 1rem; color: #a8d8ea; }
#bottom-btns { display: flex; gap: 10px; align-items: center; }
#retry-btn {
  background: #a8d8ea1f; border: 2px solid #a8d8eacc;
  color: #e7f8ff; border-radius: 20px; padding: 7px 22px;
  cursor: pointer; font-size: .98rem; font-weight: bold; font-family: inherit;
  box-shadow: 0 0 14px #a8d8ea33, 0 4px 12px #0005;
  transition: background .2s, border-color .2s, transform .15s;
}
#retry-btn:hover { background: #a8d8ea38; border-color: #e7f8ff; color: #ffffff; transform: translateY(-1px); }
#quit-btn {
  background: #ff6b6b1f; border: 2px solid #ff8a8acc;
  color: #ffdede; border-radius: 20px; padding: 7px 22px;
  cursor: pointer; font-size: .98rem; font-weight: bold; font-family: inherit;
  box-shadow: 0 0 14px #ff6b6b33, 0 4px 12px #0005;
  transition: background .2s, border-color .2s, transform .15s;
  white-space: nowrap;
}
#quit-btn:hover { background: #ff6b6b38; border-color: #ffdede; color: #ffffff; transform: translateY(-1px); }

#result-screen {
  position: absolute; inset: 0; z-index: 40;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #0f1a4a 0%, #060918 80%);
  gap: 0;
  overflow: hidden;
}
#result-screen.show { display: flex; }

#confetti-canvas {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
}

#result-screen .res-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; width: 100%; max-width: 720px; padding: 0 24px;
}
.res-title {
  font-size: 2.2rem; font-weight: bold; color: #FFE66D;
  text-shadow: 0 0 30px #ffe66daa; letter-spacing: .08em;
  animation: glow 1.5s ease-in-out infinite alternate;
}
.res-total-wrap {
  display: flex; align-items: baseline; gap: 10px;
}
.res-total-label { font-size: 1rem; color: #a8d8ea; }
.res-total-time {
  font-size: 2.8rem; font-weight: bold; color: #fff;
  text-shadow: 0 0 20px #a8d8eaaa;
  font-variant-numeric: tabular-nums;
}
.res-record {
  font-size: .95rem; color: #ffe66d; min-height: 1.4em;
  text-align: center;
}

.res-rounds {
  display: flex; gap: 10px; width: 100%; justify-content: center;
}
.res-round-card {
  flex: 1; max-width: 120px;
  background: #0d1240cc; border: 1.5px solid #1e3080;
  border-radius: 14px; padding: 10px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  animation: card-in .4s cubic-bezier(.36,1.4,.58,1) both;
}
.res-round-card:nth-child(1) { animation-delay: .05s; }
.res-round-card:nth-child(2) { animation-delay: .15s; }
.res-round-card:nth-child(3) { animation-delay: .25s; }
.res-round-card:nth-child(4) { animation-delay: .35s; }
.res-round-card:nth-child(5) { animation-delay: .45s; }
@keyframes card-in {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.rrc-num  { font-size: .72rem; color: #a8d8ea88; }
.rrc-name { font-size: .78rem; color: #a8d8ea; text-align: center; line-height: 1.3; }
.rrc-time { font-size: 1.15rem; font-weight: bold; color: #ffe66d; }

#replay-btn {
  background: linear-gradient(135deg, #ffe66d, #f0a500);
  border: none; color: #060918; border-radius: 30px; padding: 14px 52px;
  font-size: 1.2rem; font-weight: bold; font-family: inherit; cursor: pointer;
  box-shadow: 0 0 24px #ffe66d66; transition: transform .15s;
  margin-top: 4px;
}
#replay-btn:hover { transform: scale(1.07); }


