:root {
    --bg: #070b18;
    --ink: #e8ecff;
    --dim: #8fa0d0;
    --accent: #6ef3c5;
    --danger: #ff5d73;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    height: 100%;
    touch-action: manipulation;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    background: var(--bg);
    color: var(--ink);
    font-family: "Menlo", "Consolas", monospace;
    overflow: hidden;
  }
  #wrap {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  canvas {
    background: #070b18;
    image-rendering: pixelated;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
    box-shadow: 0 0 60px rgba(110, 243, 197, 0.12);
  }
  #overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(7, 11, 24, 0.86);
    padding: 24px;
    gap: 14px;
  }
  #overlay.hidden { display: none; }
  h1 { font-size: 40px; margin: 0; letter-spacing: 2px; color: var(--accent); }
  h2 { font-size: 26px; margin: 0; }
  p { margin: 0; color: var(--dim); line-height: 1.7; font-size: 15px; }
  kbd {
    background: #18213c;
    border: 1px solid #2f3c66;
    border-radius: 4px;
    padding: 2px 7px;
    color: var(--ink);
  }
  .big { color: var(--accent); font-size: 20px; }
  .bad { color: var(--danger); }
  .hint { font-size: 13px; opacity: 0.7; margin-top: 10px; max-width: 560px; line-height: 2; text-wrap: balance; }
  .hint .pieni { font-size: 11px; opacity: 0.8; }

  /* työkalurivi pelialueen yläreunassa: tauko, äänet, koko näyttö */
  #tyokalut {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 6;
  }
  #tyokalut button {
    width: 34px;
    height: 34px;
    padding: 0;
    font-family: inherit;
    font-size: 15px;
    line-height: 1;
    color: var(--ink);
    background: rgba(22, 32, 63, 0.72);
    border: 1px solid #2f3c66;
    border-radius: 9px;
    cursor: pointer;
    opacity: 0.8;
  }
  #tyokalut button:hover { opacity: 1; }
  #tyokalut button.pois { color: #5a6690; text-decoration: line-through; }
  #valinnat { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 4px 0 2px; }
  .valinta {
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 2px;
    border: 2px solid #2a3355;
    border-radius: 10px;
    padding: 16px 26px;
    min-width: 150px;
    background: #0d142a;
    cursor: pointer;
  }
  .valinta.valittu { background: #16203f; transform: scale(1.06); }
  .iso-nappi {
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #070b18;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    padding: 15px 28px;
    margin-top: 6px;
    cursor: pointer;
  }

  /* liukupalkki pelin alla - vain kosketuslaitteille */
  #ohjaus { display: none; }
  @media (pointer: coarse) {
    #wrap { flex-direction: column; justify-content: center; }
    canvas { min-height: 0; flex: 0 1 auto; }
    #ohjaus {
      display: block;
      position: relative;
      flex: 0 0 auto;
      height: 120px;
      max-width: 100%;
      margin-top: 10px;
      margin-bottom: env(safe-area-inset-bottom);
      border-radius: 18px;
      background: linear-gradient(180deg, #111a35, #0b1226);
      border: 2px solid #2f3c66;
      touch-action: none;
      overflow: hidden;
    }
    #ohjaus-merkki {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 54px;
      height: 54px;
      margin: -27px 0 0 -27px;
      border-radius: 50%;
      background: rgba(110, 243, 197, 0.16);
      border: 2px solid var(--accent);
      box-shadow: 0 0 18px rgba(110, 243, 197, 0.35);
      pointer-events: none;
    }
    #ohjaus-teksti {
      position: absolute;
      inset: auto 0 10px 0;
      text-align: center;
      color: var(--dim);
      font-size: 12px;
      letter-spacing: 1px;
      pointer-events: none;
      transition: opacity 0.4s;
    }
    #ohjaus-teksti.piilossa { opacity: 0; }
    .nuoli {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      font-size: 34px;
      color: #2f3c66;
      pointer-events: none;
    }
    .nuoli.vasen { left: 14px; }
    .nuoli.oikea { right: 14px; }
    h1 { font-size: 30px; }
    .valinta { padding: 18px 22px; min-width: 120px; }
    #tyokalut button { width: 42px; height: 42px; font-size: 18px; }
  }
  /* vaaka-asennossa matalampi palkki, jotta peliruutu on isompi */
  @media (pointer: coarse) and (orientation: landscape) {
    #ohjaus { height: 58px; margin-top: 6px; }
    #ohjaus-merkki { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
    #ohjaus-teksti { display: none; }
  }
