*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg1: #fff5f8;
  --bg2: #f3e8ff;
  --bg3: #ffe4ec;
  --rose-deep: #b84d72;
  --rose-mid: #e879a6;
  --rose-soft: #ffc4d6;
  --lilac: #c9b8e8;
  --lilac-soft: #ede6ff;
  --cream: #fffafc;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 182, 203, 0.55);
  --shadow-romantic: 0 12px 40px rgba(184, 77, 114, 0.18);
  --shadow-soft: 0 6px 24px rgba(180, 120, 150, 0.12);
  /* legacy names used in file */
  --game-border: #e8a4bf;
  --accent: #e879a6;
  --accent-dark: #b84d72;
  --text: #5c3d4d;
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(145deg, var(--bg1) 0%, var(--bg3) 35%, var(--lilac-soft) 70%, var(--bg2) 100%);
  background-size: 220% 220%;
  animation: bg-shift 18s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 15% 20%, rgba(255, 192, 210, 0.35) 0%, transparent 42%),
    radial-gradient(circle at 88% 75%, rgba(210, 190, 255, 0.3) 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(255, 218, 230, 0.5) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* 極淡心形 pattern（SVG tile，疊喺光暈之上） */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='84' viewBox='0 0 96 84'%3E%3Cg fill='%23b84d72' fill-opacity='0.07'%3E%3Cpath transform='translate(8 10) scale(0.52)' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3Cpath transform='translate(54 44) scale(0.4)' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3Cpath transform='translate(44 6) scale(0.28)' d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 96px 84px;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

@keyframes bg-shift {
  0%,
  100% {
    background-position: 0% 40%;
  }
  50% {
    background-position: 100% 60%;
  }
}

.wrap {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 58rem;
  width: 100%;
}

.game-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.2vw, 2.05rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--rose-deep);
  text-shadow: 0 2px 20px rgba(232, 121, 166, 0.28), 0 1px 0 rgba(255, 255, 255, 0.95);
}

.subtitle {
  margin: 0 0 1.15rem;
  font-family: var(--font-body);
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.78;
  max-width: 26rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.45;
}

.rules-in-game {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: linear-gradient(160deg, rgba(255, 182, 203, 0.35), rgba(200, 170, 230, 0.38));
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
}

.rules-in-game[hidden] {
  display: none !important;
}

.rules-card-in {
  width: 100%;
  max-width: 22rem;
  max-height: 94%;
  overflow: auto;
  margin: 0 auto;
  padding: 0.85rem 1rem 1rem;
  text-align: left;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 245, 250, 0.98) 100%);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  box-shadow: var(--shadow-romantic), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.rules-title-in {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rose-deep);
  text-align: center;
}

.rules-list-in {
  margin: 0;
  padding-left: 1.1rem;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.5;
}

.rules-list-in li {
  margin-bottom: 0.3rem;
}

.rules-list-in li:last-child {
  margin-bottom: 0;
}

.rules-list-in kbd {
  display: inline-block;
  padding: 0.1rem 0.32rem;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 700;
  border: 1px solid var(--rose-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--lilac-soft));
  box-shadow: 0 2px 6px rgba(184, 77, 114, 0.08);
  color: var(--rose-deep);
}

.btn-close-rules {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.35;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(232, 121, 166, 0.35);
}

.player,
.ex {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla",
    sans-serif;
}

.chip-emoji span {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla",
    sans-serif;
}

.game-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
  margin: 0 auto;
}

.controls-side {
  flex: 0 0 5.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 0.45rem;
  background: linear-gradient(180deg, var(--glass) 0%, rgba(255, 248, 252, 0.85) 100%);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  min-height: 600px;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.controls-side--right {
  flex: 0 0 6.5rem;
}

.controls-side .control-heading {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.82rem;
  margin-bottom: 0.6rem;
  text-align: center;
  color: var(--rose-deep);
  letter-spacing: -0.02em;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.chip-row--stack {
  flex-direction: column;
  flex-wrap: nowrap;
  width: 100%;
  align-items: stretch;
  gap: 0.4rem;
}

.chip-row--skins {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  width: 100%;
  justify-items: stretch;
}

.controls-side .chip {
  width: 100%;
}

.controls-side .chip span {
  width: 100%;
}

.controls-side--right .chip-emoji span {
  font-size: 1.15rem;
  min-width: 0;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.game-shell .game {
  flex: 0 0 auto;
}

@media (max-width: 430px) {
  .game {
    width: min(400px, calc(100vw - 1.25rem));
  }
}

@media (max-width: 720px) {
  .game-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0.55rem;
    max-width: min(400px, calc(100vw - 1rem));
  }

  .controls-side--left {
    grid-column: 1;
    grid-row: 1;
    min-height: auto;
    width: 100%;
  }

  .controls-side--right {
    grid-column: 2;
    grid-row: 1;
    min-height: auto;
    width: 100%;
  }

  .game-shell .game {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.chip {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(232, 121, 166, 0.45);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff 0%, rgba(255, 245, 250, 0.95) 100%);
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--rose-deep);
  box-shadow: 0 2px 10px rgba(184, 77, 114, 0.06);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease,
    transform 0.15s ease;
}

.chip-emoji span {
  min-width: 2.75rem;
  font-size: 1.35rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.chip input:checked + span {
  background: linear-gradient(145deg, #ff9ec4 0%, var(--accent) 45%, #d65a8c 100%);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 20px rgba(232, 121, 166, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.chip:hover input:not(:disabled) + span {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(232, 121, 166, 0.15);
}

.chip input:focus-visible + span {
  outline: 2px solid var(--lilac);
  outline-offset: 3px;
}

.chip input:disabled + span {
  opacity: 0.5;
  cursor: not-allowed;
}

.game {
  position: relative;
  width: 400px;
  height: 600px;
  margin: 0 auto;
  overflow: hidden;
  touch-action: none;
  border: none;
  border-radius: 28px;
  background: linear-gradient(
    185deg,
    #e8d9ff 0%,
    #ffd6ec 28%,
    #ffe8f0 52%,
    #fff5f8 72%,
    #f0e6ff 100%
  );
  box-shadow: 0 0 0 1px rgba(255, 182, 203, 0.65), 0 0 0 8px rgba(255, 255, 255, 0.55),
    var(--shadow-romantic), inset 0 0 80px rgba(255, 200, 220, 0.25);
}

.game::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(255, 255, 255, 0.75) 0%, transparent 55%),
    radial-gradient(circle at 12% 25%, rgba(255, 192, 210, 0.45) 0%, transparent 38%),
    radial-gradient(circle at 88% 18%, rgba(210, 190, 255, 0.4) 0%, transparent 36%),
    radial-gradient(circle at 50% 95%, rgba(255, 218, 235, 0.55) 0%, transparent 48%);
  pointer-events: none;
  z-index: 0;
}

.score {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  color: var(--rose-deep);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 16px rgba(184, 77, 114, 0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.player {
  position: absolute;
  bottom: 12px;
  left: 176px;
  width: 48px;
  height: 48px;
  font-size: 2.25rem;
  line-height: 48px;
  text-align: center;
  z-index: 2;
  filter: drop-shadow(0 6px 12px rgba(184, 77, 114, 0.25));
}

.touch-move {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58px;
  display: none;
  align-items: stretch;
  gap: 8px;
  padding: 6px 10px 10px;
  z-index: 4;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 245, 250, 0.88) 35%, rgba(255, 236, 244, 0.96) 100%);
  pointer-events: auto;
}

.touch-move__btn {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--rose-deep);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  box-shadow: 0 4px 16px rgba(184, 77, 114, 0.1);
  transition: transform 0.08s ease, background 0.08s ease;
}

.touch-move__btn:active {
  background: rgba(255, 218, 232, 0.98);
  transform: scale(0.97);
}

@media (max-width: 720px), (pointer: coarse) {
  .touch-move {
    display: flex;
  }

  .player {
    bottom: 62px;
  }
}

.ex {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe0ea 0%, #ffb3c9 50%, #ff8fb8 100%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  z-index: 1;
  box-shadow: 0 6px 16px rgba(184, 77, 114, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.5);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, rgba(90, 50, 80, 0.28), rgba(140, 100, 160, 0.32));
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  padding: 1rem;
}

.overlay[hidden] {
  display: none !important;
}

.overlay-card {
  background: linear-gradient(175deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 248, 252, 0.99) 100%);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 1.35rem 1.5rem;
  max-width: 90%;
  box-shadow: var(--shadow-romantic), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.overlay-line {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--rose-deep);
}

.awkward-line {
  margin: 0 0 1rem;
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.5;
  min-height: 2.9em;
}

.overlay-score {
  margin: 0 0 0.5rem;
  font-family: var(--font-body);
  font-weight: 700;
}

.overlay-hint {
  margin: 0 0 0.85rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  opacity: 0.82;
  text-align: center;
}

.btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  padding: 0.55rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: linear-gradient(145deg, #ffa8cc 0%, var(--accent) 40%, #c94d7a 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(232, 121, 166, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(232, 121, 166, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(1.03);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 16px rgba(232, 121, 166, 0.35);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
