  /* Inter (SIL Open Font License) ligger på egen server, så att besökarnas IP-adresser inte går till Google */
  @font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/font/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

  @font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('/font/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
  }

  :root {
    /* Profilfärg: blå. Grönt och rött är reserverat för rätt och fel i skrivtestet. */
    --primary-color: #1e40af;   /* ytor med vit text: nav, knappar, sidfot */
    --primary-dark: #1e3a8a;    /* hover och flikar */
    --primary-light: #dbeafe;   /* ljusa ytor */
    --primary-text: #1e40af;    /* rubriker och accenter i text */
    --nav-tab-bg: #1e3a8a;      /* inaktiva flikar */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --page-photo-veil: rgba(255, 255, 255, 0.55);   /* ljust lager över bakgrundsbilden */
    --link-color: #2563eb;
    --link-hover: #1d4ed8;
    --focus-ring: #1e40af;
    --bg-primary: #ffffff;
    --bg-secondary: #f1f5f9;
    --card-bg: #ffffff;
    --border-color: #cbd5e1;
    --accent-color: #15803d;
    --success-color: #15803d;
    --tips-bg: #f1f5f9;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --primary-color: #1e40af;
      --primary-dark: #1e3a8a;
      --primary-light: #1e3a8a;
      --primary-text: #93c5fd;
      --nav-tab-bg: #1e293b;
      --text-primary: #f1f5f9;
      --text-secondary: #cbd5e1;
      --text-muted: #94a3b8;
      --page-photo-veil: rgba(15, 23, 42, 0.82);
      --link-color: #93c5fd;
      --link-hover: #bfdbfe;
      --focus-ring: #93c5fd;
      --bg-primary: #0f172a;
      --bg-secondary: #1e293b;
      --card-bg: #1e293b;
      --border-color: #334155;
      --accent-color: #22c55e;
      --success-color: #22c55e;
      --tips-bg: #1e293b;
    }
  }

  * {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  }

  /* Knappar och formulärfält har egna typsnittsstorlekar i webbläsaren; låt dem följa sidan */
  button, input, select, textarea {
    font: inherit;
  }

  html {
    background-color: var(--bg-primary);
  }

  body {
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
  }

  /* Bakgrundsbild bakom sidkolumnen (Vitaly Gariev, Unsplash-licens), med oskärpa inbakad
     och ett lager i sidans färg över. Ligger på html så att den täcker hela fönstret även på
     korta sidor. Visas inte på mobil, där kolumnen fyller hela bredden. */
  @media (min-width: 601px) {
    body {
      background: transparent;
    }

    html {
      background-image: linear-gradient(var(--page-photo-veil), var(--page-photo-veil)), url('/image/bakgrund.jpg');
      background-image: linear-gradient(var(--page-photo-veil), var(--page-photo-veil)),
                        image-set(url('/image/bakgrund.webp') type('image/webp'), url('/image/bakgrund.jpg') type('image/jpeg'));
      background-size: cover;
      background-position: center;
      background-attachment: fixed;
    }
  }

  h1, h2, h3, h4, h5, h6, p, ul, ol, li {
    display: block;
    padding: 8px 5px;
    color: var(--text-primary);
  }

  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    padding-bottom: 4px;
    margin-bottom: 8px;
    font-family: 'Inter', sans-serif;
    line-height: 1.3;
    letter-spacing: -0.025em;
  }

  h1 {
    font-size: 42px;
    color: var(--primary-text);
    font-weight: 700;
    margin-bottom: 24px;
  }

  h2 {
    font-size: 32px;
    color: var(--primary-text);
    margin-bottom: 20px;
  }

  h3 {
    font-size: 26px;
    color: var(--text-secondary);
    margin-bottom: 8px;
  }

  h4 {
    font-size: 22px;
    color: var(--text-secondary);
    margin-bottom: 14px;
  }

  h5, h6 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 12px;
  }

  p {
    font-size: 16px;
    margin-bottom: 8px;
    font-family: 'Inter', sans-serif;
    line-height: 1.7;
    color: var(--text-secondary);
    font-weight: 400;
  }

  .innerimg {
    display: block;
    margin: 0 auto;
  }

  a {
    text-decoration: none;
    color: var(--link-color);
    transition: color 0.2s ease;
  }

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

  ul {
    list-style: disc;
    font-size: 16px;
    margin-bottom: 8px;
    line-height: 1.7;
  }

  ul ul {
    margin-bottom: 8px;
    margin: 8px 32px;
  }

  ul li, ol li {
    display: list-item;
    margin: 4px 32px;
    padding: 2px 0;
    color: var(--text-secondary);
  }

  ul li::marker, ol li::marker {
    color: var(--primary-text);
  }

  ul:nth-last-child(1), p:nth-last-child(1) {
    margin-bottom: 0;
  }

  header, main, .title, .page-head {
    margin: 0 auto;
    max-width: 1000px;
  }

  header, footer {
    margin: 0 auto;
  }

  /* Flikarna står direkt på bakgrundsbilden; menyn scrollar med sidan */
  nav {
    display: block;
    margin: 0 -30px;
    padding: 0;
    background-color: transparent;
  }

  .mininav {
    display: none;
    margin: 0 0;
    padding: 0;
    background-color: var(--primary-color);
  }

  .mininav.show {
    display: block;
  }

  nav ul {
    display: flex;
    flex-direction: row;
    justify-content: left;
    align-items: flex-end;
    list-style: none;
    position: relative;
    padding: 16px 0 8px 0;
    background-color: transparent;
  }

  /* Remsa under flikarna i den aktiva flikens färg: ytans överkant, med rundat högerhörn */
  nav ul::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 8px;
    background-color: var(--primary-light);
    border-top-right-radius: 8px;
  }

  .mininav ul {
    display: block;
    padding: 0;
    margin: 0;
    background-color: var(--primary-dark);
  }

  nav ul li {
    margin: 0 4px 0 0;
    padding: 0;
    text-align: center;
    font-size: 80%;
  }

  .mininav ul li {
    display: block;
    text-align: center;
    font-size: 80%;
    padding: 0;
    margin: 1px 0;
  }

  nav ul li.expand, nav .logo {
    display: none;
  }

  nav ul li a, .mininav ul li a {
    display: block;
    padding: 15px 30px;
    background-color: var(--nav-tab-bg);
    color: #fff;
    font-weight: bold;
    min-width: 100px;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
  }

  .mininav ul li a {
    border-radius: 0;
    padding: 15px 10px;
    min-width: none;
  }

  /* Aktiv flik har samma färg som ytan under, så att den hänger ihop med sidan */
  nav ul li a.active,
  nav ul li a.active:hover {
    display: block;
    color: var(--primary-text);
    background-color: var(--primary-light);
  }

  nav ul li a:hover {
    display: block;
    color: #fff;
    background-color: var(--primary-color);
  }

  .title {
    padding: 15px 30px 5px 30px;
    background-color: var(--primary-light);
  }

  .title span {
    display: block;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 32px;
    margin: 0 5px;
    letter-spacing: -0.025em;
  }

  /* Titel och brödsmula på en rad i den ljusblå ytan under menyn. Ytan är rundad i de nedre
     hörnen; sidor med skrivrutan fortsätter ytan i #TypeWriter, som då får de nedre hörnen. */
  .page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 20px;
    padding: 10px 30px 6px 30px;
    background-color: var(--primary-light);
    border-radius: 0 0 12px 12px;
  }

  body:not(.section-tryme):not(.section-user):not(.section-guider) .page-head {
    box-shadow: 0 24px 40px -24px rgba(15, 23, 42, 0.45);
  }

  .section-tryme .page-head,
  .section-user .page-head,
  .section-guider .page-head {
    border-radius: 0;
  }

  /* Luft mellan ytan och innehållet på sidor utan skrivruta */
  body:not(.section-tryme):not(.section-user):not(.section-guider) main {
    padding-top: 20px;
  }

  .page-head .title-text {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em;
  }

  .breadcrumbs ul {
    display: flex;
    justify-content: flex-start;
    flex-direction: row;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 15px;
  }

  .breadcrumbs ul li {
    margin: 0;
    padding: 0;
    color: var(--text-primary);
  }

  .breadcrumbs ul li a {
    color: var(--primary-text);
  }

  .breadcrumbs ul li:nth-child(1):before {
    content: '';
    margin-left: 0;
  }

  .breadcrumbs ul li:before {
    content: '/';
    margin-left: 5px;
  }

  main {
    padding: 0 30px 20px 30px;
    line-height: 1.7;
  }

  /* Texten ligger i vita kort med rundade hörn: på sidor med skrivruta i .content-card
     (öppnas i system/typer.php), på övriga sidor är hela main kortet. */
  .content-card {
    margin: 16px -30px 12px -30px;
    padding: 10px 30px 20px 30px;
    background-color: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 24px 40px -24px rgba(15, 23, 42, 0.35);
  }

  body:not(.section-tryme):not(.section-user):not(.section-guider) main {
    margin-top: 16px;
    margin-bottom: 32px;
    background-color: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 24px 40px -24px rgba(15, 23, 42, 0.35);
  }

  main .filler {
    display: block;
    width: 100%;
    margin: 0 auto 0 auto;
    padding: 0;
    text-align: center;
    height: 30px;
  }

  main .smallfiller {
    display: block;
    width: 100%;
    margin: 0 auto 0 auto;
    padding: 0;
    text-align: center;
    height: 15px;
  }

  main .blankline {
    display: block;
    width: 100%;
    margin: 0 auto 0 auto;
    padding: 0;
    text-align: center;
    height: 1px;
  }

  main .dottedline {
    display: block;
    width: 100%;
    margin: 0 auto 15px auto;
    padding: 0;
    text-align: center;
    height: 30px;
    border-bottom: dotted 1px var(--border-color);
  }

  footer {
    display: flex;
    flex-direction: row;
    padding: 15px 15px;
    margin: 0;
    background-color: var(--primary-color);
  }

  footer span {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: #FFF;
  }

  footer span a {
    color: #FFF;
  }

  /* Delning under skrivrutan. Efter ett test byter oim_engine.js texten mot resultatet. */
  .share-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 10px 0 0 0;
    padding: 0;
  }

  .share-btn {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    box-sizing: border-box;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-text);
    background: transparent;
    border: 1px solid var(--primary-text);
    border-radius: 6px;
    cursor: pointer;
  }

  .share-btn:hover,
  .share-btn:focus-visible {
    text-decoration: none;
    color: #fff;
    background: var(--primary-color);
    border-color: var(--primary-color);
  }

  /* Footer styles */
  .footer-content {
    text-align: center;
    padding: 20px;
    margin: 0 auto;
  }

  .footer-main {
    margin-bottom: 10px;
  }

  .footer-links {
    font-size: 0.9em;
  }

  /* Sidfoten har blå bakgrund (--primary-color): ljus text, #dbeafe ger 7,3:1 */
  .footer-related {
    margin-top: 8px;
    color: #dbeafe;
  }

  .footer-links a {
    color: #dbeafe;
    text-decoration: none;
    transition: color 0.2s ease;
  }

  .footer-links a:hover {
    color: #fff;
    text-decoration: underline;
  }

  .footer-separator {
    margin: 0 8px;
    color: #dbeafe;
    opacity: 0.6;
  }

  /* Modern Highscore Table */
  .highscore-table-container {
    overflow-x: auto;
    margin-bottom: 45px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background-color: var(--bg-primary);
  }

  .highscore-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
  }

  .highscore-table thead tr {
    background: var(--primary-color);
    color: white;
  }

  .highscore-table th {
    padding: 16px 20px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
  }

  .highscore-table th:first-child {
    border-top-left-radius: 12px;
    text-align: center;
  }

  .highscore-table th:last-child {
    border-top-right-radius: 12px;
    text-align: right;
  }

  .highscore-table tbody tr {
    border-bottom: 1px solid var(--bg-secondary);
    transition: all 0.2s ease;
  }

  .highscore-table tbody tr:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .highscore-table tbody tr.even {
    background-color: var(--bg-primary);
  }

  .highscore-table tbody tr.odd {
    background-color: var(--bg-secondary);
  }

  .highscore-table td {
    padding: 16px 20px;
    border: none;
    font-size: 15px;
    line-height: 1.5;
  }

  .highscore-table .position {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
  }

  .highscore-table .wpm {
    text-align: center;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
  }

  .highscore-table .error-rate {
    text-align: center;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
  }

  .highscore-table .date {
    text-align: right;
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 14px;
  }

  /* Top 3 special styling */
  .highscore-table tbody tr:nth-child(1),
  .highscore-table tbody tr:nth-child(2),
  .highscore-table tbody tr:nth-child(3) {
    background: linear-gradient(90deg, var(--primary-light), var(--bg-primary));
    font-weight: 700;
  }

  @media (max-width: 600px) {
    .highscore-table th,
    .highscore-table td {
      padding: 12px 8px;
      font-size: 13px;
    }

    .highscore-table .wpm {
      font-size: 16px;
    }

    .highscore-table .error-rate {
      font-size: 14px;
    }
  }

  /* Accessibility enhancements */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }

  /* Focus indicators */
  a:focus, button:focus, input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }

  /* Skip to main content link */
  .skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
  }

  .skip-link:focus {
    top: 6px;
  }

  /* Reduced motion support */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* Response */

  @media only screen and (max-width: 900px) {
    nav {
      margin: 0;
      padding: 0;
    }

    nav ul li a {
      padding: 8px 5px;
    }
  }

  @media only screen and (max-width: 700px) {
    nav ul li a {
      padding: 8px 2px;
      font-size: 10px;
    }
  }

  @media only screen and (max-width: 600px) {
    header {
      background-color: var(--bg-primary);
    }

    .title {
      display: none;
    }

    .page-head {
      display: none;
    }

    /* Mobil: ingen bakgrundsbild, så korten behöver varken skugga eller rundning */
    .content-card,
    body:not(.section-tryme):not(.section-user):not(.section-guider) main {
      margin: 0;
      border-radius: 0;
      box-shadow: none;
    }

    .content-card {
      padding: 0;
    }

    nav .logo {
      display: inline-block;
      position: absolute;
      top: 0;
      z-index: 1; /* över nav ul, som har egen bakgrund */
      color: var(--primary-text);
      padding: 12px;
      font-weight: bold;
      font-size: 18px;
    }

    nav ul {
      justify-content: right;
      padding: 0 0 8px 0;
    }

    nav ul li {
      display: none;
    }

    nav ul li.expand {
      display: list-item;
      padding: 0;
      margin: 0;
    }

    nav ul li a {
      padding: 8px 15px;
      font-size: 28px;
      min-width: 20px;
      border-radius: 0;
    }

    nav ul li a:hover {
      text-decoration: none;
    }

    .page-head, .title, main {
      max-width: 100%;
    }

    nav, main, .title, .page-head {
      border-right: none;
      border-left: none;
    }

    /* Mobile-specific improvements */
    body {
      font-size: 14px;
      line-height: 1.4;
    }
    
    #main {
      margin: 10px;
      padding: 15px;
    }
    
    #main_header h1 {
      font-size: 24px;
      margin: 10px 0;
    }
    
    #main_navigation {
      text-align: center;
    }
    
    #main_navigation a {
      display: inline-block;
      margin: 5px;
      padding: 8px 12px;
      font-size: 14px;
    }
    
    /* Improved touch targets */
    button, input[type="button"], .cta-button {
      min-height: 44px;
      padding: 12px 20px;
      font-size: 16px;
    }

    .share-btn {
      min-height: 44px;
    }
    
    /* Better spacing for mobile */
    h1, h2, h3 {
      margin: 15px 0 10px 0;
    }

    /* Rubrikerna i datorstorlek tog fyra rader på en telefon */
    h1 {
      font-size: 28px;
      line-height: 1.25;
    }

    h2 {
      font-size: 23px;
      line-height: 1.3;
    }

    h3 {
      font-size: 19px;
    }
    
    p {
      margin: 10px 0;
    }

    /* Footer mobile styles */
    .footer-content {
      padding: 15px 10px;
    }
    
    .footer-main, .footer-links {
      display: block;
      margin: 5px 0;
    }
    
    .footer-separator {
      display: none;
    }
    
    .footer-links a {
      display: inline-block;
      margin: 3px 8px;
    }
  }
