:root {
  --blue: #1b7fff;
  --green: #18b982;
  --ink: #102337;
  --glass: rgba(255, 255, 255, 0.82);
  --line: rgba(255, 255, 255, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body,
#gameShell,
#gameCanvas {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: #8ed2ff;
}

button,
input,
select,
a {
  font: inherit;
}

button,
a {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(15, 50, 72, 0.14);
  padding: 0.72rem 1rem;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

button {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
  border: 0;
  font-weight: 800;
}

button.music-on {
  background: linear-gradient(135deg, #13a6ff, #21c78f);
}

#gameCanvas {
  display: block;
}

.start-panel {
  position: fixed;
  inset: 50%;
  z-index: 5;
  width: min(720px, calc(100vw - 2rem));
  height: fit-content;
  transform: translate(-50%, -50%);
  padding: clamp(1.2rem, 3vw, 2rem);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(232, 255, 248, 0.88)),
    radial-gradient(circle at top left, rgba(255, 235, 150, 0.45), transparent 18rem);
  box-shadow: 0 28px 80px rgba(9, 46, 67, 0.24);
  backdrop-filter: blur(18px);
}

.kicker {
  margin: 0 0 0.25rem;
  color: var(--green);
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 5.6rem);
  line-height: 1;
  color: var(--blue);
}

.lead {
  font-size: 1.1rem;
  line-height: 1.75;
  color: #526477;
}

.join-grid,
.creator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.8rem;
}

.creator-grid {
  grid-template-columns: 1fr 1fr 1fr;
  align-items: stretch;
  margin-top: 0.8rem;
}

fieldset {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  border: 1px solid rgba(24, 92, 112, 0.18);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.66);
}

legend {
  padding: 0 0.25rem;
  color: #526477;
  font-size: 0.9rem;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

fieldset input {
  width: auto;
}

.avatar-preview-note,
.skill-box {
  border: 1px solid rgba(24, 92, 112, 0.14);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(232, 250, 246, 0.72);
  color: #526477;
  line-height: 1.55;
}

label {
  display: grid;
  gap: 0.35rem;
  color: #526477;
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(24, 92, 112, 0.18);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
}

input[type="color"] {
  min-width: 74px;
  min-height: 45px;
  padding: 0.25rem;
}

.start-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1rem;
}

.note {
  margin-bottom: 0;
  color: #66788a;
}

.hud,
.squad-panel,
.help,
.controls {
  position: fixed;
  z-index: 3;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 42px rgba(9, 46, 67, 0.16);
}

.hud {
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.hud div {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.hud button {
  min-height: 34px;
  padding: 0.35rem 0.65rem;
}

.squad-panel {
  right: 1rem;
  top: 5rem;
  width: min(310px, calc(100vw - 2rem));
  max-height: calc(100vh - 7rem);
  overflow: auto;
  padding: 1rem;
  border-radius: 8px;
}

.squad-panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
}

#wordChallenge {
  width: 100%;
  margin-bottom: 0.7rem;
}

.skill-box {
  margin-bottom: 0.8rem;
  background: rgba(255, 255, 255, 0.72);
}

.skill-box p {
  margin: 0.25rem 0 0;
}

#playerList {
  display: grid;
  gap: 0.45rem;
}

.player-pill {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.player-pill i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.chat-messages {
  display: grid;
  gap: 0.45rem;
  max-height: 180px;
  overflow: auto;
  margin-top: 0.8rem;
}

.chat-messages p {
  margin: 0;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(232, 250, 246, 0.78);
  line-height: 1.45;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.chat-row button {
  padding-inline: 0.85rem;
}

.help {
  left: 1rem;
  bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: #405466;
}

.controls {
  left: 1rem;
  bottom: 4.3rem;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.65rem;
  border-radius: 8px;
}

.controls div {
  display: flex;
  gap: 0.35rem;
}

.controls button {
  width: 52px;
  height: 48px;
  padding: 0;
}

dialog {
  width: min(520px, calc(100vw - 2rem));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(9, 46, 67, 0.28);
}

dialog.dialog-fallback[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 80;
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(16, 35, 55, 0.38);
  backdrop-filter: blur(5px);
}

.quiz-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  background: linear-gradient(135deg, #ffffff, #ebfff8);
}

.quiz-card h2,
.quiz-card p {
  margin: 0;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.quiz-options button {
  min-height: 54px;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(24, 92, 112, 0.16);
}

.quiz-result {
  min-height: 1.5rem;
  color: var(--green);
  font-weight: 800;
}

@media (max-width: 760px) {
  .join-grid,
  .creator-grid,
  .quiz-options {
    grid-template-columns: 1fr;
  }

  .hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .squad-panel {
    top: auto;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: auto;
    max-height: 34vh;
  }

  .help {
    display: none;
  }
}
