/* Dark navy, police blue, paperwork white and warning yellow: a government
   system built around one very narrow objective. */
:root {
  --bg: #0d1626;
  --panel: #15223a;
  --panel-hover: #1c2d4b;
  --border: #2a3c5e;
  --police: #2f5d9e;
  --paper: #f1ede2;
  --fg: #e9ecf2;
  --muted: #95a1b8;
  --accent: #f2c230;
  --alert: #c0392b;
  --title-red: #e74c3c;
  --title-orange: #f0882a;
}

/* Only the title uses it. Self-hosted rather than from Google Fonts, so the
   page makes no third-party request. The Latin subset covers å, ä and ö;
   swap keeps the title readable in the system font while it loads. */
@font-face {
  font-family: 'Rubik Wet Paint';
  src: url('../assets/fonts/RubikWetPaint-Regular.woff2') format('woff2');
  font-display: swap;
}

* {
  box-sizing: border-box;
}

/* The painting sits far behind a navy veil: there for the mood, never in the
   way of the numbers. */
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgb(13 22 38 / 0.9), rgb(13 22 38 / 0.9)),
    url('../assets/images/skriet_hela.jpg') center / cover fixed,
    var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
}

/* minmax(0, …) everywhere: a plain 1fr track grows to fit its widest
   unbreakable content (a long cost like "676,00 miljoner"), and on a phone
   that pushes the page wider than the screen. */
#game {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 760px) {
  #game {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    padding: 32px 16px;
  }
}

/* News ticker: a newspaper strip across the top */

.ticker {
  display: flex;
  grid-column: 1 / -1;
  overflow: hidden;
  border-top: 3px solid var(--alert);
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  color: #1d2433;
}

.ticker-label {
  flex: none;
  padding: 8px 12px;
  background: var(--alert);
  color: var(--paper);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-text {
  display: inline-block;
  padding: 8px 12px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.9rem;
  font-weight: 700;
}

/* With reduced motion the headline sits still, so a long one wraps instead
   of running off the edge. */
@media (prefers-reduced-motion: reduce) {
  .ticker-track {
    white-space: normal;
  }
}

/* Collector: counter and the cup */

.collector {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Red, orange and yellow like the sunset in the painting. Brighter than
   --alert so the red stays readable on the navy. */
h1 {
  margin: 0;
  color: var(--accent);
  font-family: 'Rubik Wet Paint', system-ui, sans-serif;
  font-size: 2.4rem;
  font-weight: 400;
}

.title-ur {
  color: var(--title-red);
}

.title-in {
  color: var(--title-orange);
}

/* Quiet next to the title, so the dripping letters stay the eye-catcher. */
.subtitle {
  margin: 4px 0 16px;
  color: var(--muted);
  font-style: italic;
}

.count {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rate {
  margin: 4px 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cup-area {
  position: relative;
  margin: 24px 0 8px;
}

.cup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  /* No double-tap zoom on phones: rapid taps are the whole game. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  /* iOS ignores a cancelled contextmenu event: without this a long press
     still pops up the image callout, or selects the banner text. */
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 80ms ease-out;
}

.cup img {
  display: block;
  width: 200px;
  height: auto;
  user-select: none;
  filter: drop-shadow(0 8px 16px rgb(0 0 0 / 40%));
}

/* The officer's current reason for a test, styled like a police banner. */
.command {
  max-width: 280px;
  padding: 8px 14px;
  border: 2px solid var(--paper);
  border-radius: 4px;
  background: var(--police);
  color: var(--paper);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 0 #1d3d6c;
}

.cup:hover {
  transform: scale(1.04);
}

.cup:active {
  transform: scale(0.94);
}

.cup:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 8px;
  border-radius: 12px;
}

/* The "+1" that floats up from each click. */
.float {
  position: absolute;
  pointer-events: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 1.4rem;
  text-shadow: 0 2px 4px rgb(0 0 0 / 60%);
  animation: float-up 800ms ease-out forwards;
}

@keyframes float-up {
  from {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -260%);
  }
}

.stats {
  display: flex;
  gap: 24px;
  margin: 16px 0 0;
  font-variant-numeric: tabular-nums;
}

.stats dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.notice {
  max-width: 320px;
  margin: 8px 0 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

/* Events: a memo on the desk that wants an answer. */

.event {
  width: 100%;
  max-width: 420px;
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--alert);
  border-radius: 8px;
  background: var(--panel);
}

/* The screaming officer: every event is a situation. */
.event-art {
  float: right;
  width: 88px;
  height: auto;
  margin: 0 0 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.event-title {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.event-text {
  margin: 0 0 12px;
}

.event-choices {
  clear: both;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upgrade.choice {
  grid-template-columns: minmax(0, 1fr);
}

.event-timer,
.modifiers {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.modifiers {
  max-width: 420px;
}

/* Policy panels: grounds for suspicion and resource diversion */

.policy {
  align-self: stretch;
  margin-top: 32px;
  text-align: left;
}

.policy h2 {
  margin: 0;
  font-size: 1.2rem;
}

.policy-intro {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.policy-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 6px;
  font-variant-numeric: tabular-nums;
}

.policy-summary dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.policy-summary dd {
  margin: 2px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.policy-summary div:last-child {
  text-align: right;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--border);
}

.bar-fill {
  height: 100%;
  background: var(--police);
  transition: width 200ms ease-out;
}

.trust-bar,
.liberties-bar {
  margin-bottom: 16px;
}

/* Trust and liberties are the cost: the bar turns red as they fall. */
.bar.low .bar-fill {
  background: var(--alert);
}

.policy-note {
  margin: -8px 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* A ground for suspicion is a form like an upgrade, stamped in red. */
.upgrade.ground {
  border-left-color: var(--alert);
}

.ground .upgrade-effect {
  color: var(--alert);
}

.policy h3 {
  margin: 0;
  font-size: 1rem;
}

/* The PR campaign sits between the trust meter and the departments. */
.upgrade.campaign {
  margin-bottom: 16px;
}

/* Oversight is a form too, stamped in police blue. */
.upgrade.oversight {
  border-left-color: var(--police);
}

.department-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.department {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.department-name {
  font-weight: 700;
}

.department-description {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.85rem;
}

.department-controls {
  grid-row: span 2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.department-controls button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-hover);
  color: var(--fg);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.department-controls button:hover:enabled {
  border-color: var(--accent);
}

.department-controls button:disabled {
  cursor: default;
  opacity: 0.35;
}

.department-capacity {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.department-capacity .bar {
  flex: 1;
  height: 6px;
}

/* Shop */

.shop h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.shop-list,
.upgrade-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upgrade-list {
  margin-bottom: 24px;
}

/* Upgrades are paperwork: off-white forms on the navy desk. */
.upgrade {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--paper);
  border-left: 6px solid var(--accent);
  border-radius: 6px;
  background: var(--paper);
  color: #1d2433;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.upgrade:hover:enabled {
  border-left-color: var(--police);
}

.upgrade:disabled {
  cursor: default;
  opacity: 0.6;
}

.upgrade-icon {
  grid-row: span 3;
  font-size: 1.6rem;
  line-height: 1;
}

.upgrade-name {
  font-weight: 700;
}

.upgrade-cost {
  grid-row: span 3;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.upgrade-effect {
  color: var(--police);
  font-size: 0.9rem;
  font-weight: 600;
}

.upgrade-description {
  color: #5b6478;
  font-size: 0.85rem;
}

.producer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.producer:hover:enabled {
  background: var(--panel-hover);
  border-color: var(--accent);
}

.producer:disabled {
  cursor: default;
  opacity: 0.6;
}

.producer-icon {
  grid-row: span 3;
  align-self: center;
  font-size: 1.8rem;
  line-height: 1;
}

.producer-name {
  font-weight: 700;
}

.producer-owned {
  grid-row: span 2;
  align-self: center;
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.producer-description,
.producer-stats {
  color: var(--muted);
  font-size: 0.9rem;
}

.producer-stats {
  grid-column: 2 / -1;
  font-variant-numeric: tabular-nums;
}
.reset {
  margin-top: 24px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.reset:hover {
  color: var(--fg);
  border-color: var(--muted);
}

/* Save code: a quiet panel at the bottom of the shop, like "Börja om". */

.save-code {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

.save-code summary {
  cursor: pointer;
}

.save-code-intro {
  margin: 8px 0;
}

.save-code textarea {
  display: block;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--fg);
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  resize: vertical;
}

.save-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.save-code-actions .reset {
  margin-top: 8px;
}

.save-code-status {
  min-height: 1.2em;
  margin: 8px 0 0;
}

.version {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Storage consent: asked before anything is saved. Both answers look the
   same and neither has focus, so the dialog doesn't lean towards yes. */

.consent {
  max-width: min(420px, calc(100vw - 32px));
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
}

.consent::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.consent h2 {
  margin-top: 0;
  font-size: 1.2rem;
}

.consent p {
  color: var(--muted);
  line-height: 1.4;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.consent-choice {
  padding: 8px 20px;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--panel-hover);
  color: var(--fg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.consent-choice:hover {
  border-color: var(--fg);
}

.consent:focus {
  outline: none;
}
