:root {
  --bg: #264653;          /* mörkt läge bakgrund */
  --fg: #F4A261;          /* text */
  --muted: #a6a7ad;
  --letter: #F4A261;      /* bokstäver */
  --digit: #E9C46A;       /* siffror */
  --special: #E76F51;     /* specialtecken */
  --tile-a: #1e2f35;
  --tile-b: #264653;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}

.light {
  --bg: #ffffff;          /* ljust läge bakgrund */
  --fg: #264653;          /* text */
  --muted: #6c6f75;
  --letter: #264653;      /* bokstäver */
  --digit: #2A9D8F;       /* siffror */
  --special: #E9C46A;     /* specialtecken */
  --tile-a: #f2f3f5;
  --tile-b: #ffffff;
  --shadow: 0 10px 40px rgba(0,0,0,.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--fg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.topbar { display: flex; gap: 8px; padding: 12px 16px; align-items: center; }
.brand { font-weight: 700; letter-spacing: 0.3px; opacity: .9; }

.input { flex: 1 1 auto; max-width: 100%; display: flex; }
.input input {
  width: 100%; font-size: 18px; padding: 12px 14px; color: var(--fg);
  background: var(--tile-a); border: 1px solid transparent; border-radius: 12px; outline: none;
}
.input input::placeholder { color: var(--muted); }

.btn { border: 1px solid transparent; background: var(--tile-a); color: var(--fg); padding: 10px 12px; border-radius: 12px; cursor: pointer; }

.stage-wrap { display: grid; place-items: center; padding: 8px 16px 0 16px; }
.stage {
  width: 100%; max-width: 2000px; display: inline-flex; align-items: stretch; justify-content: center;
  box-shadow: var(--shadow); border-radius: 18px; overflow: hidden;
  background: linear-gradient( to bottom, var(--tile-b), var(--tile-a) );
}

.cell { display: flex; align-items: center; justify-content: center; min-width: 2ch; position: relative; }
.cell:nth-child(odd) { background: var(--tile-a); }
.cell:nth-child(even){ background: var(--tile-b); }

.glyph { display: inline-block; line-height: 1; white-space: pre; font-weight: 700; text-shadow: 0 1px 0 rgba(0,0,0,.04); }
.letter { color: var(--letter); }
.digit  { color: var(--digit); }
.special{ color: var(--special); }

.cell::after {
  content: attr(data-i);
  position: absolute; bottom: 4px; left: 8px;
  font-size: clamp(10px, 1.6vw, 12px); opacity: .5;
}

.controls { display: flex; gap: 8px; }

.ad { display: grid; place-items: center; width: 100%; min-height: 60px; max-height: 120px; margin: 8px 0 16px 0; }
.ad > div {
  width: min(100%, 728px); height: 90px; border-radius: 12px;
  background: repeating-linear-gradient(45deg, #ddd 0 10px, #ccc 10px 20px);
  color: #333; display: grid; place-items: center; font-weight: 700; letter-spacing: .08em;
}
@media (max-width: 480px) { .ad > div { width: 320px; height: 50px; } }

footer a {
  color: var(--muted);
  text-decoration: none;
  margin: 0 4px;
}

footer a:hover {
  text-decoration: underline;
}

footer { padding: 10px 16px 24px 16px; color: var(--muted); font-size: 12px; text-align: center; }

dialog#infoModal {
  width: min(800px, 95vw);
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: var(--shadow);
  background: var(--tile-b);
  color: var(--fg);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
#infoModal .modal-close {
  position: absolute; top: 8px; right: 8px;
  background: transparent; border: 0; font-size: 20px; cursor: pointer; color: var(--fg);
}
#infoModal article { padding: 20px; max-height: min(70vh, 80svh); overflow: auto; }

a {
  color: var(--fg);
  text-decoration: underline;
}

a:hover {
  color: var(--letter); /* eller välj en annan kontrastfärg */
}


