/* Das Wiesn-Spiel (spec §23). Spelet är en canvas i låg upplösning som skalas upp pixligt;
   all text runt omkring är vanlig DOM så att 200 %-kravet (spec §17) gäller den. */

.arcade-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #2a1d0e;
  color: #f8f4e8;
}

.arcade-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  flex-wrap: wrap;
  border-bottom: 0.125rem solid var(--gold);
}

.arcade-bar a {
  color: #f8f4e8;
  text-decoration: none;
  font-weight: 700;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}

.arcade-bar__title {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  margin: 0;
  font-weight: 400;
}

/* Smal skärm: raden får plats på en rad utan titeln, som finns kvar för skärmläsare (den stora titeln
   syns ändå i spelets startruta). */
@media (max-width: 34rem) {
  .arcade-bar__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

.arcade-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.arcade {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Kant­svepen på iPhone kan vi inte stoppa: en tunn marginal gör dem svårare att träffa av misstag. */
  padding: 0.25rem 0.5rem 0.5rem;
  box-sizing: border-box;
}

.arcade__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 24rem;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: #1b1a17;
  border-radius: 0.75rem;
  overflow: hidden;
}

.arcade__canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #3b2a12;
}

.arcade [hidden] { display: none !important; }

/* HUD: DOM-text ovanpå canvasen. */
.arcade__hud {
  position: absolute;
  top: 0.4rem;
  left: 0.5rem;
  right: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  justify-content: center;
  pointer-events: none;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  text-shadow: 0.0625rem 0.0625rem 0 #1b1a17, -0.0625rem 0 0 #1b1a17;
  color: #f8f4e8;
}

.hud__time { color: #f2c230; }
.hud__guard {
  color: #ff6a5a;
  animation: arcade-blink 0.5s steps(2) infinite;
}

@keyframes arcade-blink { to { opacity: 0.2; } }

@media (prefers-reduced-motion: reduce) {
  .hud__guard { animation: none; }
}

.hud__points { color: #4cc35a; }

/* Frågetecknet: pausar och förklarar. Uppe till vänster, ovanpå canvasen. */
.arcade__help {
  left: 0.35rem;
}

.arcade__hud { padding-left: 3rem; padding-right: 0.5rem; }

/* Vrid-knappen (bara på dator, arcade.js visar den): bredvid frågetecknet. */
.arcade__rotate {
  left: 3.4rem;
}

/* Knapparna på spelplanen: runda, i spelets knappfärger, med pixelritade ikoner. */
.arcade__iconbtn {
  position: absolute;
  top: 0.35rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 0.125rem solid var(--gold);
  background: #3b2a12;
  color: #f2c230;
  box-shadow: 0 0.1875rem 0 #1b1a17;
  cursor: pointer;
  z-index: 2;
}
.arcade__iconbtn svg { width: 55%; height: 55%; display: block; }
.arcade__iconbtn:hover { background: #4d3719; }
.arcade__iconbtn:active { transform: translateY(0.125rem); box-shadow: 0 0.0625rem 0 #1b1a17; }
.arcade__iconbtn:focus-visible { outline: 0.1875rem solid #f8f4e8; outline-offset: 0.125rem; }
.arcade__rotate[aria-pressed="true"] { background: var(--green); color: #f8f4e8; }
.arcade--desktop .arcade__hud { padding-left: 6.2rem; }

.arcade__panel--help {
  max-width: 26rem;
  text-align: left;
  max-height: 100%;
  overflow: auto;
}

.arcade__panel--help .arcade__title { text-align: center; }

.arcade__subtitle {
  font-family: "Barlow Condensed", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-size: 0.95em;
  margin: 0.9rem 0 0.35rem;
}

.arcade__help-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.arcade__help-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.3rem 0;
  border-bottom: 0.0625rem solid rgba(248, 244, 232, 0.12);
  line-height: 1.4;
}

.arcade__help-list--plain .arcade__help-item { padding: 0.2rem 0; border-bottom: none; }

.arcade__icon {
  width: 2.4rem;
  height: auto;
  flex: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  margin-top: 0.1rem;
}

/* Fast i kön: en rad under HUD:en. */
.arcade__hint-line {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  top: 2.6rem;
  margin: 0;
  text-align: center;
  font-size: 0.85em;
  line-height: 1.35;
  color: #f8f4e8;
  background: rgba(27, 26, 23, 0.7);
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  pointer-events: none;
}

/* Resultatets poängrader. */
.arcade__lines {
  margin: 0.5rem 0;
  text-align: left;
}

.arcade__line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0;
  border-bottom: 0.0625rem solid rgba(248, 244, 232, 0.15);
}

.arcade__line strong {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.1em;
  color: #f8f4e8;
}

.arcade__line--bad strong { color: #ff6a5a; }

.arcade__line--total {
  border-bottom: none;
  margin-top: 0.25rem;
  font-size: 1.1em;
}

.arcade__line--total strong {
  color: #f2c230;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.95em;
  font-weight: 400;
}

.arcade__live {
  position: absolute;
  width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Skärmarna: titel, namnval, resultat, game over. Rullar inuti om texten är stor. */
.arcade__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  box-sizing: border-box;
  overflow: auto;
  background: rgba(20, 12, 4, 0.35);
}

.arcade__overlay[data-screen="result"],
.arcade__overlay[data-screen="gameover"],
.arcade__overlay[data-screen="picker"] {
  background: rgba(20, 12, 4, 0.75);
}

.arcade__panel {
  background: rgba(27, 26, 23, 0.92);
  border: 0.1875rem solid var(--gold);
  border-radius: 0.5rem;
  padding: 1rem;
  max-width: 22rem;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 0 0 0.25rem #1b1a17;
  margin: auto;
}

.arcade__eyebrow {
  margin: 0 0 0.25rem;
  color: var(--gold);
  font-family: "Barlow Condensed", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.9em;
}

.arcade__title {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-weight: 400;
  color: #f2c230;
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 0.25rem 0 0.75rem;
  text-shadow: 0.1875rem 0.1875rem 0 #7d1f19;
  overflow-wrap: anywhere;
}

.arcade__title--small { font-size: 0.95rem; }

.arcade__blurb, .arcade__hint, .arcade__who, .arcade__best, .arcade__save {
  margin: 0.5rem 0;
  line-height: 1.45;
}

.arcade__hint { font-size: 0.9em; color: #d9c9a8; }
.arcade__best { color: #f2c230; }
.arcade__save { color: #d9c9a8; font-size: 0.95em; min-height: 1.4em; }
.arcade__record {
  font-family: "Press Start 2P", "Courier New", monospace;
  color: #4cc35a;
  font-size: 0.8rem;
  margin: 0.5rem 0;
  animation: arcade-blink 0.6s steps(2) infinite;
}

.arcade__big {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.6;
  color: #f8f4e8;
  margin: 0.25rem 0;
}

.arcade__mid { margin: 0.25rem 0 0.5rem; }

.arcade__score {
  font-size: 1.1em;
  margin: 0.5rem 0;
}

.arcade__score strong {
  color: #f2c230;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.95em;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.arcade__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  margin: 0.25rem;
  border: 0.125rem solid var(--gold);
  border-radius: 0.375rem;
  background: #3b2a12;
  color: #f8f4e8;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

.arcade__btn--primary {
  background: var(--green);
  border-color: #4cc35a;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  padding: 0.9rem 1.25rem;
  width: 100%;
  margin: 0.5rem 0;
}

.arcade__btn--small {
  font-size: 0.9em;
  padding: 0.35rem 0.75rem;
}

.arcade__link {
  background: none;
  border: none;
  color: #f2c230;
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
  padding: 0.25rem;
  min-height: 2.75rem;
}

.arcade__row, .arcade__util {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.arcade__util { border-top: 0.0625rem solid rgba(248, 244, 232, 0.2); padding-top: 0.5rem; }

/* Två banor på titelskärmen (bana 2 bara när den är öppen). */
.arcade__level {
  border: 0.125rem solid rgba(248, 244, 232, 0.35);
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin: 0.5rem 0;
  text-align: center;
}
.arcade__level--locked { opacity: 0.65; }
.arcade__level-title {
  margin: 0 0 0.25rem;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-weight: 400;
  font-size: 0.7rem;
  line-height: 1.6;
  color: #f2c230;
  overflow-wrap: anywhere;
}
.arcade__level-blurb { margin: 0 0 0.35rem; }
.arcade__level .arcade__best { margin: 0 0 0.35rem; }
.arcade__level .arcade__btn { margin-top: 0.25rem; }
.arcade__btn:disabled { opacity: 0.5; cursor: default; }
.arcade__practice { color: #ff6a5a; font-size: 0.9em; margin: 0.5rem 0 0; }

/* Pratbubblorna på bana 2: DOM-text ovanpå canvasen, följer systemets textstorlek. */
.arcade__bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #f8f4e8;
  color: #1b1a17;
  border: 0.125rem solid #1b1a17;
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  line-height: 1.3;
  max-width: 11rem;
  width: max-content;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.arcade__bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.4rem;
  width: 0.55rem;
  height: 0.55rem;
  background: #f8f4e8;
  border-right: 0.125rem solid #1b1a17;
  border-bottom: 0.125rem solid #1b1a17;
  transform: translateX(-50%) rotate(45deg);
}

.arcade__players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.arcade__player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.6rem;
  border: 0.125rem solid var(--gold);
  border-radius: 0.375rem;
  background: #3b2a12;
  color: #f8f4e8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.arcade__player img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  background: #f8f4e8;
  flex: none;
}

/* Helskärm (Android; iPhone saknar API:et): scenen tar hela ytan. */
.arcade:fullscreen, .arcade:-webkit-full-screen {
  background: #1b1a17;
  padding: 0;
}

.arcade:fullscreen .arcade__stage { border-radius: 0; min-height: 100vh; }

/* Liggande telefon: raden överst tar plats i onödan, spelet får hela höjden. */
@media (orientation: landscape) and (max-height: 30rem) {
  .arcade-bar { display: none; }
  .arcade { padding: 0; }
  .arcade__stage { border-radius: 0; min-height: 100dvh; }
}

/* Topplistan (publika sajten). */
.highscore {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

.highscore__row {
  display: grid;
  /* Namnet får det utrymme som blir över; poängen tar sin egen bredd och bryts aldrig. */
  grid-template-columns: 2.2em minmax(0, 1fr) auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  padding: 0.6rem 0.5rem;
  border-bottom: 0.0625rem solid var(--line);
}

.highscore__row--me {
  background: color-mix(in srgb, var(--gold) 18%, transparent);
  border-radius: 0.5rem;
}

.highscore__rank {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 1.3em;
  text-align: center;
  color: var(--gold);
}

.highscore__row:first-child .highscore__rank { color: var(--green-text, var(--green)); }

/* Avatar, namn och ibland etiketten "overifierad": etiketten lägger sig under namnet när raden är smal. */
.highscore__who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.5rem;
  min-width: 0;
}

.highscore__name { font-weight: 700; }

.highscore__legend { margin: 0.75rem 0 0; }

.highscore__points {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 1.15em;
  letter-spacing: 0.02em;
  white-space: nowrap;
  justify-self: end;
}

.highscore__detail {
  grid-column: 2 / -1;
  font-size: 0.9em;
  color: var(--grey);
}

.highscore__empty { color: var(--grey); }

/* Offline-sidan. */
.offline-note { text-align: center; }

/* En länk som ser ut som en knapp (Spela, till spelet). */
a.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border-radius: 0.75rem;
  text-decoration: none;
  font-weight: 700;
  box-sizing: border-box;
}
