* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', sans-serif;
    user-select: none;
}

/* ========== スタート画面 ========== */
#startScreen {
    position: fixed; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #000;
    z-index: 100;
}
#startScreen h1 {
    font-size: clamp(2rem, 6vw, 4rem);
    color: #fff;
    text-shadow: 0 0 30px rgba(255,255,255,0.5);
    margin-bottom: 0.6rem;
    letter-spacing: 0.1em;
}
#startScreen p.sub {
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    color: #aaa;
    margin-bottom: 2rem;
}

/* 設定ボックス */
.settings-box {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 1.6rem 2.4rem;
    backdrop-filter: blur(8px);
    margin-bottom: 2rem;
    min-width: 340px;
}
.settings-box h2 {
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 1.2rem;
    text-align: center;
    letter-spacing: 0.1em;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-row label {
    font-size: 0.95rem;
    color: #ccc;
    white-space: nowrap;
    min-width: 4.5em;
}
.setting-row input[type="range"] {
    flex: 1;
    accent-color: #fff;
    cursor: pointer;
}
.setting-row .val {
    min-width: 6em;
    text-align: right;
    font-size: 0.95rem;
    color: #fff;
    font-weight: bold;
}

/* スタートボタン */
#startBtn {
    padding: 1rem 3.5rem;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    border: none; border-radius: 50px;
    background: linear-gradient(135deg, #ffffff33, #ffffff99);
    color: #fff; cursor: pointer;
    box-shadow: 0 0 30px rgba(255,255,255,0.3);
    backdrop-filter: blur(4px);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.1em;
}
#startBtn:hover {
    transform: scale(1.06);
    box-shadow: 0 0 40px rgba(255,255,255,0.5);
}
#startBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== ゲーム中UI ========== */
#gameUI {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 20; pointer-events: none;
}
#topBar {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0.7rem 2rem;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(6px);
}
#timerDisplay {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: bold; color: #fff;
    background: rgba(255,255,255,0.12);
    padding: 0.3rem 1.2rem; border-radius: 30px;
    min-width: 80px; text-align: center;
}
#timerDisplay.warning {
    color: #ff6666;
    animation: pulse 0.8s infinite;
}
@keyframes pulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}
#scoreDisplay {
    font-size: clamp(1rem, 3vw, 1.6rem);
    color: #fff;
    background: rgba(255,255,255,0.12);
    padding: 0.3rem 1.2rem; border-radius: 30px;
}
#scoreDisplay span {
    font-weight: bold;
    font-size: 1.2em;
    color: #ffdd88;
}

/* ========== Canvas ========== */
#gameCanvas {
    display: block;
    position: fixed; top: 0; left: 0;
    z-index: 5;
}

/* ========== 終了画面 ========== */
#endScreen {
    display: none;
    position: fixed; inset: 0;
    align-items: center; justify-content: center;
    background: rgba(0,0,0,0.85);
    z-index: 90;
}
.end-panel {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 28px;
    padding: 3rem 4rem;
    text-align: center;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    animation: popIn 0.5s cubic-bezier(.36,2,.6,1) forwards;
}
.end-panel h2 {
    font-size: clamp(2.5rem, 8vw, 5rem);
    color: #fff;
    text-shadow: 0 0 20px rgba(255,255,255,0.4);
    margin-bottom: 1rem;
}
#endScore {
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: #ddd; margin-bottom: 0.5rem;
}
#endScore span {
    font-size: 1.5em;
    font-weight: bold;
    color: #ffdd88;
}
#endMessage {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    color: #aaddff;
    margin-bottom: 2rem;
}
#retryBtn {
    padding: 0.8rem 2.5rem;
    font-size: 1.3rem;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50px;
    background: rgba(255,255,255,0.15);
    color: #fff; cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    font-weight: bold;
}
#retryBtn:hover {
    transform: scale(1.06);
    background: rgba(255,255,255,0.28);
}
@keyframes popIn {
    0%   { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.img-btns { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; }
.img-btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.95rem;
  border: 2.5px solid #aad0f0;
  border-radius: 30px;
  background: rgba(255,255,255,0.6);
  color: #3a6a9a;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: bold;
}
.img-btn:hover { background: rgba(180,220,255,0.6); }
.img-btn.active {
  background: linear-gradient(135deg, #aadeff, #66bbff);
  color: #fff;
  border-color: #66bbff;
  box-shadow: 0 3px 12px rgba(100,180,255,0.4);
}
#gifLayer {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}
#gifLayer img {
  position: absolute;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}