:root {
  color-scheme: dark;
  --plum: #34243f;
  --plum-2: #513651;
  --rose: #a85d79;
  --rose-light: #e4a9b5;
  --cream: #fbf0dc;
  --sage: #8ea88c;
  --gold: #d6b878;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #21172b; color: var(--cream); font-family: Georgia, "Times New Roman", serif; }
button, input { font: inherit; }
button { color: inherit; }
#app { display: grid; place-items: center; width: 100vw; height: 100dvh; overflow: hidden; background: radial-gradient(ellipse at center, #745477 0%, #30223a 68%, #21172b 100%); }
#stage { position: relative; width: min(100vw, calc(100dvh * 16 / 9), 1600px); height: min(100dvh, calc(100vw * 9 / 16), 900px); aspect-ratio: 16 / 9; overflow: hidden; background: #9d8bc0; box-shadow: 0 12px 54px #100b166e; isolation: isolate; }
#game { display: block; width: 100%; height: 100%; image-rendering: auto; touch-action: none; }
.screen { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: clamp(16px, 4vw, 40px); background: linear-gradient(90deg, #21152b24, #21152b44 55%, #21152b20); }
.screen[hidden] { display: none; }
.menu-screen { place-items: center end; background: linear-gradient(90deg, #22162a12 0%, #22162a30 42%, #271931a8 100%); }
.menu-card, .modal-card, .dialog-card {
  position: relative; border: 1px solid #e8c991c9; border-radius: 24px;
  background: linear-gradient(145deg, #4a3457f2, #30213deF);
  box-shadow: 0 14px 38px #1e122d88, inset 0 0 0 5px #d7b87820, inset 0 0 30px #f4d9aa0b;
}
.menu-card { width: min(42%, 390px); min-width: 310px; padding: 30px 32px 24px; text-align: center; margin-right: 3%; }
.eyebrow { color: #e9cb91; text-transform: uppercase; letter-spacing: .14em; font: 600 11px/1.4 Arial, sans-serif; }
h1, h2, p { margin: 0; }
h1 { margin: 8px 0 -4px; font-size: clamp(45px, 6vw, 72px); font-weight: 500; letter-spacing: -.055em; color: #fae9d3; text-shadow: 0 4px 20px #170d1d99; }
.subtitle { color: #e6b3c1; font-size: clamp(18px, 2vw, 24px); font-style: italic; }
.menu-card > p { margin: 18px 0 17px; color: #edd9c1; font-size: 13px; line-height: 1.5; }
.menu-card > p span { display: block; color: #fff3dc; font-size: 16px; margin-top: 2px; }
.menu-buttons { display: grid; gap: 9px; }
.primary-button, .secondary-button, .text-button {
  min-height: 43px; border-radius: 999px; padding: 10px 20px; cursor: pointer; transition: transform .16s ease, filter .16s ease, background .16s ease;
  font: 600 14px Arial, sans-serif; letter-spacing: .015em;
}
.primary-button { border: 1px solid #f4d898; color: #3a263e; background: linear-gradient(180deg, #f3dcae, #d6b37a); box-shadow: 0 5px 14px #120a206b, inset 0 1px 0 #fff8df; }
.secondary-button { border: 1px solid #d4a9b7; background: #9a5b77; color: #fff3e4; box-shadow: 0 4px 12px #160e2499; }
.text-button { min-height: 35px; padding: 7px 14px; border: 0; background: transparent; color: #f2e2d0; }
button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: translateY(1px) scale(.985); }
button:focus-visible, input:focus-visible { outline: 2px solid #fff0b9; outline-offset: 3px; }
.menu-foot { margin-top: 18px; color: #cbb4c8; font: 11px/1.5 Arial, sans-serif; }
.modal-screen { background: #1b1329b8; backdrop-filter: blur(7px); }
.modal-card { width: min(440px, 94%); padding: 28px clamp(20px, 4vw, 36px); text-align: center; }
.modal-card h2 { margin: 8px 0 18px; font-size: clamp(27px, 4vw, 38px); font-weight: 500; text-transform: capitalize; color: #fff0d5; }
.modal-card > p { margin: -5px 0 18px; font: 14px/1.55 Arial, sans-serif; color: #ead9db; }
.compact { min-height: 38px; padding: 8px 18px; }
.dialog-screen { place-items: end center; padding-bottom: 5%; background: linear-gradient(0deg, #1b1028d4, transparent 48%); }
.dialog-card { width: min(760px, 94%); min-height: 132px; display: grid; grid-template-columns: 102px 1fr auto; align-items: center; gap: 17px; padding: 15px 19px; }
.dialog-portrait { width: 95px; height: 95px; border-radius: 50%; object-fit: cover; object-position: center 20%; border: 2px solid #e1c481; box-shadow: 0 0 0 4px #d8b47722; background: #48334f; }
.dialog-speaker { margin-bottom: 5px; color: #efca8f; font-size: 17px; }
.dialog-copy p { max-width: 500px; color: #fff1dc; font: 15px/1.52 Arial, sans-serif; }
.setting-row { display: grid; grid-template-columns: 1fr auto 1.2fr; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f7e8cc24; text-align: left; font: 14px Arial, sans-serif; color: #f6e8d9; }
.setting-row input[type=checkbox] { accent-color: #d7b67c; width: 18px; height: 18px; }
.setting-row input[type=range] { width: 100%; accent-color: #d6b878; }
.settings-card .primary-button, .help-card .primary-button { margin-top: 20px; min-width: 140px; }
.controls-grid { display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 11px 15px; margin: 12px 0 19px; font: 13px Arial, sans-serif; color: #eddfdb; }
.controls-grid b { color: #f2d596; font-weight: 600; white-space: nowrap; }
.help-card > p { text-align: left; }
.victory-card { width: min(500px, 96%); }
.victory-card h2 { color: #f4db9e; }
.victory-copy { margin: -6px auto 18px !important; max-width: 375px; }
.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.results-grid div { display: grid; gap: 4px; padding: 12px 7px; border: 1px solid #d7bb8052; border-radius: 14px; background: #fff4df0b; }
.results-grid strong { font-size: 20px; color: #f2d89e; font-weight: 500; }
.results-grid span { color: #d9c7d7; font: 11px Arial, sans-serif; }
.power-earned { margin: 13px 0 19px; color: #ceb9d2; font: 12px/1.6 Arial, sans-serif; }
.power-earned b { display: block; color: #f2dbad; font-size: 14px; }
.quick-pause { position: absolute; z-index: 3; top: 3%; right: 2%; width: clamp(34px, 4.2vw, 46px); height: clamp(34px, 4.2vw, 46px); border: 1px solid #f0daae; border-radius: 50%; background: #3a2947cc; color: #ffe8c1; font-size: 18px; cursor: pointer; box-shadow: 0 3px 12px #24162877; }
.touch-controls { display: none; position: absolute; z-index: 3; inset: auto 0 3.2% 0; align-items: end; justify-content: space-between; padding: 0 3.5%; pointer-events: none; }
.move-pad, .action-pad { display: flex; align-items: end; gap: 9px; pointer-events: auto; }
.action-pad { position: relative; padding-right: 3px; }
.touch-controls button { display: grid; place-items: center; width: clamp(44px, 7vw, 68px); height: clamp(44px, 7vw, 68px); border-radius: 50%; border: 1px solid #f4e0c89b; color: #fff1db; background: #4e3b5fb8; box-shadow: 0 3px 11px #21152e7a, inset 0 1px 0 #fff6de47; font: 32px/1 Georgia, serif; touch-action: none; -webkit-user-select: none; user-select: none; }
.touch-controls button.active { background: #bf8194df; transform: scale(.94); }
.touch-controls .attack-button { width: clamp(40px, 6vw, 56px); height: clamp(40px, 6vw, 56px); font-size: 22px; margin-right: 7px; }
.touch-controls .interact-button { position: absolute; right: 0; bottom: calc(100% + 8px); display: none; width: 37px; height: 37px; font: bold 13px Arial, sans-serif; }
.touch-controls.show-interact .interact-button { display: grid; }
.rotate-hint { display: none; position: absolute; z-index: 6; inset: 0 0 auto; min-height: 28px; place-items: center; color: #fff0d5; background: #2f203db8; font: 10px Arial, sans-serif; letter-spacing: .04em; pointer-events: none; }
@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .quick-pause { top: 4%; }
}
@media (orientation: portrait) and (pointer: coarse) {
  #stage[data-state="menu"] .rotate-hint { display: grid; }
  .touch-controls { padding-bottom: 1%; }
}
@media (max-width: 620px) {
  .menu-screen { place-items: center; background: linear-gradient(90deg, #24162a6b, #24162ac7); }
  .menu-card { width: min(86%, 370px); min-width: 0; padding: 18px 22px 15px; margin: 0; border-radius: 19px; }
  h1 { font-size: 46px; }
  .menu-card > p { margin: 12px 0; }
  .menu-foot { margin-top: 10px; }
  .screen { padding: 12px; }
  .dialog-card { width: 96%; grid-template-columns: 60px 1fr; gap: 10px; padding: 11px; min-height: 104px; border-radius: 17px; }
  .dialog-portrait { width: 56px; height: 56px; }
  .dialog-copy p { font-size: 12px; }
  .dialog-speaker { font-size: 14px; }
  .dialog-card .primary-button { grid-column: 2; justify-self: end; min-height: 31px; font-size: 11px; padding: 6px 14px; }
}
@media (max-height: 420px) {
  .menu-card { padding: 12px 20px; }
  h1 { font-size: 42px; }
  .menu-card > p { margin: 8px 0; }
  .menu-foot { margin-top: 8px; }
  .primary-button, .secondary-button { min-height: 36px; }
  .modal-card { padding-top: 17px; padding-bottom: 17px; }
  .modal-card h2 { margin-bottom: 10px; }
  .dialog-screen { padding-bottom: 10%; }
}
@media (max-height: 300px) {
  .menu-screen { place-items: center; }
  .menu-card { width: min(90%, 390px); min-width: 0; padding: 8px 15px; margin: 0; }
  .menu-card .eyebrow, .menu-card > p, .menu-foot { display: none; }
  h1 { margin: 0; font-size: 34px; line-height: 1; }
  .subtitle { font-size: 15px; }
  .menu-buttons { grid-template-columns: repeat(2, 1fr); gap: 5px; margin-top: 8px; }
  .menu-buttons button { min-height: 29px; padding: 5px 8px; font-size: 11px; }
  .modal-screen { overflow-y: auto; }
  .modal-card { padding: 11px 15px; }
}
