:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #b9c2d0;
  --panel: rgba(13, 19, 33, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #f7c948;
  --leaf: #43c46b;
  --sky: #66d9ff;
  --danger: #fb5270;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(102, 217, 255, 0.22), transparent 30%),
    linear-gradient(135deg, #121826 0%, #1f2638 43%, #24301f 100%);
}

.game-shell {
  width: min(1120px, 100%);
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--sky);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 54px);
  line-height: 0.95;
}

.subtitle {
  margin: 4px 0 0;
  font-family: "Brush Script MT", "Segoe Script", "Comic Sans MS", cursive;
  font-size: clamp(18px, 2.6vw, 28px);
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #f7c948, #fb7185, #66d9ff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #f7c948;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.hud span,
.controls span,
.levelbar span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
}

.levelbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.levelbar span {
  flex: 1 1 230px;
}

.levelbar span:last-child {
  justify-content: flex-end;
  color: var(--gold);
}

.icon-button {
  width: 38px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
}

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

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101827;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  image-rendering: pixelated;
}

.message {
  position: absolute;
  inset: auto 20px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(8, 13, 24, 0.88);
  color: var(--ink);
  font-size: 15px;
}

.message-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message.is-hidden {
  display: none;
}

/* Duzy monit na koniec kampanii */
.message.is-final {
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 28px;
  background: radial-gradient(circle at 50% 30%, rgba(247, 201, 72, 0.18), transparent 60%),
    rgba(8, 13, 24, 0.94);
}

.message.is-final .message-copy {
  align-items: center;
  gap: 10px;
  max-width: 620px;
}

.final-title {
  font-size: clamp(30px, 6vw, 56px);
  color: var(--gold);
  text-shadow: 0 4px 22px rgba(247, 201, 72, 0.45);
  animation: finalpop 0.8s ease-out;
}

.final-sub {
  font-size: clamp(16px, 3vw, 24px);
  color: var(--sky) !important;
  font-weight: 800;
}

.message.is-final .menu-actions {
  justify-content: center;
}

@keyframes finalpop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

.message strong {
  color: var(--gold);
}

.message span {
  color: var(--muted);
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.menu-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.menu-actions button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.17);
}

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

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
