:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  --cream: #fff7ef;
  --gold: #f5cc7d;
  --rose: #ff91aa;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: clamp(1rem, 3vw, 2.5rem);
  color: var(--cream);
  background:
    radial-gradient(circle at 10% 8%, #812b64 0, transparent 28%),
    radial-gradient(circle at 90% 88%, #6d234f 0, transparent 32%),
    linear-gradient(145deg, #230d31 0%, #46143c 55%, #200b2c 100%);
}

.game-shell { width: min(100%, 1000px); margin: 0 auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  color: #ffe8ed;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .14em;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: .55rem .85rem;
  border: 1px solid #fff1e638;
  border-radius: 999px;
  color: inherit;
  letter-spacing: .01em;
  text-decoration: none;
}

.topbar a:hover { background: #fff2e91a; }
.topbar a:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.game-card {
  overflow: hidden;
  border: 1px solid #fff4e62f;
  border-radius: 30px;
  background: #17081fd6;
  box-shadow: 0 34px 100px #09020d99, inset 0 0 0 1px #ffffff09;
  backdrop-filter: blur(15px);
}

.game-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: linear-gradient(135deg, #2a0d35, #49133c);
}

.eyebrow {
  margin: 0 0 .55rem;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2rem, 4.5vw, 3.55rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -.045em;
}

h1 em { color: var(--rose); font-weight: 400; }

.game-heading > p {
  max-width: 29rem;
  margin: 0;
  color: #e9ced9;
  font-size: 1rem;
  line-height: 1.65;
}

.character-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem clamp(1.35rem, 4vw, 2.5rem);
  border-bottom: 1px solid #fff2df20;
  background: #1e092ad9;
}

.character-picker > div:first-child { min-width: 10rem; }
.character-picker p { margin: 0; color: #fff5ec; font-size: .96rem; font-weight: 700; }
.character-picker > div:first-child small { display: block; margin-top: .3rem; color: #caaebe; font-size: .78rem; }
.character-options { display: flex; flex-wrap: wrap; justify-content: end; gap: .45rem; }

.character-option {
  display: grid;
  justify-items: center;
  gap: .2rem;
  min-width: 66px;
  padding: .45rem .35rem .4rem;
  border: 1px solid #ffffff24;
  border-radius: 12px;
  background: #35142f;
  color: #f8e8ed;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.character-option:hover { background: #4b1b40; transform: translateY(-2px); }
.character-option.selected { border-color: #f5c978; background: #683052; box-shadow: 0 0 0 2px #f5c9782b; }
.character-option > span { min-height: 1.9rem; font-size: 1.55rem; line-height: 1.2; }
.character-option small { color: #e3cbd4; font-size: .67rem; white-space: nowrap; }

.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #2c123d;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.score-pill {
  position: absolute;
  top: 1rem;
  left: 50%;
  display: flex;
  align-items: baseline;
  gap: .22rem;
  min-width: 92px;
  padding: .55rem .9rem;
  border: 1px solid #fff4e65e;
  border-radius: 999px;
  background: #18091fc7;
  box-shadow: 0 8px 24px #10041654;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.score-pill span {
  margin-left: auto;
  color: #fffaf2;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.55rem;
  line-height: 1;
}

.score-pill small { margin-right: auto; color: var(--gold); font-size: .78rem; font-weight: 700; }

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 1.5rem;
  background: #18082099;
  text-align: center;
  backdrop-filter: blur(5px);
}

.game-overlay::before {
  content: "";
  position: absolute;
  width: min(86%, 440px);
  height: min(74%, 340px);
  border: 1px solid #fff2df38;
  border-radius: 25px;
  background: linear-gradient(150deg, #260e35ed, #49133eed);
  box-shadow: 0 26px 70px #09020dbd;
}

.game-overlay > * { position: relative; z-index: 1; }

.overlay-heart,
.crown {
  margin: 0 0 .35rem;
  color: var(--gold);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 3.3rem;
  line-height: 1;
}

.game-overlay h2 {
  margin: 0;
  color: #fff8ef;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 400;
}

.game-overlay p:not(.overlay-heart):not(.crown) {
  max-width: 22rem;
  margin: .75rem 0 1.1rem;
  color: #ead3dc;
  font-size: 1rem;
  line-height: 1.55;
}

.game-overlay button,
.game-overlay a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: .85rem 1.35rem;
  border: 1px solid #ffdca561;
  border-radius: 14px;
  background: linear-gradient(135deg, #bd426a, #792451);
  box-shadow: 0 12px 28px #0e03146b;
  color: #fffaf4;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.game-overlay button:hover,
.game-overlay a:hover { transform: translateY(-2px); box-shadow: 0 16px 32px #0e03147d; }

.game-overlay button:focus-visible,
.game-overlay a:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.game-overlay small { margin-top: .75rem; color: #d9b9c7; font-size: .78rem; }

.win-overlay::before {
  background: linear-gradient(150deg, #3f163fef, #6f244cef);
  box-shadow: 0 26px 70px #09020dbd, 0 0 45px #ff8fa957;
}

.win-overlay .crown { color: #ffe09b; animation: crown-bounce 1.2s ease-in-out infinite; }

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

@media (max-width: 700px) {
  body { padding: .75rem; }
  .topbar { font-size: .65rem; }
  .topbar span { display: none; }
  .game-card { border-radius: 22px; }
  .game-heading { display: grid; gap: .8rem; padding: 1.35rem; }
  .game-heading > p { font-size: .92rem; line-height: 1.5; }
  .character-picker { display: grid; gap: .75rem; padding: 1rem 1.35rem; }
  .character-options { justify-content: start; }
  .character-option { min-width: 58px; }
  .game-frame { max-height: none; }
  .game-overlay::before { width: min(90%, 380px); height: min(82%, 310px); }
  .overlay-heart, .crown { font-size: 2.6rem; }
  .game-overlay h2 { font-size: clamp(1.75rem, 8vw, 2.5rem); }
  .game-overlay p:not(.overlay-heart):not(.crown) { margin-block: .55rem .8rem; font-size: .9rem; }
  .game-overlay button, .game-overlay a { min-height: 46px; padding: .7rem 1rem; font-size: .9rem; }
  .game-overlay small { margin-top: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
