:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #151821;
  --panel-2: #1d2230;
  --panel-3: #242a38;
  --text: #f7f7fb;
  --muted: #9aa3b4;
  --line: rgba(255, 255, 255, 0.12);
  --cyan: #2df7c8;
  --pink: #ff4fd8;
  --yellow: #ffe15a;
  --orange: #ff7a3d;
  --violet: #7c5cff;
  --green: #8cff4d;
  --danger: #ff5a6f;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.shell {
  width: min(100%, 1160px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.view {
  min-height: calc(100dvh - 34px);
}

.login-view,
.play-view {
  max-width: 680px;
  margin: 0 auto;
}

.is-hidden {
  display: none !important;
}

.login-view {
  display: grid;
  align-content: center;
  gap: 18px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  gap: 8px;
  width: max-content;
  margin: 0 auto 2px;
}

.brand-mark span {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.brand-mark span:nth-child(1) {
  background: var(--cyan);
  border-radius: 50%;
}

.brand-mark span:nth-child(2) {
  background: var(--pink);
  border-radius: var(--radius);
}

.brand-mark span:nth-child(3) {
  background: var(--yellow);
  border-radius: var(--radius);
}

.brand-mark span:nth-child(4) {
  background: var(--orange);
  border-radius: 50%;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 2.8rem;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.tagline {
  color: var(--yellow);
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.login-form {
  display: grid;
  gap: 14px;
  width: 100%;
  padding: 18px;
  background: rgba(25, 25, 34, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  background: #101014;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
}

.login-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45, 247, 200, 0.16);
}

.primary-button,
.restart-button,
.control-button {
  min-height: 48px;
  border-radius: var(--radius);
  font-weight: 900;
  text-transform: uppercase;
}

.primary-button {
  background: var(--cyan);
  color: #071210;
}

.form-message {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.studio-form .form-message {
  color: var(--cyan);
  text-align: left;
}

.topbar,
.gamebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 16px;
}

.topbar {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 44px;
}

.topbar-copy {
  min-width: 0;
}

.topbar-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 6px;
  max-width: 220px;
}

.topbar-status span,
.credit-button {
  min-height: 30px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.credit-button {
  background: var(--yellow);
  color: #171306;
}

.topbar-status strong {
  color: var(--yellow);
}

.gamebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.eyebrow,
.gamebar-title p {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar h2,
.gamebar-title h2 {
  margin-top: 2px;
  font-size: 1.65rem;
  line-height: 1.08;
}

.topbar h2 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 900;
}

.sound-icon {
  display: block;
  position: relative;
  width: 22px;
  height: 20px;
}

.sound-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 6px;
  width: 8px;
  height: 8px;
  background: currentColor;
  clip-path: polygon(0 25%, 42% 25%, 100% 0, 100% 100%, 42% 75%, 0 75%);
}

.sound-icon::after {
  content: "";
  position: absolute;
  right: 0;
  top: 3px;
  width: 10px;
  height: 14px;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 14px 14px 0;
}

.icon-button.is-muted .sound-icon::after {
  width: 16px;
  height: 2px;
  top: 9px;
  right: 0;
  background: currentColor;
  border: 0;
  border-radius: 2px;
  transform: rotate(-35deg);
}

.market-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.market-tab {
  min-height: 42px;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.market-tab.is-active {
  background: var(--text);
  color: #101014;
}

.market-message {
  min-height: 22px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.market-message--ok {
  color: var(--cyan);
}

.market-message--warn {
  color: var(--yellow);
}

.market-panel {
  display: grid;
  gap: 14px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  margin-top: 2px;
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  line-height: 1.05;
}

.section-count {
  flex: 0 0 auto;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-grid,
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.game-card {
  display: grid;
  gap: 13px;
  min-height: 220px;
  padding: 15px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 46%),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.game-card::after {
  content: "";
  position: absolute;
  right: -18px;
  top: 54px;
  width: 88px;
  height: 88px;
  background: var(--shape);
  border: 8px solid rgba(255, 255, 255, 0.13);
  opacity: 0.72;
  transform: rotate(12deg);
}

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

.card-topline,
.card-meta,
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-topline span,
.card-topline strong,
.card-meta span {
  min-width: 0;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card-topline span {
  color: color-mix(in srgb, var(--accent) 74%, white);
}

.card-topline strong {
  padding: 5px 7px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  color: var(--text);
}

.game-card h4 {
  align-self: end;
  max-width: 75%;
  font-size: 1.48rem;
  line-height: 1;
  text-transform: uppercase;
}

.game-card p {
  max-width: 82%;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.28;
}

.card-meta {
  align-self: end;
  color: var(--muted);
}

.card-actions {
  align-self: end;
}

.card-action,
.ghost-action {
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.card-action {
  background: var(--cyan);
  color: #071210;
}

.card-action--buy {
  background: var(--yellow);
  color: #171306;
}

.ghost-action {
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid var(--line);
  color: var(--text);
}

.library-card,
.draft-card,
.project-card,
.studio-form,
.agent-board,
.empty-state {
  background: rgba(21, 24, 33, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.library-card {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 14px;
}

.offline-dot {
  width: 10px;
  height: 10px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(45, 247, 200, 0.12);
}

.library-card h4,
.draft-card h4,
.project-card h4 {
  font-size: 1rem;
  line-height: 1.12;
  text-transform: uppercase;
}

.library-card p,
.draft-card p,
.project-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.35;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 12px;
}

.studio-form {
  display: grid;
  gap: 13px;
  padding: 15px;
}

.prompt-field {
  display: grid;
  gap: 8px;
}

.prompt-field span,
.complexity-field legend {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.prompt-field textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  padding: 12px;
  background: #0c0e13;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  line-height: 1.35;
  outline: none;
}

.prompt-field textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(45, 247, 200, 0.14);
}

.complexity-field {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.complexity-field legend {
  grid-column: 1 / -1;
  padding: 0;
}

.complexity-field label {
  cursor: pointer;
}

.complexity-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.complexity-field span {
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.complexity-field strong {
  font-size: 0.82rem;
  line-height: 1.1;
}

.complexity-field em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.complexity-field input:checked + span {
  background: rgba(45, 247, 200, 0.12);
  border-color: color-mix(in srgb, var(--cyan) 64%, var(--line));
}

.agent-board {
  padding: 15px;
}

.agent-board ol {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.agent-board li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
}

.agent-board li > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
}

.agent-board li.is-complete > span {
  background: var(--cyan);
  color: #071210;
}

.agent-board strong {
  display: block;
  font-size: 0.86rem;
  line-height: 1.1;
}

.agent-board em,
.agent-board small {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
}

.agent-board small {
  text-transform: uppercase;
}

.project-list,
.draft-list {
  display: grid;
  gap: 10px;
}

.project-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.project-card__head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.project-card__head span,
.project-card__head strong {
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 950;
  text-transform: uppercase;
}

.project-card__head strong {
  flex: 0 0 auto;
  padding: 6px 8px;
  background: rgba(45, 247, 200, 0.1);
  border: 1px solid rgba(45, 247, 200, 0.22);
  border-radius: var(--radius);
}

.project-swatches {
  display: flex;
  gap: 6px;
}

.project-swatches i {
  width: 22px;
  height: 22px;
  background: var(--swatch);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
}

.project-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.project-columns em {
  display: block;
  margin-bottom: 6px;
  color: var(--yellow);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 950;
  text-transform: uppercase;
}

.project-columns ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.draft-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.draft-card span {
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 950;
  text-transform: uppercase;
}

.draft-card strong {
  flex: 0 0 auto;
  padding: 6px 8px;
  background: rgba(255, 225, 90, 0.12);
  border: 1px solid rgba(255, 225, 90, 0.24);
  border-radius: var(--radius);
  color: var(--yellow);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.empty-state {
  min-height: 88px;
  padding: 22px 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.score-strip span {
  min-height: 38px;
  padding: 9px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.score-strip strong {
  color: var(--text);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: min(62dvh, 620px);
  min-height: 430px;
  overflow: hidden;
  background: #050507;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.32);
}

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

.restart-button {
  position: absolute;
  left: 50%;
  bottom: 18px;
  min-width: 128px;
  padding: 0 16px;
  background: var(--yellow);
  color: #171306;
  transform: translateX(-50%);
}

.feedback-toast {
  position: absolute;
  left: 50%;
  top: 18px;
  z-index: 2;
  min-width: 116px;
  padding: 8px 12px;
  background: rgba(16, 16, 20, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
  animation: feedback-pop 760ms ease both;
  pointer-events: none;
}

.feedback-toast--level,
.feedback-toast--record {
  color: #071210;
  background: var(--yellow);
}

.feedback-toast--hurt,
.feedback-toast--over {
  background: var(--danger);
  color: #180407;
}

@keyframes feedback-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.92);
  }

  16%,
  76% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.96);
  }
}

.controls {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 16px;
  min-height: 106px;
  padding-top: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.control-pad {
  display: grid;
  gap: 7px;
  position: relative;
}

.control-pad--pair {
  grid-template-columns: repeat(2, 78px);
  grid-template-rows: 62px;
}

.control-pad--dpad {
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 48px);
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
}

.control-center {
  grid-area: center;
  align-self: center;
  justify-self: center;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.control-button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22);
  touch-action: none;
}

.control-pad--dpad .control-button[data-control="up"] {
  grid-area: up;
}

.control-pad--dpad .control-button[data-control="down"] {
  grid-area: down;
}

.control-pad--dpad .control-button[data-control="left"] {
  grid-area: left;
}

.control-pad--dpad .control-button[data-control="right"] {
  grid-area: right;
}

.control-button--action {
  width: 78px;
  height: 78px;
  align-self: center;
  background: color-mix(in srgb, var(--pink) 34%, var(--panel-2));
}

.control-icon {
  display: block;
  position: relative;
  width: 24px;
  height: 24px;
}

.control-button[data-control="up"] .control-icon::before,
.control-button[data-control="down"] .control-icon::before,
.control-button[data-control="left"] .control-icon::before,
.control-button[data-control="right"] .control-icon::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-top: 4px solid currentColor;
  border-left: 4px solid currentColor;
}

.control-button[data-control="up"] .control-icon::before {
  transform: translateY(4px) rotate(45deg);
}

.control-button[data-control="down"] .control-icon::before {
  transform: translateY(-4px) rotate(225deg);
}

.control-button[data-control="left"] .control-icon::before {
  transform: translateX(4px) rotate(-45deg);
}

.control-button[data-control="right"] .control-icon::before {
  transform: translateX(-4px) rotate(135deg);
}

.control-button[data-control="fire"] .control-icon {
  width: 30px;
  height: 30px;
  border: 3px solid currentColor;
  border-radius: 50%;
}

.control-button[data-control="fire"] .control-icon::after {
  content: "";
  position: absolute;
  inset: 8px;
  background: currentColor;
  border-radius: 50%;
}

.control-button.is-active {
  background: var(--cyan);
  color: #071210;
  transform: translateY(2px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

@media (min-width: 560px) {
  .shell {
    padding-top: 26px;
  }

  .login-form {
    width: 420px;
    margin: 0 auto;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .topbar-status {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: start;
    max-width: none;
  }

  .topbar .icon-button {
    grid-column: 2;
    grid-row: 1;
  }

  .game-grid,
  .library-grid,
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .shell {
    padding-inline: 12px;
  }

  .market-tabs {
    gap: 4px;
  }

  .market-tab {
    min-height: 40px;
    font-size: 0.72rem;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .section-count {
    align-self: start;
  }

  .game-card {
    min-height: 210px;
  }

  .game-card h4 {
    max-width: 78%;
    font-size: 1.34rem;
  }

  .card-actions,
  .draft-card {
    align-items: stretch;
    flex-direction: column;
  }

  .card-action,
  .ghost-action {
    width: 100%;
  }

  .library-card {
    grid-template-columns: 12px minmax(0, 1fr);
  }

  .library-card .card-action {
    grid-column: 1 / -1;
  }

  .complexity-field {
    grid-template-columns: 1fr;
  }

  .project-card__head,
  .project-columns {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .agent-board li {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .agent-board small {
    grid-column: 2;
  }
}

@media (max-height: 700px) {
  .canvas-wrap {
    height: 56dvh;
    min-height: 340px;
  }

  .controls {
    min-height: 90px;
  }

  .control-pad--dpad {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 42px);
  }

  .control-pad--pair {
    grid-template-columns: repeat(2, 74px);
    grid-template-rows: 52px;
  }

  .control-button--action {
    width: 68px;
    height: 68px;
  }
}
