/* MIKU PLAZA —— 初音未来卡通配色 */
:root {
  --teal: #39c5bb;
  --teal-dark: #2aa79c;
  --pink: #ff77a9;
  --purple: #8e7cc3;
  --ink: #2b3a42;
  --cream: #fff8f0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #a8e6de 0%, #c5f0ea 40%, #ffd9e8 100%);
  color: var(--ink);
}

#game {
  position: fixed;
  inset: 0;
  display: block;
}

.hidden {
  display: none !important;
}

/* ===== 覆盖层 ===== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(57, 197, 187, 0.92), rgba(255, 119, 169, 0.9));
  z-index: 30;
  padding: 16px;
  overflow-y: auto;
}

.join-card {
  background: var(--cream);
  border-radius: 28px;
  padding: 28px 32px 24px;
  width: min(560px, 94vw);
  text-align: center;
  box-shadow: 0 20px 60px rgba(30, 90, 85, 0.35), inset 0 0 0 4px #fff;
  border: 3px solid var(--teal);
}

.join-card.small {
  width: min(380px, 90vw);
}

.logo {
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--teal) 20%, var(--pink) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.small-logo {
  font-size: 24px;
}

.logo-note {
  color: var(--pink);
  -webkit-text-fill-color: var(--pink);
  font-size: 0.8em;
  animation: bob 1.6s ease-in-out infinite;
}
.logo-note.flip {
  animation-delay: 0.8s;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-8px) rotate(8deg); }
}

.subtitle {
  margin-top: 2px;
  font-size: 15px;
  color: var(--teal-dark);
  font-weight: 700;
  letter-spacing: 6px;
}

.tagline {
  margin: 10px 0 16px;
  font-size: 14px;
  color: #5b7079;
}

#nameInput {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid #bfe8e2;
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
  text-align: center;
  transition: border-color 0.15s;
}

#nameInput:focus {
  border-color: var(--teal);
}

/* ===== 角色选择 ===== */
.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 20px;
}

.char-card {
  border: 3px solid #d9efeb;
  border-radius: 16px;
  background: #fff;
  padding: 8px 4px 6px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  user-select: none;
}

.char-card:hover {
  transform: translateY(-3px);
}

.char-card.selected {
  border-color: var(--pink);
  box-shadow: 0 6px 18px rgba(255, 119, 169, 0.35);
  transform: translateY(-3px) scale(1.03);
}

.char-card canvas {
  width: 56px;
  height: 70px;
  image-rendering: auto;
}

.char-card .cname {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.char-card .cdesc {
  font-size: 10px;
  color: #7d929b;
  line-height: 1.25;
  min-height: 24px;
}

/* ===== 按钮 ===== */
button {
  font-family: inherit;
  cursor: pointer;
}

#joinBtn,
#rejoinBtn {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  border: none;
  border-radius: 16px;
  background: linear-gradient(90deg, var(--teal), var(--teal-dark));
  box-shadow: 0 6px 0 #1f7f77, 0 10px 20px rgba(42, 167, 156, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}

#joinBtn:hover,
#rejoinBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #1f7f77, 0 14px 24px rgba(42, 167, 156, 0.45);
}

#joinBtn:active,
#rejoinBtn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #1f7f77;
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: #8fa3ab;
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  z-index: 20;
  pointer-events: none;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-logo {
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid var(--teal);
  color: var(--teal-dark);
  font-weight: 900;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  letter-spacing: 1px;
}

.pill {
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #ffd3e4;
  color: #d1517f;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.pill.btn {
  border: 2px solid #bfe8e2;
  color: var(--teal-dark);
  background: rgba(255, 255, 255, 0.85);
}

.pill.btn:hover {
  background: #fff;
}

#helpPanel {
  position: fixed;
  top: 56px;
  right: 14px;
  z-index: 21;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--teal);
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 13px;
  max-width: 260px;
  box-shadow: 0 10px 30px rgba(30, 90, 85, 0.25);
}

#helpPanel ul {
  margin: 8px 0 8px 18px;
  line-height: 1.7;
}

#helpPanel p {
  color: #7d929b;
  font-size: 12px;
}

/* ===== 聊天输入 ===== */
#chatInput {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(480px, 86vw);
  padding: 12px 18px;
  font-size: 15px;
  border: 3px solid var(--teal);
  border-radius: 999px;
  outline: none;
  background: rgba(255, 255, 255, 0.96);
  z-index: 25;
  box-shadow: 0 8px 24px rgba(30, 90, 85, 0.3);
}

/* ===== 移动端控件 ===== */
#touchUI {
  position: fixed;
  inset: 0;
  z-index: 22;
  pointer-events: none;
}

#stick {
  position: absolute;
  left: 28px;
  bottom: 32px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 3px solid rgba(57, 197, 187, 0.6);
  pointer-events: auto;
  touch-action: none;
}

#stickKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(57, 197, 187, 0.85);
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#emoteBar {
  position: absolute;
  right: 16px;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

#emoteBar button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  background: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  font-weight: 700;
  color: var(--teal-dark);
}

#emoteBar button:active {
  transform: scale(0.9);
  background: var(--teal);
  color: #fff;
}

@media (max-width: 480px) {
  .char-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .join-card {
    padding: 20px 16px 18px;
  }
  .hud-logo {
    display: none;
  }
}
