:root {
  --panel-bg: rgba(24, 42, 68, 0.72);
  --cream-white: #f4f9ff;
  --sky-cyan: #72ddf7;
  --magic-blue: #3a86ff;
  --gold-accent: #ffe194;
  --danger-red: #f26a8d;
}
* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  margin: 0;
  padding: 0;
}
body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #1b3252;
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Fredoka', sans-serif;
  font-weight: 500;
  color: var(--cream-white);
  -webkit-font-smoothing: antialiased;
}
#webglContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 20px;
}
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  gap: 12px;
}
.left-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}
.glass-pill {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(190, 232, 255, 0.55);
  border-radius: 20px;
  padding: 6px 18px;
  box-shadow: 0 8px 24px rgba(10, 22, 42, 0.35), 0 0 16px rgba(114, 221, 247, 0.15);
  text-align: center;
  min-width: 118px;
}
.pill-label {
  font-size: 11px;
  font-weight: 500;
  color: #a8e2ff;
  letter-spacing: 1px;
}
.pill-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--cream-white);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.life-cluster {
  display: flex;
  gap: 5px;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(190, 232, 255, 0.55);
  border-radius: 20px;
  padding: 8px 14px;
  box-shadow: 0 8px 24px rgba(10, 22, 42, 0.35);
}
.heart-unit {
  display: inline-flex;
  width: 18px;
  height: 18px;
}
.heart-svg {
  width: 100%;
  height: 100%;
  fill: #ff7aa2;
  filter: drop-shadow(0 0 6px rgba(255, 122, 162, 0.65));
}
.heart-unit.lost .heart-svg {
  fill: rgba(255, 255, 255, 0.2);
  filter: none;
}
#lapBanner {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(168, 226, 255, 0.65);
  border-radius: 99px;
  padding: 8px 28px;
  box-shadow: 0 8px 24px rgba(10, 22, 42, 0.35), 0 0 18px rgba(114, 221, 247, 0.2);
  text-align: center;
}
#lapTitle {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.4px;
}
.speed-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(190, 232, 255, 0.55);
  border-radius: 22px;
  padding: 6px 16px;
  box-shadow: 0 8px 24px rgba(10, 22, 42, 0.35);
}
.speed-bar-track {
  width: 10px;
  height: 38px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
#speedBarFill {
  width: 100%;
  height: 45%;
  background: linear-gradient(180deg, #8ef6ff 0%, #4ea8de 100%);
  border-radius: 99px;
  transition: height 0.15s ease-out;
}
#airBanner {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: linear-gradient(90deg, rgba(86, 207, 225, 0.9), rgba(78, 168, 222, 0.9));
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  padding: 5px 22px;
  border-radius: 99px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 6px 22px rgba(86, 207, 225, 0.45);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#airBanner.show {
  opacity: 1;
  transform: translateX(-50%) scale(1.05);
}
#hitBanner {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: linear-gradient(90deg, rgba(242, 106, 141, 0.92), rgba(224, 122, 159, 0.92));
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  padding: 6px 26px;
  border-radius: 99px;
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 6px 22px rgba(242, 106, 141, 0.5);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}
#hitBanner.show {
  opacity: 1;
  transform: translateX(-50%) scale(1.08);
}
.hud-bottom {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
#voiceBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid rgba(190, 232, 255, 0.6);
  border-radius: 99px;
  padding: 6px 20px;
  box-shadow: 0 8px 24px rgba(10, 22, 42, 0.4);
  cursor: pointer;
}
.mic-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mic-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #56cfe1;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 12px rgba(86, 207, 225, 0.7);
  animation: pulseMic 0.9s infinite alternate;
}
.mic-badge.warn {
  background: var(--danger-red);
  box-shadow: none;
  animation: none;
}
.mic-icon-svg {
  width: 14px;
  height: 14px;
  fill: var(--cream-white);
}
@keyframes pulseMic {
  0% { transform: scale(0.94); }
  100% { transform: scale(1.1); }
}
#heardText {
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
}
#quickTeachBtn {
  display: none;
  background: #72efdd;
  color: #142842;
  border: 2px solid #fff;
  border-radius: 99px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.gate-counter {
  background: rgba(255, 255, 255, 0.14);
  border: 1.5px solid rgba(168, 226, 255, 0.65);
  padding: 3px 14px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}
#keypad {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
  background: rgba(20, 36, 60, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 7px;
  border-radius: 18px;
  border: 1.5px solid rgba(190, 232, 255, 0.32);
}
.key-btn {
  background: linear-gradient(180deg, rgba(248, 252, 255, 0.95) 0%, rgba(218, 236, 252, 0.95) 100%);
  border: none;
  color: #1b3252;
  font-family: inherit;
  font-size: 19px;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(90, 125, 160, 0.65);
}
.key-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(90, 125, 160, 0.65);
  background: #b8e4ff;
}
.key-btn.clear-btn {
  background: linear-gradient(180deg, #f27a96 0%, #c94a6a 100%);
  color: var(--cream-white);
  box-shadow: 0 3px 0 rgba(120, 35, 58, 0.7);
  font-size: 12px;
}

/* オーバーレイ画面（ブルーグレー＆ソフトネオンブラー調） */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  background: linear-gradient(180deg, rgba(24, 43, 73, 0.88) 0%, rgba(39, 68, 108, 0.88) 55%, rgba(62, 104, 152, 0.9) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  text-align: center;
}
.title-logo {
  font-size: clamp(34px, 5.5vw, 58px);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 2px;
  text-shadow: 0 3px 18px rgba(130, 220, 255, 0.55), 0 8px 28px rgba(12, 24, 48, 0.45);
  margin-bottom: 20px;
}
.setup-panel {
  background: rgba(24, 42, 70, 0.68);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 2px solid rgba(190, 228, 255, 0.48);
  border-radius: 26px;
  padding: 24px 28px;
  max-width: 720px;
  width: 100%;
  margin-bottom: 22px;
  box-shadow: 0 14px 36px rgba(10, 20, 42, 0.38), inset 0 0 24px rgba(140, 215, 255, 0.08);
}
.name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.name-row label {
  font-size: 16px;
  font-weight: 600;
  color: #e6f4ff;
}
#playerNameInput {
  user-select: text;
  -webkit-user-select: text;
  background: rgba(255, 255, 255, 0.94);
  color: #1b3252;
  border: 2px solid rgba(155, 225, 255, 0.85);
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  width: 240px;
  text-align: center;
  outline: none;
  box-shadow: 0 0 14px rgba(130, 215, 255, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#playerNameInput.input-error {
  border-color: #ff4d6d;
  box-shadow: 0 0 22px rgba(255, 77, 109, 0.85);
  animation: nameErrorShake 0.36s ease;
}
@keyframes nameErrorShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.diff-selector, .cc-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.cc-selector {
  margin-bottom: 0;
}
.diff-btn, .cc-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(190, 228, 255, 0.32);
  border-radius: 18px;
  padding: 16px 10px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(10, 22, 44, 0.25);
  transition: all 0.16s ease;
  color: #e6f4ff;
}
.diff-btn.easy-btn.selected {
  background: linear-gradient(180deg, rgba(244, 168, 208, 0.88) 0%, rgba(152, 182, 238, 0.88) 100%);
  border: 2px solid #ffffff;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(235, 165, 215, 0.45), 0 0 16px rgba(255, 210, 240, 0.4);
}
.diff-btn.normal-btn.selected {
  background: linear-gradient(180deg, rgba(244, 182, 120, 0.88) 0%, rgba(206, 128, 108, 0.88) 100%);
  border: 2px solid #ffffff;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(235, 165, 115, 0.42);
}
.diff-btn.hard-btn.selected {
  background: linear-gradient(180deg, rgba(76, 188, 218, 0.88) 0%, rgba(62, 92, 148, 0.9) 100%);
  border: 2px solid #9beeff;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(86, 210, 245, 0.48), 0 0 18px rgba(215, 130, 235, 0.32);
}
.cc-btn.selected {
  background: linear-gradient(180deg, rgba(130, 220, 255, 0.9) 0%, rgba(78, 162, 222, 0.9) 100%);
  border: 2px solid #ffffff;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(100, 195, 245, 0.45);
}
.cc-title {
  font-size: 21px;
  font-weight: 600;
  color: inherit;
}
.start-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.start-btn {
  background: linear-gradient(180deg, rgba(116, 222, 255, 0.95) 0%, rgba(64, 158, 224, 0.95) 100%);
  border: 2px solid rgba(255, 255, 255, 0.88);
  color: #ffffff;
  font-family: inherit;
  font-size: 21px;
  font-weight: 600;
  padding: 13px 48px;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(80, 190, 250, 0.48), 0 0 18px rgba(140, 225, 255, 0.35);
  transition: all 0.15s ease;
}
.start-btn:active {
  transform: translateY(2px);
}
.start-btn.locked {
  opacity: 0.45;
  filter: grayscale(0.35);
}
.sub-action-btn {
  background: rgba(26, 46, 78, 0.75);
  border: 1.5px solid rgba(190, 228, 255, 0.65);
  color: #f4f9ff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 99px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(10, 22, 44, 0.35);
}
.sub-action-btn:hover {
  background: rgba(140, 210, 255, 0.22);
}

/* クリア＆ランキング画面 */
#clearScreen {
  background: linear-gradient(180deg, rgba(24, 48, 86, 0.88) 0%, rgba(44, 84, 136, 0.9) 100%);
}
.clear-banner-title {
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 3px 20px rgba(145, 230, 255, 0.75);
  margin-bottom: 6px;
}
.ranking-box {
  background: rgba(20, 36, 62, 0.82);
  border: 2px solid rgba(168, 226, 255, 0.55);
  border-radius: 20px;
  padding: 12px 18px;
  width: 100%;
  max-width: 780px;
  margin: 10px 0 16px;
  max-height: 260px;
  overflow-y: auto;
}
.rank-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}
.rank-tab-btn {
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(190, 228, 255, 0.4);
  color: #fff;
  padding: 5px 18px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.rank-tab-btn.active {
  background: rgba(130, 220, 255, 0.9);
  color: #142844;
  border-color: #ffffff;
}
.rank-cc-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}
.rank-cc-btn {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(190, 228, 255, 0.3);
  color: #cfe8ff;
  padding: 3px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.rank-cc-btn.active {
  background: rgba(255, 209, 102, 0.92);
  color: #142844;
  border-color: #ffffff;
}
.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}
.ranking-table th {
  color: #a8e2ff;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 500;
}
.ranking-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 500;
}
.mode-tag {
  background: rgba(155, 231, 255, 0.18);
  border: 1px solid rgba(168, 226, 255, 0.6);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

/* GAME OVER 画面 */
#gameOverScreen {
  background: radial-gradient(circle at 50% 30%, rgba(68, 38, 68, 0.92) 0%, rgba(20, 30, 50, 0.96) 100%);
}
.gameover-logo {
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 900;
  color: #f48fb1;
  text-shadow: 0 3px 20px rgba(244, 143, 177, 0.5);
  letter-spacing: 3px;
  margin-bottom: 18px;
}

/* 音声辞書モーダル */
#dictModal {
  display: none;
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 25;
  background: rgba(18, 32, 56, 0.85);
  backdrop-filter: blur(12px);
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.dict-card {
  background: rgba(26, 46, 78, 0.95);
  border: 2px solid rgba(168, 226, 255, 0.65);
  border-radius: 22px;
  padding: 20px 24px;
  max-width: 580px;
  width: 100%;
  text-align: left;
}
.dict-input-row {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.dict-input-row input {
  user-select: text;
  -webkit-user-select: text;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid #9be7ff;
  font-size: 15px;
  font-weight: 800;
}
.dict-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid #9be7ff;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 13px;
  margin: 4px;
}
.dict-del-btn {
  background: #f26a8d;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
}
#fileWarning {
  display: none;
  background: rgba(20, 38, 68, 0.9);
  border: 1.5px solid #9be7ff;
  color: #ffffff;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 10px;
  margin-top: 10px;
}
