/* Bakgrunden är färgen som alla delar. --bg och --fg sätts i app.js. */
:root {
  --bg: #808080;
  --fg: #000000;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 250ms, color 250ms;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}

main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* allt mitt på sidan, även i höjdled */
  text-align: center;
  padding: 20px 0;
}

.lang { display: flex; gap: 6px; justify-content: center; }
.lang button {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--fg);
  padding: 4px 10px;
  cursor: pointer;
  opacity: 0.7;
}
.lang button[aria-pressed='true'] { opacity: 1; background: var(--fg); color: var(--bg); }
.lang button:hover { opacity: 1; }

h1 {
  margin: 28px 0 6px;
  font-size: clamp(40px, 12vw, 72px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}

.lead { margin: 0 0 12px; max-width: 40ch; line-height: 1.4; }
.lead span { display: block; } /* en mening per rad */

/* Staplarna. Fyllningen visar kanalens värde (--fill sätts i app.js), och de två
   halvorna är knappar: minus till vänster, plus till höger. */
.bars {
  width: min(100%, 440px);
  display: grid;
  gap: 14px;
  margin: 10px 0 6px;
}

.bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 72px;
  border: 3px solid var(--fg);
  background: linear-gradient(to right, var(--c) var(--fill, 50.2%), #000 var(--fill, 50.2%));
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bar button {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 18px;
  text-shadow: 0 0 3px #000, 0 0 1px #000;
}
.bar button[data-region$='-'] { justify-content: flex-start; }
.bar button[data-region$='+'] { justify-content: flex-end; }
.bar button:hover { background: rgba(255, 255, 255, 0.12); }
.bar button:focus-visible { outline: 3px solid #fff; outline-offset: -6px; }
.bar button.pulse { animation: pulse 200ms ease-out; }
@keyframes pulse {
  50% { background: rgba(255, 255, 255, 0.3); }
}

/* bokstaven och värdet mitt i stapeln, ovanpå knapparna men utan att ta klicken */
.label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  pointer-events: none;
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  text-shadow: 0 0 3px #000, 0 0 1px #000;
  font-variant-numeric: tabular-nums;
}

.code {
  margin: 8px 0 0;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
#hex { display: block; font-size: clamp(32px, 9vw, 48px); font-weight: 700; letter-spacing: 0.04em; }
#rgb { font-size: 15px; opacity: 0.8; }

.keys {
  margin: 14px 0 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
}
.status { min-height: 1.4em; margin: 6px 0 0; font-size: 15px; }

/* vinsten, i vinnarens färg */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 16px 24px;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
  border: 3px solid;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: in 250ms ease-out;
  z-index: 10;
}
.toast[hidden] { display: none; }
.toast[data-winner='white'] { background: #fff; color: #000; border-color: #000; }
.toast[data-winner='black'] { background: #000; color: #fff; border-color: #fff; }
@keyframes in {
  from { transform: translate(-50%, -20px); opacity: 0; }
}

footer { padding: 16px 0 20px; font-size: 13px; }
footer a { color: var(--fg); opacity: 0.7; }
