@import url("https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&display=swap");

:root {
  color-scheme: light;
  --paper: #eaf6ff;
  --ink: #17152b;
  --ink-soft: #35305f;
  --muted: #6d7090;
  --line: rgba(36, 32, 86, 0.18);
  --gold: #f2b535;
  --gold-deep: #9a5815;
  --blue: #2351c4;
  --cyan: #29dbe8;
  --violet: #8b62ff;
  --green: #39c758;
  --rose: #e64f91;
  --panel: rgba(255, 255, 255, 0.7);
  --mx: 0.5;
  --my: 0.5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  background: #cfe8ff;
  color: var(--ink);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

#aura-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.32;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  padding: clamp(16px, 3vw, 32px);
}

.hidden {
  display: none !important;
}

.kicker,
.nav-title,
.pixel-button,
.stage-heading h2,
.setup-panel h1,
.result-hero h1,
.column-heading h2,
.final-story h2,
.score-card h2 {
  font-family: "Pixelify Sans", "Courier New", monospace;
  letter-spacing: 0;
}

.kicker {
  margin: 0;
  color: var(--blue);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
}

.start-screen {
  display: grid;
  align-items: end;
  justify-items: center;
  padding: min(3vw, 24px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(20, 26, 66, 0.18)),
    url("/static/main_screen.png") center / contain no-repeat #c6d9ff;
}

.midia-logo {
  position: absolute;
  left: clamp(18px, 2.4vw, 34px);
  bottom: clamp(18px, 2.4vw, 34px);
  width: clamp(72px, 8.2vw, 112px);
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid rgba(50, 19, 95, 0.62);
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 8px 0 rgba(50, 19, 95, 0.14),
    0 14px 24px rgba(35, 24, 70, 0.22);
  object-fit: cover;
  object-position: center;
  image-rendering: pixelated;
}

.menu-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 22px);
  width: min(520px, 74vw);
  margin-bottom: clamp(10px, 2vh, 28px);
  transform: translateY(clamp(6px, 1.1vh, 16px));
}

.image-button {
  display: grid;
  place-items: center;
  width: min(230px, 31vw);
  height: min(96px, 13vw);
  padding: 0;
  background: transparent;
  filter: drop-shadow(0 16px 22px rgba(35, 24, 70, 0.34));
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

.image-button.info-button {
  width: min(230px, 31vw);
}

.image-button:hover {
  transform: translateY(-4px) scale(1.02);
  filter: drop-shadow(0 20px 26px rgba(35, 24, 70, 0.42)) saturate(1.08);
}

.image-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.image-button.info-button img {
  height: 92.5%;
}

.setup-screen,
.loading-screen {
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(233, 245, 255, 0.7), rgba(219, 232, 255, 0.86)),
    url("/static/background.png") center / cover no-repeat;
}

.setup-panel,
.info-dialog article {
  width: min(820px, 94vw);
  max-width: 100%;
  border: 4px solid #382175;
  border-radius: 8px;
  background: rgba(255, 244, 177, 0.9);
  box-shadow:
    0 0 0 5px rgba(255, 255, 255, 0.56),
    0 22px 48px rgba(40, 29, 85, 0.28);
}

.setup-panel {
  padding: clamp(20px, 4vw, 36px);
}

.setup-panel h1 {
  margin: 8px 0 24px;
  color: #351060;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.92;
  text-transform: uppercase;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 24px);
}

fieldset {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 2px solid rgba(53, 16, 96, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
}

legend {
  padding-inline: 8px;
  color: #351060;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 1.3rem;
  font-weight: 700;
}

label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  color: var(--ink);
  font-weight: 760;
}

label span {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="radio"] {
  accent-color: var(--blue);
}

.setup-actions,
.brew-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.pixel-button {
  min-height: 48px;
  padding: 0 22px;
  border: 3px solid #32135f;
  border-radius: 8px;
  background: var(--gold);
  color: #32135f;
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.54),
    inset 0 -4px 0 rgba(130, 69, 8, 0.28),
    0 8px 0 rgba(50, 19, 95, 0.18);
}

.pixel-button.secondary {
  background: #dff4ff;
}

.pixel-button:hover {
  transform: translateY(-2px);
}

.loading-screen {
  align-content: center;
  gap: 16px;
  text-align: center;
}

.loading-sigil {
  width: 62px;
  height: 62px;
  border: 8px solid rgba(50, 19, 95, 0.2);
  border-top-color: var(--gold);
  border-radius: 8px;
  image-rendering: pixelated;
  animation: spin 1s steps(8) infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-screen h2 {
  margin: 0;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(2rem, 6vw, 4rem);
  color: #32135f;
  text-transform: uppercase;
}

.loading-screen p {
  width: min(560px, 92vw);
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.progress-track {
  width: min(460px, 76vw);
  height: 16px;
  overflow: hidden;
  border: 3px solid #32135f;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.5);
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--gold));
  transition: width 180ms ease;
}

.status-note {
  min-height: 1.4em;
  color: #8b224d !important;
}

.game-screen,
.results-screen {
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(225, 235, 255, 0.22)),
    url("/static/background.png") center top / cover fixed no-repeat;
}

.game-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 60px;
  padding-inline: clamp(10px, 2vw, 22px);
  border-bottom: 3px solid rgba(50, 19, 95, 0.32);
  background: rgba(255, 244, 177, 0.72);
  backdrop-filter: blur(10px);
}

.nav-title {
  color: #32135f;
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid #32135f;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: #32135f;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.78);
}

.word-stage {
  position: relative;
  z-index: 4;
  width: min(1180px, calc(100% - 32px));
  min-height: clamp(380px, 45vh, 520px);
  margin: clamp(18px, 3vw, 30px) auto 0;
  overflow: visible;
  border: 4px solid rgba(50, 19, 95, 0.64);
  border-radius: 8px;
  background: rgba(242, 248, 255, 0.42);
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.34),
    0 20px 46px rgba(52, 48, 105, 0.12);
  backdrop-filter: blur(4px);
}

.stage-heading {
  position: relative;
  z-index: 2;
  padding: 18px 18px 0;
  text-align: center;
  pointer-events: none;
}

.stage-heading h2 {
  margin: 4px 0 2px;
  color: #32135f;
  font-size: clamp(1.5rem, 4vw, 3rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.stage-heading p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 700;
  text-transform: uppercase;
}

.word-field {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: visible;
  pointer-events: none;
}

.ingredient {
  position: absolute;
  --tone: 265 88% 66%;
  --glow: rgba(139, 98, 255, 0.36);
  display: grid;
  place-items: center;
  min-width: clamp(90px, 9vw, 132px);
  min-height: clamp(50px, 6vw, 70px);
  padding: 11px 16px;
  border: 3px solid hsl(var(--tone) / 0.54);
  border-radius: 8px;
  background:
    radial-gradient(circle at 26% 20%, rgba(255, 255, 255, 0.95), transparent 30%),
    linear-gradient(145deg, hsl(var(--tone) / 0.38), rgba(255, 255, 255, 0.88) 48%, rgba(242, 181, 53, 0.28)),
    #fff2a6;
  color: #24114d;
  box-shadow:
    0 10px 0 rgba(50, 19, 95, 0.18),
    0 0 22px var(--glow),
    inset 0 3px 0 rgba(255, 255, 255, 0.72),
    inset 0 -5px 0 rgba(50, 19, 95, 0.12);
  image-rendering: pixelated;
  overflow: hidden;
  touch-action: none;
  pointer-events: auto;
  user-select: none;
  transform: translate(-50%, -50%);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
  animation: floatStone 5.8s ease-in-out infinite, pulseIngredient 4.8s ease-in-out infinite;
  animation-delay: var(--float-delay);
}

.ingredient::before {
  content: "";
  position: absolute;
  inset: -36%;
  background: linear-gradient(110deg, transparent 36%, rgba(255, 255, 255, 0.78) 48%, transparent 60%);
  opacity: 0;
  transform: translateX(-42%) rotate(10deg);
  transition:
    opacity 160ms ease,
    transform 500ms ease;
}

.ingredient::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 10px;
  width: 7px;
  height: 7px;
  background: hsl(var(--tone) / 0.86);
  box-shadow:
    14px 11px 0 -2px hsl(var(--tone) / 0.44),
    -18px 24px 0 -2px rgba(255, 255, 255, 0.82),
    0 0 16px hsl(var(--tone) / 0.78);
  opacity: 0.72;
}

.ingredient span {
  position: relative;
  z-index: 1;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  font-weight: 700;
  line-height: 0.95;
}

.ingredient small {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  color: rgba(36, 17, 77, 0.55);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ingredient.used {
  border-color: hsl(var(--tone) / 0.78);
  filter: saturate(1.18);
  box-shadow:
    0 10px 0 rgba(50, 19, 95, 0.16),
    0 0 34px var(--glow),
    0 0 68px hsl(var(--tone) / 0.16),
    inset 0 3px 0 rgba(255, 255, 255, 0.74),
    inset 0 -5px 0 rgba(50, 19, 95, 0.1);
}

.ingredient:hover {
  filter: saturate(1.2) brightness(1.04);
  box-shadow:
    0 12px 0 rgba(50, 19, 95, 0.16),
    0 0 42px var(--glow),
    inset 0 3px 0 rgba(255, 255, 255, 0.78),
    inset 0 -5px 0 rgba(50, 19, 95, 0.1);
}

.ingredient:hover::before,
.ingredient.dragging::before {
  opacity: 0.86;
  transform: translateX(42%) rotate(10deg);
}

.ingredient.dragging {
  z-index: 9;
  animation-play-state: paused;
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.04);
  box-shadow:
    0 16px 0 rgba(50, 19, 95, 0.14),
    0 0 54px var(--glow),
    0 0 110px hsl(var(--tone) / 0.2),
    inset 0 3px 0 rgba(255, 255, 255, 0.8),
    inset 0 -5px 0 rgba(50, 19, 95, 0.1);
}

.word-spark {
  position: absolute;
  z-index: 8;
  width: 8px;
  height: 8px;
  background: hsl(var(--tone) / 0.82);
  box-shadow:
    0 0 16px hsl(var(--tone) / 0.7),
    10px -7px 0 -3px rgba(255, 255, 255, 0.9),
    -9px 9px 0 -3px hsl(var(--tone) / 0.42);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: sparkFade 720ms ease-out forwards;
}

@keyframes floatStone {
  50% {
    transform: translate(-50%, calc(-50% - 9px)) translateX(var(--drift));
  }
}

@keyframes pulseIngredient {
  50% {
    box-shadow:
      0 10px 0 rgba(50, 19, 95, 0.14),
      0 0 32px var(--glow),
      inset 0 3px 0 rgba(255, 255, 255, 0.76),
      inset 0 -5px 0 rgba(50, 19, 95, 0.1);
  }
}

@keyframes sparkFade {
  to {
    opacity: 0;
    transform: translate(-50%, -190%) scale(0.2);
  }
}

.word-count {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 3;
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: 10px 12px;
  border: 3px solid rgba(50, 19, 95, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink-soft);
  text-align: center;
  text-transform: uppercase;
}

.word-count strong {
  color: #32135f;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 2.4rem;
  line-height: 0.85;
}

.word-count span {
  font-size: 0.72rem;
  font-weight: 820;
}

.duel-stage {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px minmax(0, 1fr);
  gap: clamp(12px, 2vw, 22px);
  width: min(1180px, calc(100% - 32px));
  margin: 20px auto 0;
}

.story-column {
  min-width: 0;
  padding: clamp(14px, 2vw, 20px);
  border: 4px solid rgba(50, 19, 95, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.38),
    0 18px 42px rgba(52, 48, 105, 0.1);
  backdrop-filter: blur(6px);
}

.column-heading {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin-bottom: 12px;
}

.column-heading h2,
.final-story h2 {
  margin: 0;
  color: #32135f;
  font-size: 1.35rem;
  text-transform: uppercase;
}

.column-heading time {
  color: #32135f;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 1.2rem;
  font-weight: 700;
}

.spark {
  width: 12px;
  height: 12px;
  background: var(--violet);
  box-shadow: 0 0 18px var(--violet);
}

.spark.model {
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(41, 219, 232, 0.7);
}

textarea,
.model-output {
  width: 100%;
  min-height: clamp(210px, 26vh, 340px);
  padding: 14px;
  border: 3px solid rgba(50, 19, 95, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  font-size: clamp(1rem, 1.45vw, 1.16rem);
  line-height: 1.58;
}

textarea {
  resize: vertical;
}

textarea::placeholder,
.model-output {
  color: rgba(23, 21, 43, 0.5);
}

textarea:focus {
  border-color: rgba(35, 81, 196, 0.7);
  outline: 3px solid rgba(41, 219, 232, 0.22);
}

textarea.attention {
  animation: attention 520ms ease;
}

@keyframes attention {
  40% {
    box-shadow: 0 0 0 4px rgba(230, 79, 145, 0.32);
  }
}

.model-output {
  overflow: auto;
  white-space: pre-wrap;
}

.story-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 24px;
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 820;
  text-transform: uppercase;
}

.story-meta .over,
#user-word-count.over {
  color: #b9154c;
}

.versus-mark {
  display: grid;
  place-items: center;
  align-self: center;
  width: 54px;
  height: 54px;
  border: 4px solid rgba(50, 19, 95, 0.5);
  border-radius: 8px;
  background: rgba(255, 244, 177, 0.82);
  color: #32135f;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
}

.brew-actions {
  position: relative;
  z-index: 3;
  margin: 20px auto 34px;
}

.results-screen {
  padding-bottom: 42px;
}

.final-nav {
  margin-bottom: 28px;
}

.result-hero {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
  padding: 18px;
  border: 4px solid rgba(50, 19, 95, 0.5);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  text-align: center;
}

.result-hero h1 {
  margin: 8px 0;
  color: #32135f;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.92;
  text-transform: uppercase;
}

.judge-summary {
  width: min(760px, 92%);
  margin: 0 auto 14px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.result-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.result-words span {
  padding: 7px 11px;
  border: 2px solid rgba(50, 19, 95, 0.24);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 1rem;
}

.result-words span.used {
  border-color: rgba(35, 81, 196, 0.5);
  color: var(--ink);
  box-shadow: 0 0 18px rgba(41, 219, 232, 0.18);
}

.score-grid,
.final-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 24px);
  width: min(1080px, calc(100% - 32px));
  margin: 22px auto 0;
}

.score-card,
.final-story {
  min-width: 0;
  padding: 18px;
  border: 4px solid rgba(50, 19, 95, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 18px 42px rgba(52, 48, 105, 0.1);
}

.score-card h2 {
  margin: 0;
  color: #32135f;
  font-size: 1.5rem;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  margin: 4px 0 12px;
  color: var(--gold-deep);
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: 4rem;
  line-height: 0.9;
}

.score-card dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.score-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}

.score-card dt {
  color: var(--ink-soft);
  font-weight: 800;
}

.score-card dd {
  margin: 0;
  color: #32135f;
  font-weight: 900;
}

.score-card p,
.final-story p {
  margin: 14px 0 0;
  color: #252348;
  line-height: 1.65;
  white-space: pre-wrap;
}

.score-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.info-dialog {
  width: min(700px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.info-dialog::backdrop {
  background: rgba(17, 18, 38, 0.56);
  backdrop-filter: blur(5px);
}

.info-dialog article {
  position: relative;
  width: 100%;
  padding: clamp(22px, 4vw, 34px);
  overflow: hidden;
}

.info-dialog .icon-button {
  position: absolute;
  right: 14px;
  top: 14px;
}

.info-dialog h2 {
  margin: 0 46px 14px 0;
  color: #32135f;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(2rem, 5.2vw, 3.5rem);
  line-height: 0.9;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.info-dialog p {
  margin: 12px 0 0;
  color: #252348;
  font-size: 1.05rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .setup-grid,
  .duel-stage,
  .score-grid,
  .final-grid {
    grid-template-columns: 1fr;
  }

  .versus-mark {
    justify-self: center;
  }

  .menu-actions {
    flex-direction: column;
    width: min(330px, 70vw);
    margin-bottom: clamp(8px, 1.6vh, 20px);
    transform: translateY(clamp(3px, 1vh, 10px));
  }

  .image-button,
  .image-button.info-button {
    width: min(280px, 68vw);
    height: min(104px, 24vw);
  }
}

@media (max-width: 640px) {
  .screen {
    padding: 12px;
  }

  .game-screen,
  .results-screen {
    padding: 0;
  }

  .word-stage,
  .duel-stage,
  .result-hero,
  .score-grid,
  .final-grid {
    width: calc(100% - 20px);
  }

  .word-stage {
    min-height: 520px;
  }

  .ingredient {
    min-width: 86px;
    min-height: 48px;
    padding: 10px 12px;
  }

  .setup-actions,
  .brew-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
