:root {
  --ink: #171717;
  --paper: #f9f1df;
  --panel: #fff7e6;
  --panel-strong: #ffd166;
  --line: #2b2b2b;
  --blue: #2563eb;
  --blue-dark: #1746a2;
  --red: #e11d48;
  --green: #16a34a;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #1f2937;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
}

button {
  font: inherit;
}

.game-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(32, 48, 69, 0.8), rgba(13, 19, 33, 0.95)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 90px);
}

.game-shell {
  position: relative;
  width: min(96vw, 960px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 4px solid #0f172a;
  background: #9fd5ff;
  box-shadow: 0 24px 70px var(--shadow);
}

#gameCanvas,
#winCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  pointer-events: none;
}

.hud-title,
.hud-counter,
.nearby-prompt {
  border: 3px solid var(--line);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--line);
}

.hud-title {
  padding: 8px 10px;
  font-size: 16px;
  font-weight: 700;
  color: #15315c;
}

.hud-counter {
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 700;
}

.nearby-prompt {
  position: absolute;
  left: 50%;
  bottom: 154px;
  transform: translateX(-50%);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #101010;
  pointer-events: none;
}

.dialog-box {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  min-height: 128px;
  padding: 14px 156px 14px 18px;
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--line);
}

.dialog-speaker {
  margin-bottom: 4px;
  color: #1746a2;
  font-size: 17px;
  font-weight: 700;
}

.dialog-label {
  margin-bottom: 8px;
  color: #8a3ffc;
  font-size: 14px;
  font-weight: 700;
}

.dialog-text {
  margin: 0;
  max-height: 62px;
  overflow: auto;
  font-size: 15px;
  line-height: 1.35;
}

.dialog-box .primary-button {
  position: absolute;
  right: 16px;
  bottom: 16px;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  border: 3px solid var(--line);
  color: #111111;
  box-shadow: 3px 3px 0 var(--line);
  cursor: pointer;
}

.primary-button {
  padding: 8px 14px;
  background: var(--panel-strong);
  font-weight: 700;
}

.secondary-button {
  padding: 8px 14px;
  background: #d9f99d;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  background: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--line);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:disabled:hover {
  transform: none;
  box-shadow: 3px 3px 0 var(--line);
}

.panel,
.fail-screen,
.win-screen {
  position: absolute;
  inset: 18px;
  z-index: 10;
  border: 4px solid var(--line);
  background: rgba(255, 247, 230, 0.98);
  box-shadow: 8px 8px 0 var(--line);
}

.panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.city-hall-panel {
  gap: 10px;
}

.panel-header,
.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header h1,
.panel-header p,
.docket-column h2,
.win-copy h1,
.win-copy p {
  margin: 0;
}

.panel-header h1 {
  font-size: 25px;
  color: #15315c;
}

.panel-header p {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 700;
}

.priority-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.priority-step {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 3px solid var(--line);
  background: #ffd166;
  box-shadow: 3px 3px 0 var(--line);
  font-size: 15px;
  font-weight: 700;
}

.chosen-order {
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow: auto;
  padding: 6px;
  border: 3px solid var(--line);
  background: #ffffff;
}

.chosen-chip {
  flex: 0 0 auto;
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 7px;
  border: 2px solid var(--line);
  background: #d9f99d;
  font-size: 12px;
  font-weight: 700;
}

.choice-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 9px;
  margin-top: 0;
  padding: 10px;
  border: 3px solid var(--line);
  background: #ffffff;
}

.choice-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 54px;
  padding: 9px 10px;
  border: 3px solid var(--line);
  background: #e0f2fe;
  color: #111111;
  box-shadow: 3px 3px 0 var(--line);
  text-align: left;
  cursor: pointer;
}

.choice-card:hover,
.choice-card:focus {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--line);
}

.choice-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  background: #ffedd5;
  font-size: 13px;
  font-weight: 700;
}

.choice-label {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}

.choice-meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #475569;
}

.complaint-details {
  min-height: 52px;
  margin-top: 0;
  padding: 9px 10px;
  border: 3px solid var(--line);
  background: #fefce8;
  overflow: auto;
  font-size: 13px;
  line-height: 1.32;
}

.panel-actions {
  margin-top: 12px;
  justify-content: flex-end;
}

.city-hall-panel .panel-actions {
  margin-top: 0;
}

.fail-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  background: #ff0033;
  animation: panicFlash 0.18s infinite alternate;
}

.cuomo-image {
  width: min(760px, 88%);
  max-height: 66%;
  object-fit: cover;
  border: 4px solid #000000;
  box-shadow: 8px 8px 0 #000000;
}

.fail-text {
  padding: 8px 12px;
  border: 4px solid #000000;
  background: #ffffff;
  color: #000000;
  font-size: clamp(22px, 4vw, 42px);
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 5px 5px 0 #000000;
}

.fail-reason {
  padding: 5px 8px;
  border: 3px solid #000000;
  background: #fff7e6;
  color: #000000;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 3px 3px 0 #000000;
}

.fail-screen .primary-button {
  background: #ffffff;
}

.win-screen {
  display: grid;
  grid-template-columns: 1fr 0.9fr;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 246, 222, 0.96)),
    repeating-linear-gradient(0deg, rgba(37, 99, 235, 0.12) 0 12px, rgba(245, 122, 37, 0.14) 12px 24px);
}

.win-copy h1 {
  color: #1746a2;
  font-size: clamp(30px, 5vw, 58px);
  line-height: 1;
}

.win-copy {
  min-width: 0;
  padding-bottom: 54px;
  position: relative;
  z-index: 1;
}

.win-copy p {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

#winCanvas {
  width: min(100%, 500px);
  height: auto;
  justify-self: center;
}

.win-screen .primary-button {
  position: absolute;
  right: 20px;
  bottom: 18px;
}

@keyframes panicFlash {
  from {
    background: #ff0033;
    filter: contrast(1.4) saturate(1.4);
  }
  to {
    background: #8b0000;
    filter: contrast(1.9) saturate(2.2);
  }
}

@media (max-width: 760px) {
  .game-page {
    padding: 10px;
  }

  .hud {
    top: 10px;
    left: 10px;
    gap: 6px;
  }

  .hud-title,
  .hud-counter {
    padding: 6px 7px;
    font-size: 12px;
  }

  .dialog-box {
    left: 10px;
    right: 10px;
    bottom: 10px;
    min-height: 118px;
    padding: 10px 104px 10px 12px;
  }

  .dialog-text {
    font-size: 12px;
  }

  .dialog-box .primary-button {
    right: 10px;
    bottom: 10px;
  }

  .panel {
    inset: 10px;
    padding: 12px;
  }

  .priority-status {
    align-items: stretch;
    flex-direction: column;
    margin-top: 4px;
  }

  .choice-grid {
    grid-template-columns: 1fr 1fr;
    margin-top: 8px;
  }

  .chosen-order {
    min-height: 36px;
  }

  .win-screen {
    inset: 10px;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px;
  }

  .win-copy {
    position: absolute;
    top: 14px;
    left: 14px;
    max-width: 230px;
    padding-bottom: 0;
  }

  .win-copy h1 {
    font-size: 22px;
  }

  .win-copy p {
    display: none;
  }

  #winCanvas {
    width: 100%;
    max-height: calc(100% - 62px);
    height: auto;
    object-fit: contain;
  }
}
