:root {
  color-scheme: light;
  font-family: 'Courier New', 'Liberation Mono', monospace;
  color: #283b3c;
  background: #efe8d7;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #283b3c;
  --paper: #efe8d7;
  --muted: #72827a;
  --rust: #bf634d;
  --lilac: #8d7195;
  --green: #637b5d;
  --sun: #f1c453;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--paper); }

body { min-width: 320px; min-height: 100vh; min-height: 100svh; margin: 0; }

button, progress { font: inherit; }

.game {
  position: relative;
  isolation: isolate;
  display: flex;
  width: min(100%, 960px);
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding: max(15px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  flex-direction: column;
  overflow: hidden;
}

.game::before, .game::after {
  position: absolute;
  z-index: -1;
  content: '';
  pointer-events: none;
}

.game::before {
  inset: 0 13px auto;
  height: 5px;
  background: var(--rust);
  box-shadow: 0 5px 0 var(--sun);
}

.game::after {
  right: 0;
  bottom: 0;
  left: 0;
  height: 8px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 18px, transparent 18px 23px, var(--rust) 23px 29px, transparent 29px 37px);
  opacity: .88;
}

.masthead {
  display: flex;
  min-height: 53px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(40, 59, 60, .22);
}

.wordmark { display: flex; align-items: center; gap: 11px; min-width: 0; }

.wordmark-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--ink);
  background: var(--sun);
  box-shadow: 3px 3px 0 var(--rust);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -2px;
}

h1 { margin: 0; font-size: clamp(16px, 2.1vw, 20px); font-weight: 900; letter-spacing: -.8px; line-height: 1.1; }
h1 span { color: var(--rust); }

.round-badge { display: flex; align-items: center; gap: 7px; color: #66746e; font-size: 10px; font-weight: 800; letter-spacing: 1.1px; white-space: nowrap; }
.status-lamp { width: 8px; height: 8px; border-radius: 50%; background: #75a66d; box-shadow: 0 0 0 3px rgba(117, 166, 109, .15); }
.game[data-state='won'] .status-lamp { background: var(--sun); box-shadow: 0 0 0 3px rgba(241, 196, 83, .19); }
.game[data-state='won'] #round-label { color: #826c2d; }
.game[data-state='won'] progress::-webkit-progress-value { background: repeating-linear-gradient(90deg, #728850 0 13px, #8da269 13px 16px, #728850 16px 20px); }
.game[data-state='won'] progress::-moz-progress-bar { background: repeating-linear-gradient(90deg, #728850 0 13px, #8da269 13px 16px, #728850 16px 20px); }

.relief-panel {
  display: grid;
  gap: 7px;
  margin: 13px auto 0;
  width: min(100%, 490px);
}

.relief-heading, .relief-scale { display: flex; align-items: center; justify-content: space-between; }
.relief-heading { min-height: 20px; font-size: 11px; font-weight: 900; letter-spacing: 1.35px; }
.relief-heading > span:first-child { color: #697971; }
.relief-heading #relief-readout { color: var(--rust); font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.8px; }
.relief-heading #relief-readout span { margin-left: 2px; font-size: 12px; }

progress {
  display: block;
  width: 100%;
  height: 15px;
  overflow: hidden;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #d8d2c1;
  box-shadow: 2px 2px 0 rgba(40, 59, 60, .12);
}

progress::-webkit-progress-bar { background: #d8d2c1; }
progress::-webkit-progress-value { background: repeating-linear-gradient(90deg, #c56a50 0 13px, #d98059 13px 16px, #c56a50 16px 20px); transition: width .2s steps(4, end); }
progress::-moz-progress-bar { background: repeating-linear-gradient(90deg, #c56a50 0 13px, #d98059 13px 16px, #c56a50 16px 20px); }
.relief-scale { color: #738077; font-size: 10px; font-weight: 700; }
.goal-mark { display: inline-flex; align-items: center; gap: 5px; color: #bc8140; }
.goal-mark b { color: #728078; font-size: 9px; letter-spacing: .7px; }

.instructions {
  display: flex;
  min-height: 32px;
  margin: 6px 0 5px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #69766e;
  font-size: 13px;
  font-weight: 600;
}
.keycap { padding: 3px 5px; border: 1px solid rgba(40, 59, 60, .34); background: #f7f0e1; color: var(--ink); font-size: 10px; font-weight: 900; letter-spacing: .6px; }
.tiny-arrow { color: var(--rust); font-size: 15px; }
.desktop-hint { color: #849087; font-size: 11px; }

.tag-band {
  position: relative;
  display: flex;
  width: min(100%, 390px);
  min-height: 43px;
  margin: 1px auto 5px;
  padding: 8px 13px 10px 35px;
  align-items: center;
  border: 1px solid #d1c4a9;
  background: #f8f2e5;
  box-shadow: 3px 3px 0 rgba(40, 59, 60, .1);
  transition: transform .08s linear;
}
.tag-pin { position: absolute; left: 12px; top: 7px; color: var(--rust); font-size: 21px; line-height: 1; }
.tag-band p { width: 100%; margin: 0; color: #425354; font-size: 14px; font-weight: 700; line-height: 1.35; text-align: center; overflow-wrap: anywhere; }
.tag-tail { position: absolute; bottom: -6px; left: 50%; width: 10px; height: 10px; transform: translateX(-50%) rotate(45deg); border-right: 1px solid #d1c4a9; border-bottom: 1px solid #d1c4a9; background: #f8f2e5; }

.office-frame {
  position: relative;
  display: block;
  width: min(100%, 780px, calc((100svh - 238px) * 1.8));
  max-width: 100%;
  margin: 0 auto;
  padding: 7px;
  border: 2px solid var(--ink);
  background: #35494a;
  box-shadow: 5px 5px 0 rgba(40, 59, 60, .19);
}

#office {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 9 / 5;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  image-rendering: pixelated;
  cursor: crosshair;
}
.scene-rail { position: absolute; top: 50%; display: grid; width: 13px; height: 30px; place-items: center; transform: translateY(-50%); border: 1px solid rgba(239, 232, 215, .38); color: #ddd7c8; font-size: 5px; font-weight: 900; letter-spacing: .25px; line-height: 1.4; text-align: center; pointer-events: none; }
.scene-rail-left { left: 3px; }
.scene-rail-right { right: 3px; }
.feedback-slot { display: grid; min-height: 35px; flex: 0 0 auto; place-items: center; }
.result { margin: 0; color: var(--ink); font-size: 15px; font-weight: 900; letter-spacing: 1.7px; text-align: center; }
.result:empty { display: none; }
.game[data-result='Miss'] .result { color: #778078; }
.game[data-result='Träff'] .result { color: #bd724b; }
.game[data-result='Fullträff'] .result { color: #758647; }
.game[data-result='Du vann!'] .result { color: #8a6c2f; }

.footer { display: flex; min-height: 28px; margin-top: auto; padding-top: 10px; align-items: center; justify-content: space-between; gap: 12px; color: #879187; font-size: 8px; font-weight: 800; letter-spacing: .65px; }

.victory {
  position: relative;
  display: flex;
  min-height: 0;
  padding: 7px 10px 12px;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #8c7041;
  background: radial-gradient(ellipse at 50% 47%, #fff4ca, #f6e7bb 62%, #edd8a3 100%);
  box-shadow: inset 0 0 0 5px rgba(255, 250, 228, .55), 4px 4px 0 rgba(40, 59, 60, .17);
  text-align: center;
}
.victory[hidden] { display: none; }
.prize-label { color: #906c2c; font-size: 10px; font-weight: 900; letter-spacing: 2px; }
.prize-label span { color: #d09b43; }
.trophy { display: block; width: clamp(66px, 22svh, 128px); height: auto; margin: 5px 0; overflow: visible; filter: drop-shadow(4px 5px 0 rgba(92, 65, 75, .18)); }
.victory h2 { margin: 0; color: #a94e40; font-size: clamp(28px, 7vw, 40px); font-weight: 1000; letter-spacing: 4px; line-height: 1.05; text-shadow: 2px 2px 0 #f1c453; }
.victory-copy { margin: 4px 0 9px; color: #526052; font-size: 14px; line-height: 1.4; }
.victory-copy strong { color: #ad6343; font-size: 16px; }
.replay { position: relative; z-index: 2; min-height: 42px; padding: 8px 23px; border: 2px solid #283b3c; border-radius: 0; background: #637b5d; box-shadow: 4px 4px 0 #283b3c; color: #fff9e9; font-size: 13px; font-weight: 900; letter-spacing: 1.3px; cursor: pointer; touch-action: manipulation; }
.replay span { margin-right: 5px; color: #f4ca5a; font-size: 17px; vertical-align: -1px; }
.replay:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #283b3c; background: #526e4c; }
.replay:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #283b3c; }
.replay:focus-visible { outline: 3px solid #bf634d; outline-offset: 4px; }
.victory-note { margin: 10px 0 0; color: #8a8067; font-size: 9px; font-weight: 900; letter-spacing: 1.2px; }
.victory-note span { color: #c56a50; }
.confetti { position: absolute; inset: -15% 0; z-index: 0; pointer-events: none; }
.confetti::before, .confetti::after { position: absolute; top: -18px; left: var(--x); width: 8px; height: 13px; content: ''; background: var(--c); animation: confetti-fall var(--duration) steps(8, end) var(--delay) 2 both; }
.confetti-a { --x: 9%; --c: #c56a50; --duration: 1.15s; --delay: 0s; }
.confetti-a::after { left: 10%; --x: 49vw; --c: #637b5d; --duration: 1.25s; --delay: .12s; }
.confetti-b { --x: 81%; --c: #f1c453; --duration: 1.2s; --delay: .04s; }
.confetti-b::before { box-shadow: 42px 90px 0 #8d7195, -30px 175px 0 #bf634d, 56px 205px 0 #637b5d, -42px 260px 0 #f1c453; }
.confetti-b::after { left: 25%; --x: 21vw; --c: #e99a3c; --duration: 1.35s; --delay: .19s; box-shadow: 55px 70px 0 #bf634d, -35px 153px 0 #8d7195, 40px 248px 0 #c56a50; }
@keyframes confetti-fall { to { transform: translateY(125svh) rotate(360deg); } }

.game[data-state='won'] #instructions,
.game[data-state='won'] #tag-band,
.game[data-state='won'] #office-frame,
.game[data-state='won'] .feedback-slot { display: none; }
.game[data-state='won'] .victory:not([hidden]) { display: flex; }
.game[data-state='won'] .footer { flex-shrink: 0; }
.noscript { position: fixed; inset: 20px; z-index: 10; display: grid; padding: 22px; place-items: center; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 16px; font-weight: 700; text-align: center; }

@media (min-width: 780px) {
  .game { padding-inline: 36px; }
  .masthead { min-height: 61px; }
  .relief-panel { margin-top: 16px; }
  .tag-band { margin-top: 4px; margin-bottom: 9px; }
}

@media (max-width: 520px) {
  .game { padding-right: max(15px, env(safe-area-inset-right)); padding-left: max(15px, env(safe-area-inset-left)); }
  .masthead { min-height: 47px; }
  .wordmark { gap: 8px; }
  .round-badge { gap: 6px; font-size: 9px; letter-spacing: .6px; }
  .wordmark-icon { width: 29px; height: 29px; }
  .relief-panel { width: min(100%, 390px); margin-top: 8px; gap: 5px; }
  .instructions { min-height: 28px; margin-block: 3px; font-size: 12px; }
  .keycap { font-size: 10px; }
  .tag-band { width: min(100%, 390px); margin-top: 0; margin-bottom: 5px; }
  .office-frame { width: min(100%, calc((100svh - 204px) * 1.8)); padding: 5px; }
  .footer { font-size: 7px; letter-spacing: .2px; }
}

@media (max-width: 370px) {
  .round-badge { font-size: 8px; }
  .desktop-hint { display: none; }
  .instructions { gap: 5px; }
  .tag-band { min-height: 40px; padding-left: 30px; padding-right: 8px; }
  .tag-band p { font-size: 14px; }
  .footer span:last-child { display: none; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .game { min-height: 100svh; padding-top: max(7px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .masthead { min-height: 39px; }
  .relief-panel { width: min(100%, 410px); margin-top: 5px; gap: 3px; }
  .relief-heading { min-height: 16px; font-size: 10px; }
  .relief-heading #relief-readout { font-size: 16px; }
  progress { height: 12px; }
  .relief-scale { font-size: 9px; }
  .instructions { min-height: 22px; margin: 1px 0; font-size: 12px; }
  .tag-band { width: min(100%, 450px); min-height: 35px; margin: 1px auto 5px; padding-block: 5px 7px; }
  .office-frame { width: min(100%, calc((100svh - 194px) * 1.8)); }
  .office-frame { padding: 4px; }
  .feedback-slot { min-height: 21px; }
  .result { font-size: 13px; }
  .footer { min-height: 19px; padding-top: 4px; }
  .trophy { width: clamp(66px, 20svh, 96px); margin: 1px 0; }
  .prize-label { font-size: 9px; }
  .victory h2 { font-size: clamp(25px, 8vh, 34px); }
  .victory-copy { margin: 2px 0 6px; font-size: 14px; }
  .victory-copy strong { font-size: 15px; }
  .replay { min-height: 38px; padding-block: 6px; }
  .victory-note { margin-top: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .confetti::before, .confetti::after { animation-duration: .01s; animation-iteration-count: 1; }
}
