/* Review overlay. Styling is layered over the game's current DOM and layout. */
:root {
  --azhar-ivory: #fff0d1;
  --azhar-amber: #e7ad58;
  --azhar-edge: #ad7138;
  --azhar-deep: #1d1225;
  --azhar-step: polygon(0 18%, 7% 18%, 7% 10%, 14% 10%, 14% 0, 86% 0, 86% 10%, 93% 10%, 93% 18%, 100% 18%, 100% 82%, 93% 82%, 93% 90%, 86% 90%, 86% 100%, 14% 100%, 14% 90%, 7% 90%, 7% 82%, 0 82%);
  --azhar-step-rim: polygon(evenodd, 0 18%, 7% 18%, 7% 10%, 14% 10%, 14% 0, 86% 0, 86% 10%, 93% 10%, 93% 18%, 100% 18%, 100% 82%, 93% 82%, 93% 90%, 86% 90%, 86% 100%, 14% 100%, 14% 90%, 7% 90%, 7% 82%, 0 82%, 0 18%, 2% 20%, 2% 80%, 9% 80%, 9% 88%, 16% 88%, 16% 98%, 84% 98%, 84% 88%, 91% 88%, 91% 80%, 98% 80%, 98% 20%, 91% 20%, 91% 12%, 84% 12%, 84% 2%, 16% 2%, 16% 12%, 9% 12%, 9% 20%, 2% 20%);
  --azhar-rosette: polygon(50% 0, 61% 22%, 85% 15%, 78% 39%, 100% 50%, 78% 61%, 85% 85%, 61% 78%, 50% 100%, 39% 78%, 15% 85%, 22% 61%, 0 50%, 22% 39%, 15% 15%, 39% 22%);
}

.masthead .wordmark b { color: var(--azhar-ivory); }
.masthead .wordmark span { color: #d4b789; }
.stage { border-color: var(--azhar-edge); }

:is(.text-button, .primary):not(:disabled):is(:hover, :focus-visible) {
  border-image-source: url("ui-art/button-hover.png");
  color: #fff3d4;
  filter: drop-shadow(0 0 4px #ffa84c34);
}
:is(.text-button, .primary):not(:disabled):active {
  border-image-source: url("ui-art/button-pressed.png");
  color: #ffe7af;
  filter: none;
}
:is(.text-button, .primary):disabled { opacity: .52; filter: saturate(.28); }

/* Preserve the current player information and its placement. */
body[data-phase="play"] .hud-player {
  position: relative;
  isolation: isolate;
}
body[data-phase="play"] .hud-player::before {
  position: absolute;
  z-index: -1;
  inset: -3px -5px -4px;
  border: 6px solid transparent;
  border-inline-width: 9px;
  border-image: var(--ui-frame) 13 20 fill stretch;
  opacity: .74;
  pointer-events: none;
  content: "";
}
body[data-phase="play"] .hud-portrait { filter: drop-shadow(1px 2px 2px #120b16); }
body[data-phase="play"] .health-track { background: #3a172b; }
body[data-phase="play"] .health-fill {
  background:
    repeating-linear-gradient(104deg, transparent 0 12px, #521c38a8 12px 13px),
    linear-gradient(#fb7771 0 14%, #ea4d49 15% 31%, #a82945 32% 76%, #6d1835 77%);
}
body[data-phase="play"] .health-text { color: #fff7dc; }
body[data-phase="play"] .hud-progress { color: var(--azhar-ivory); }
body[data-phase="play"] .hud-progress span { color: #f3c988; }
body[data-phase="play"] .hint[data-feedback="true"] { color: #ffe2a7; }
body:not([data-input="touch"]) .status-strip {
  background: linear-gradient(90deg, #28172b, #1b1424 60%, #211426);
  border-color: #8b603c;
}
body:not([data-input="touch"]) .controls { color: #d7c7b9; }
body:not([data-input="touch"]) .controls kbd {
  color: #ffe2aa;
  border-color: #936637;
  background: #26162b;
  border-radius: 1px;
}

/* A second layer paints the bright rim. The touch plate remains 50% opaque. */
body[data-input="touch"][data-phase="play"] .touch-pad button {
  color: var(--azhar-ivory);
  text-shadow: 0 1px 1px #190f1a, 0 2px 5px #100813;
}
body[data-input="touch"][data-phase="play"] .touch-pad button::before {
  border: 0;
  border-radius: 0;
  clip-path: var(--azhar-step);
  background:
    repeating-linear-gradient(135deg, transparent 0 5px, #f9be6924 5px 6px, transparent 6px 10px),
    linear-gradient(150deg, #592d59, #1d1225 80%);
  box-shadow: none;
  opacity: .5;
}
body[data-input="touch"][data-phase="play"] .touch-pad button::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  clip-path: var(--azhar-step-rim);
  background: linear-gradient(129deg, #fae0a4, #b08148 32%, #d8a862 57%, #8f5636 90%);
  opacity: .9;
  pointer-events: none;
  content: "";
}
body[data-input="touch"][data-phase="play"] .touch-pad button kbd { color: #ffe0a6; }
body[data-input="touch"][data-phase="play"] .touch-pad button[data-game-key="KeyZ"]::before {
  background: linear-gradient(155deg, #614238, #21172b 78%);
}
body[data-input="touch"][data-phase="play"] .touch-pad button[data-game-key="KeyC"]::before {
  background: linear-gradient(155deg, #4b4a3c, #26192d 78%);
}
body[data-input="touch"][data-phase="play"] .touch-pad button[data-game-key="KeyA"]::before {
  background:
    repeating-linear-gradient(135deg, transparent 0 7px, #f8bd6c32 7px 8px, transparent 8px 13px),
    linear-gradient(150deg, #963f4f, #36182d 80%);
}
body[data-input="touch"][data-phase="play"] .touch-pad button[data-game-key="KeyA"]::after {
  background: linear-gradient(130deg, #ffe2a3, #ecab55 45%, #b7773d 100%);
  opacity: 1;
}
body[data-input="touch"][data-phase="play"] .touch-pad button:is(.is-pressed, :active)::before {
  background: linear-gradient(150deg, #af593e, #3e1f2e 82%);
}
body[data-input="touch"][data-phase="play"] .touch-pad button:is(.is-pressed, :active, :focus-visible)::after {
  background: #ffdd91;
  opacity: 1;
}
body[data-input="touch"]:is([data-phase="play"], [data-phase="paused"], [data-phase="boss-intro"]) .masthead .text-button {
  border: 0;
  border-radius: 0;
  clip-path: var(--azhar-step);
  background: linear-gradient(140deg, #ffe0a2, #a7703f 55%, #e8af63);
  isolation: isolate;
  box-shadow: none;
}
body[data-input="touch"]:is([data-phase="play"], [data-phase="paused"], [data-phase="boss-intro"]) .masthead .text-button::before {
  position: absolute;
  z-index: -1;
  inset: 1px;
  clip-path: var(--azhar-step);
  background: linear-gradient(153deg, #51334d, var(--azhar-deep) 80%);
  content: "";
}
body[data-input="touch"][data-phase="play"] #objective {
  border-color: #dba761a0;
  border-radius: 1px;
  background: #24162ae0;
}

/* State-specific ornaments stay inside the existing game panels. */
body[data-phase="title"] .title-lockup > .kicker {
  display: inline-flex;
  align-items: center;
  gap: .15em;
  max-width: 100%;
}
body[data-phase="title"] .title-lockup > .kicker::before,
body[data-phase="title"] .title-lockup > .kicker::after {
  width: clamp(8px, 1cqw, 12px);
  aspect-ratio: 1;
  margin-inline: .28em;
  background: var(--azhar-amber);
  clip-path: var(--azhar-rosette);
  content: "";
}
body[data-phase="title"] .title-panel h1 { color: var(--azhar-ivory); }

body[data-phase="rotate"] .rotate-card,
body[data-phase="language"] .language-card,
body[data-phase="paused"] .pause-card {
  box-shadow: 0 10px 34px #10081689;
  filter: drop-shadow(0 0 11px #a55c291f);
}
body[data-phase="rotate"] .rotate-phone {
  border-radius: 3px;
  background: linear-gradient(148deg, #442449 14%, #261630 55%, #633c3d 100%);
  color: var(--azhar-amber);
}
body[data-phase="rotate"] .rotate-phone::before { border-radius: 1px; }
body[data-phase="paused"] #pause-title {
  position: relative;
  color: var(--azhar-ivory);
}
body[data-phase="paused"] #pause-title::after {
  position: absolute;
  top: 100%;
  left: 50%;
  width: clamp(5px, .7cqw, 8px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  clip-path: var(--azhar-rosette);
  background: var(--azhar-amber);
  content: "";
}

body:is([data-phase="opening"], [data-phase="dialogue"]) .dialogue {
  filter: drop-shadow(0 3px 9px #100812c6);
}
body:is([data-phase="opening"], [data-phase="dialogue"]) #speaker {
  display: flex;
  align-items: center;
  gap: .65em;
  color: #ffd283;
  text-shadow: 0 1px 2px #1d101c;
}
body:is([data-phase="opening"], [data-phase="dialogue"]) #speaker::before {
  display: inline-block;
  width: .72em;
  aspect-ratio: 1;
  flex: none;
  clip-path: var(--azhar-rosette);
  background: var(--azhar-amber);
  content: "";
}
body:is([data-phase="opening"], [data-phase="dialogue"]) #portrait {
  border-color: var(--azhar-amber);
  box-shadow: 0 0 0 2px #342035;
}

@media (orientation: portrait) {
  body[data-input="touch"][data-phase="play"] .hud-player::before { opacity: .62; }
}
