@font-face {
  font-family: 'ITC Korinna';
  src: url('fonts/ITC Korinna LT Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
  /* Fonts */
  :root {
    --font-oswald: 'Oswald', 'Arial Narrow', Impact, sans-serif;
    --font-libertinus: 'Libertinus Sans', 'Segoe UI', Arial, sans-serif;
    --font-marauder: 'Marauder', Georgia, 'Times New Roman', serif;
    --font-backup-serif: Georgia, 'Times New Roman', serif;
    --bg: #0b1d6b;
    --tile: #1436c4;
    --text: #ffd54a;
    --panel: #0d1a5d;
    --panel-alt: #102c9f;
    --white: #ffffff;
  }

  /* Base */
  html {
    scroll-behavior: auto;
  }

  * {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    background: var(--bg);
    color: var(--white);
    font-family: Georgia, 'Times New Roman', serif;
    min-height: 100vh;
  }

  [hidden] {
    display: none !important;
  }

  header {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    padding: 12px 14px;
  }

  button,
  input,
  textarea,
  select {
    font: inherit;
  }

  /* Header */
  .ti {
    background: transparent;
    color: var(--text);
    border: 0;
    border-bottom: 0;
    font: bold 28px Georgia, serif;
    width: min(420px, 100%);
    text-align: center;
  }

  .bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Board */
  main {
    padding: 0 14px;
    overflow-x: auto;
  }

  #board {
    display: grid;
    gap: 6px;
    margin: 0 auto;
    max-width: 1200px;
  }

  .cat {
    background: var(--panel-alt);
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-oswald);
    font-size: clamp(12px, 2.2vw, 22px);
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 6px;
    word-break: break-word;
  }

  .tile {
    background: var(--tile);
    color: var(--text);
    border-radius: 6px;
    min-height: clamp(54px, 11vw, 110px);
    font: bold clamp(16px, 4vw, 44px) Georgia, serif;
    padding: 4px;
    transition: opacity 0.25s, transform 0.1s;
  }

  .tile:active {
    transform: scale(0.97);
  }

  .tile.used {
    opacity: 0.12;
    pointer-events: none;
  }

  /* Teams */
  #teams {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 14px;
    justify-content: center;
  }

  .team {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-marauder);
    font-variant: small-caps;
    letter-spacing: 0.08em;
    font-size: 16pt;
  }

  .team textarea,
  .team input {
    width: min(170px, 100%);
    max-width: 170px;
    min-height: 2.4em;
    resize: vertical;
    overflow: auto;
    background: transparent;
    color: var(--white);
    border: 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.4);
    padding: 4px;
    font-family: var(--font-marauder);
    font-variant: small-caps;
    letter-spacing: 0.08em;
    font-size: 16pt;
    line-height: 1.15;
    white-space: pre-wrap;
    text-align: center;
  }

  .sc {
    background: rgba(0, 0, 0, 0.6) !important;
    color: var(--text) !important;
    font-family: var(--font-marauder);
    font-variant: small-caps;
    letter-spacing: 0.08em;
    font-size: 16pt;
    min-width: 90px;
  }

  /* Presentation */
  body.presentation-mode {
    overflow: hidden;
  }

  body.presentation-mode header {
    display: flex;
    align-items: center;
  }

  body.presentation-mode .bar {
    display: none;
  }

  body.presentation-mode main {
    padding: 0;
  }

  body.presentation-mode #board {
    max-width: 100%;
    min-width: 100%;
    gap: 8px;
  }

  body.presentation-mode #teams {
    padding: 8px 14px 26px;
    gap: 12px;
    justify-content: center;
  }

  body.presentation-mode .team {
    width: min(280px, 100%);
    min-height: 140px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.46);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
  }

  body.presentation-mode .team textarea,
  body.presentation-mode .team input {
    width: 100%;
    max-width: none;
    min-height: 2.8em;
    font-size: 18pt;
    text-align: center;
  }

  body.presentation-mode .team > button[data-d],
  body.presentation-mode [data-add],
  body.presentation-mode [data-rm] {
    display: none !important;
  }

  body.presentation-mode .sc {
    width: 100%;
    min-width: 0;
    font-size: 28pt;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 213, 74, 0.12) !important;
  }

  #presentation-exit-wrap {
    display: none;
    padding: 0 14px 18px;
    text-align: center;
  }

  body.presentation-mode #presentation-exit-wrap {
    display: block;
  }

  #presentation-exit {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 30;
    background: var(--text);
    color: #111;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 30px;
    line-height: 1;
    font-weight: 700;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 10px;
    opacity: 1;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
  }

  /* Buttons */
  button {
    background: var(--text);
    color: #111;
    border: 0;
    padding: 9px 14px;
    border-radius: 8px;
    font: bold 15px Georgia, serif;
    cursor: pointer;
  }

  button:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible {
    outline: 3px solid var(--white);
  }

  button.ok {
    background: #2e9d4f;
    color: var(--white);
  }

  button.bad {
    background: #c0392b;
    color: var(--white);
  }

  button.ghost {
    background: transparent;
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.5);
  }

  button:disabled {
    opacity: 0.35;
  }

  @media (max-width: 700px) {
    .bar button {
      font-size: 0;
    }

    .bar button::before {
      content: attr(data-mobile);
      font-size: 22px;
      display: inline-block;
      line-height: 1;
    }
  }

  @media (min-width: 701px) {
    .bar button::before {
      content: none;
    }

    .bar button {
      font-size: 15px;
    }
  }

  /* Double Jeopardy theme */
  .rpill {
    padding: 3px 14px;
    border-radius: 999px;
    border: 2px solid var(--text);
    color: var(--text);
    font-family: var(--font-oswald);
    font-size: 14px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  body {
    transition: background 0.5s;
  }

  body.round2 {
    background: radial-gradient(ellipse at 50% 0%, #3b1a94 0%, var(--bg) 55%, #07021f 100%) fixed;
  }

  body.round2 header {
    border-bottom: 2px solid rgba(255, 224, 102, 0.35);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0));
  }

  body.round2 .rpill {
    background: var(--text);
    color: #1a0a52;
    box-shadow: 0 0 16px rgba(255, 224, 102, 0.55);
  }

  body.round2 .cat {
    background: linear-gradient(180deg, #5b2fd0, #2b0f7a);
    border-color: rgba(255, 224, 102, 0.55);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  }

  body.round2 .tile {
    background: linear-gradient(160deg, color-mix(in srgb, var(--tile) 80%, #fff) 0%, var(--tile) 45%, color-mix(in srgb, var(--tile) 70%, #000) 100%);
    border: 2px solid rgba(255, 224, 102, 0.45);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 0 14px rgba(255, 224, 102, 0.35);
    box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.12);
  }

  body.round2 .box {
    border-color: var(--text);
  }

  #dd-splash.dj {
    background: radial-gradient(circle at 50% 50%, #5b2fd0 0%, #1a0a52 55%, #07021f 100%);
  }

  #dd-splash.dj::before {
    background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.16) 0deg 5deg, transparent 5deg 15deg);
    animation-direction: reverse;
  }

  #dd-splash.dj .dd-title {
    color: #fff;
    text-shadow: 0 4px 0 #6d3ee0, 0 8px 0 #2b0f7a, 0 0 44px rgba(190, 150, 255, 0.9);
  }

  /* Daily Double theme */
  #dd-splash {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    background: radial-gradient(circle at 50% 50%, #2a4fe0 0%, #0b1d6b 55%, #030a2e 100%);
    animation: ddFade 0.25s ease-out;
  }

  #dd-splash::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: repeating-conic-gradient(from 0deg, rgba(255, 213, 74, 0.22) 0deg 7deg, transparent 7deg 20deg);
    animation: ddSpin 14s linear infinite;
  }

  #dd-splash.out {
    opacity: 0;
    transition: opacity 0.35s ease-in;
  }

  .dd-wrap {
    position: relative;
    text-align: center;
    padding: 0 16px;
  }

  .dd-title {
    font-family: 'ITC Korinna', var(--font-oswald);
    font-weight: 700;
    font-size: clamp(40px, 12vw, 140px);
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #ffd54a;
    text-shadow: 0 4px 0 #a86a00, 0 8px 0 #6b3d00, 0 0 40px rgba(255, 213, 74, 0.75);
    animation: ddSlam 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both, ddPulse 1.1s ease-in-out 0.8s infinite;
  }

  .dd-title span {
    display: block;
  }

  .dd-sub {
    margin-top: 18px;
    font-family: var(--font-oswald);
    font-size: clamp(14px, 3vw, 26px);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #fff;
    opacity: 0;
    animation: ddFade 0.5s ease-out 1s forwards;
  }

  .box.dd {
    background: linear-gradient(180deg, #14308f 0%, #0d1a5d 100%);
    border-color: #ffd54a;
    box-shadow: 0 0 0 4px #0b1d6b, 0 0 0 7px #ffd54a, 0 0 40px rgba(255, 213, 74, 0.5);
    animation: ddPop 0.35s ease-out;
  }

  .box.dd h2 {
    font-family: 'ITC Korinna', var(--font-oswald);
    text-align: center;
    font-size: clamp(24px, 5vw, 38px);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-shadow: 0 2px 0 #a86a00, 0 0 18px rgba(255, 213, 74, 0.6);
  }

  .dd-badge {
    display: block;
    width: fit-content;
    margin: 0 auto 8px;
    padding: 4px 16px;
    border-radius: 999px;
    background: #ffd54a;
    color: #0b1d6b;
    font-family: var(--font-oswald);
    font-size: 14px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    box-shadow: 0 0 18px rgba(255, 213, 74, 0.6);
  }

  @keyframes ddSlam {
    0% { transform: scale(4) rotate(-6deg); opacity: 0; }
    60% { opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
  }

  @keyframes ddPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
  }

  @keyframes ddSpin {
    to { transform: rotate(360deg); }
  }

  @keyframes ddFade {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes ddPop {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }

  @media (prefers-reduced-motion: reduce) {
    #dd-splash::before,
    .dd-title,
    .box.dd {
      animation: none;
    }
    .dd-sub {
      animation: none;
      opacity: 1;
    }
  }

  /* Modal */
  #m {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px;
    z-index: 9;
  }

  .box {
    background: var(--panel);
    border: 3px solid var(--text);
    border-radius: 12px;
    width: 100%;
    max-width: 760px;
    max-height: 100%;
    overflow: auto;
    padding: 20px;
  }

  .box h2 {
    margin: 0 0 10px;
    color: var(--text);
  }

  .box label {
    display: block;
    margin: 10px 0 4px;
    font-size: 14px;
    opacity: 0.9;
  }

  .box input,
  .box textarea,
  .box select {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: var(--white);
    color: #111;
    font: 16px Georgia, serif;
  }

  .box textarea {
    min-height: 70px;
    resize: vertical;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: var(--edit-font-size, 12pt);
    line-height: 1.4;
  }

  #eq,
  #ea,
  #fq,
  #fa {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: var(--edit-font-size, 12pt);
  }

  .box input[type='checkbox'] {
    width: auto;
  }

  .box input[type='color'] {
    height: 38px;
    padding: 2px;
  }

  .box input[type='file'] {
    background: none;
    color: var(--white);
    border: 0;
    padding: 6px 0;
  }

  .g2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
  }

  .row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    align-items: center;
  }

  .row input {
    flex: 1;
    min-width: 140px;
  }

  .grow {
    flex: 1;
  }

  .pair {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 8px;
  }

  .ch {
    text-align: center;
    color: var(--text);
    font-family: var(--font-libertinus);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .q {
    text-align: center;
    font-family: 'ITC Korinna', var(--font-libertinus);
    font-size: clamp(22px, 4.5vw, 40px);
    font-weight: 700;
    line-height: 1.3;
    margin: 18px 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: pre-wrap;
  }

  .ans {
    text-align: center;
    font-family: var(--font-libertinus);
    font-size: clamp(20px, 4vw, 32px);
    color: var(--text);
    margin: 14px 0;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: pre-wrap;
  }

  .box img,
  .box video {
    display: block;
    margin: 10px auto;
    max-width: 100%;
    max-height: 45vh;
    border-radius: 8px;
  }

  .box audio {
    display: block;
    margin: 12px auto;
    width: 100%;
  }

  .box hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
    margin: 18px 0;
  }

  #toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: #111;
    color: var(--white);
    padding: 10px 16px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 20;
  }

  .audio-panel {
    display: grid;
    gap: 10px;
  }

  .audio-panel label {
    font-size: 14px;
    opacity: 0.95;
  }

  .audio-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .audio-row input[type='range'] {
    flex: 1;
    min-width: 160px;
  }

  .audio-row .value {
    min-width: 48px;
    text-align: right;
    font-weight: 700;
  }

  .audio-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
  }

  .audio-check input {
    width: auto;
  }

  /*Final Jeopardy*/
  .fnote {
    text-align: center;
    opacity: 0.85;
    font-size: 14px;
    margin: 6px 0 0;
  }

  .ftimer {
    font-family: var(--font-oswald);
    font-size: 40px;
    color: var(--text);
    min-width: 56px;
    text-align: center;
  }

  .frank {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    font-size: 20px;
  }

  .frank.win {
    background: rgba(255, 213, 74, 0.18);
    border: 2px solid var(--text);
  }

  .frank .score {
    color: var(--text);
    font-weight: 700;
  }