:root {
  --tool-w: 42px;
  --ink: #5c3142;
  --muted: #8d5b6c;
  --accent: #ee5c86;
}

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

html, body {
  margin: 0;
  height: 100%;
}

body {
  color: var(--ink);
  font-family: YouYuan, "幼圆", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 10% 12%, #ffd0e2 0 90px, transparent 150px),
    radial-gradient(circle at 92% 8%, #ffe9b8 0 100px, transparent 170px),
    radial-gradient(circle at 84% 92%, #ffd8c6 0 120px, transparent 190px),
    #fff3ea;
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 0;
}

.app.hidden,
.menu.hidden { display: none; }

.menu {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 20px;
  text-align: center;
}

.menu h1 {
  margin: 0;
  font-size: 46px;
  letter-spacing: 0.08em;
  color: #e24b7a;
}

.menu p {
  margin: 0 0 8px;
  max-width: 280px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.menu button {
  appearance: none;
  min-width: 200px;
  border: 0;
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 22px;
  border-radius: 999px;
  padding: 12px 28px;
  cursor: pointer;
}

.menu button.second {
  background: white;
  color: #e24b7a;
  box-shadow: 0 8px 20px rgba(180, 90, 110, 0.12);
}

.menu button:hover { background: #e24676; }
.menu button.second:hover { background: #fff; }

.board-list {
  width: min(340px, 100%);
  max-height: 46dvh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.dialog .board-list {
  width: 100%;
  max-height: 220px;
  margin-top: 12px;
}

.dialog .board-list li {
  background: #fff0f4;
}

.board-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 10px 12px;
}

.board-list .rank {
  width: 28px;
  flex: none;
  font-weight: 700;
  color: #e24b7a;
  text-align: center;
}

.board-list .who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-list .pts {
  flex: none;
  font-weight: 700;
  color: #d64574;
}

.board-list li.mine {
  outline: 3px solid #ffb03a;
}

.empty-board {
  margin: 0;
  color: var(--muted);
}

.stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  container-type: size;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.play {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

.frame {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 46px rgba(176, 72, 104, 0.18);
}

.tools {
  position: absolute;
  z-index: 2;
  right: 2px;
  top: 54%;
  width: var(--tool-w);
  display: flex;
  flex-direction: column;
  transform: translateY(-50%);
  gap: 10px;
}

.tool {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 6px 4px 7px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(180, 90, 110, 0.12);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.tool em {
  display: block;
  font-style: normal;
  color: var(--muted);
}

.tool .badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff4d5a;
  color: white;
  font-size: 12px;
  line-height: 18px;
  font-weight: 700;
}

.tool-face {
  position: relative;
  width: 32px;
  height: 32px;
  margin: 0 auto 2px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -6px 10px rgba(80, 20, 40, 0.12);
}

.rainbow-face {
  background: conic-gradient(#ff5b7a, #ffb03a, #ffe14a, #7ddea0, #5eb6ff, #b07cff, #ff5b7a);
}

.bomb-face {
  background: radial-gradient(circle at 35% 32%, #e4c6ff, #8d45d6 58%, #56248d);
}

.bomb-face::after {
  content: "";
  position: absolute;
  top: -4px;
  right: 7px;
  width: 7px;
  height: 14px;
  border-radius: 4px;
  background: #f2c14a;
  transform: rotate(28deg);
}

.clear-face {
  background: radial-gradient(circle at 35% 32%, #ffe0f0, #ff6fa8 62%, #e23b78);
  color: white;
  font-size: 22px;
}

.clear-face::before {
  content: "✦";
}

.tool.active {
  outline: 3px solid #e24b7a;
  outline-offset: 2px;
}

.tool.empty {
  opacity: 0.55;
}

.code-overlay {
  z-index: 4;
}

.dialog input {
  width: 100%;
  margin-top: 12px;
  border: 2px solid #f3b3c6;
  border-radius: 12px;
  padding: 8px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  text-align: center;
}

.code-error {
  margin: 8px 0 0;
  color: #e24b7a;
  font-size: 14px;
  font-weight: 700;
}

.code-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.dialog button.ghost {
  background: transparent;
  color: var(--muted);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(92, 42, 58, 0.28);
  backdrop-filter: blur(4px);
}

.overlay.hidden { display: none; }

.dialog {
  width: min(280px, 84%);
  padding: 22px 22px 18px;
  text-align: center;
  background: #fffaf8;
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(80, 20, 40, 0.2);
}

.dialog h2 {
  margin: 0;
  font-size: 28px;
  color: #e24b7a;
}

.final {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.final strong {
  color: #d64574;
  font-size: 28px;
}

.record {
  margin: 6px 0 0;
  color: #e24b7a;
  font-size: 16px;
  font-weight: 700;
}

.dialog button {
  appearance: none;
  margin-top: 14px;
  border: 0;
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 18px;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
}

.dialog button:hover { background: #e24676; }

.tool:focus-visible,
.dialog button:focus-visible {
  outline: 3px solid #ffd0e0;
  outline-offset: 2px;
}

.dialog button:active { transform: translateY(1px); }

