* {
      box-sizing: border-box;
    }

    html,
    body {
      margin: 0;
      width: 100%;
      height: 100%;
      min-height: 100dvh;
      overflow: hidden;
      overscroll-behavior: none;
      touch-action: none;
      user-select: none;
      font-family: Arial, sans-serif;
      color: #14213d;
      background: #0e1726;
    }

    #game {
      position: fixed;
      inset: 0;
      height: 100dvh;
    }

    canvas {
      display: block;
      width: 100%;
      height: 100%;
      touch-action: none;
    }

    .hud {
      position: fixed;
      left: 12px;
      right: 12px;
      top: max(12px, env(safe-area-inset-top));
      z-index: 2;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
      align-items: center;
      max-width: 980px;
      margin: 0 auto;
      padding: 10px;
      border: 3px solid #263650;
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.92);
      box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
    }

    .mission {
      margin: 0;
      font-size: clamp(18px, 4vw, 25px);
      line-height: 1.15;
    }

    .score {
      padding: 8px 10px;
      border: 2px solid #263650;
      border-radius: 8px;
      background: #dcf8d5;
      font-weight: 800;
      white-space: nowrap;
    }

    .level {
      grid-column: 1 / -1;
      color: #4b5568;
      font-size: 14px;
      font-weight: 700;
    }

    .tools {
      position: fixed;
      left: 12px;
      right: 12px;
      bottom: max(12px, env(safe-area-inset-bottom));
      z-index: 2;
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      max-width: 980px;
      margin: 0 auto;
      padding: 10px;
      border: 3px solid #263650;
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.92);
      box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
    }

    button {
      min-height: 42px;
      flex: 1 1 136px;
      border: 2px solid #263650;
      border-radius: 8px;
      background: #ffffff;
      color: #14213d;
      font-size: 15px;
      font-weight: 800;
      cursor: pointer;
      touch-action: manipulation;
      white-space: nowrap;
    }

    button:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }

    .message {
      flex: 1 1 100%;
      min-height: 22px;
      font-weight: 800;
      overflow-wrap: anywhere;
    }

    .help {
      position: fixed;
      left: 50%;
      top: 112px;
      z-index: 2;
      width: min(92vw, 580px);
      padding: 10px 12px;
      border: 2px solid #263650;
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.9);
      color: #253047;
      font-size: 14px;
      font-weight: 700;
      text-align: center;
      transform: translateX(-50%);
    }

    .crosshair {
      position: fixed;
      left: 50%;
      top: 50%;
      z-index: 2;
      width: 22px;
      height: 22px;
      border: 2px solid rgba(255, 255, 255, 0.9);
      border-radius: 50%;
      box-shadow: 0 0 0 2px rgba(20, 33, 61, 0.35);
      transform: translate(-50%, -50%);
      pointer-events: none;
    }

    .speech {
      position: fixed;
      left: 50%;
      top: 168px;
      z-index: 2;
      width: min(90vw, 430px);
      padding: 12px 14px;
      border: 3px solid #263650;
      border-radius: 14px;
      background: #ffffff;
      font-weight: 800;
      text-align: center;
      transform: translateX(-50%);
      transition: opacity 0.35s ease, transform 0.35s ease;
    }

    .speech.hide {
      opacity: 0;
      transform: translateX(-50%) translateY(-8px);
      pointer-events: none;
    }

    .fullscreen-button {
      background: #17294a;
      color: #ffffff;
    }

    .mobile-controls {
      position: fixed;
      left: max(12px, env(safe-area-inset-left));
      right: max(12px, env(safe-area-inset-right));
      bottom: calc(max(12px, env(safe-area-inset-bottom)) + 142px);
      z-index: 3;
      display: none;
      align-items: end;
      justify-content: space-between;
      gap: 12px;
      pointer-events: none;
    }

    .move-pad {
      display: grid;
      width: 150px;
      grid-template-columns: repeat(3, 46px);
      grid-template-rows: repeat(3, 46px);
      gap: 6px;
      pointer-events: auto;
    }

    .look-pad {
      display: grid;
      width: min(48vw, 220px);
      grid-template-columns: 1fr;
      gap: 8px;
      pointer-events: auto;
    }

    .control-button {
      min-height: 46px;
      flex: initial;
      border: 2px solid rgba(255, 255, 255, 0.82);
      border-radius: 10px;
      color: #ffffff;
      background: rgba(20, 33, 61, 0.9);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
      font-size: 15px;
      touch-action: none;
    }

    .control-button.is-pressed,
    .control-button:active {
      background: #25d8ff;
      color: #071126;
    }

    .control-up {
      grid-column: 2;
      grid-row: 1;
    }

    .control-left {
      grid-column: 1;
      grid-row: 2;
    }

    .control-right {
      grid-column: 3;
      grid-row: 2;
    }

    .control-down {
      grid-column: 2;
      grid-row: 3;
    }

    .find-button {
      min-height: 54px;
      background: #7cff2e;
      color: #071126;
      font-size: 18px;
    }

    @media (max-width: 540px) {
      .hud {
        grid-template-columns: 1fr;
        left: 8px;
        right: 8px;
        padding: 8px;
        border-width: 2px;
      }

      .score {
        text-align: center;
      }

      .help {
        top: 136px;
        width: min(94vw, 520px);
        padding: 8px 10px;
        font-size: 12px;
      }

      .speech {
        top: 198px;
        font-size: 13px;
      }

      .tools {
        left: 8px;
        right: 8px;
        gap: 6px;
        padding: 8px;
        border-width: 2px;
      }

      button,
      .game-nav-button {
        min-height: 38px;
        flex-basis: calc(50% - 6px);
        padding: 6px 8px;
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .message {
        order: -1;
        font-size: 13px;
      }
    }

    @media (hover: none), (max-width: 820px) {
      .mobile-controls {
        display: flex;
      }
    }

    @media (max-width: 480px) {
      .mission {
        font-size: 18px;
      }

      .level {
        font-size: 12px;
      }

      .mobile-controls {
        bottom: calc(max(10px, env(safe-area-inset-bottom)) + 178px);
      }

      .move-pad {
        width: 132px;
        grid-template-columns: repeat(3, 40px);
        grid-template-rows: repeat(3, 40px);
      }

      .look-pad {
        width: min(42vw, 170px);
      }

      .control-button {
        min-height: 40px;
        font-size: 13px;
      }

      .find-button {
        min-height: 48px;
        font-size: 16px;
      }
    }

    @media (max-height: 680px) and (max-width: 820px) {
      .help,
      .speech {
        display: none;
      }

      .hud {
        max-width: calc(100% - 16px);
      }

      .tools {
        max-height: 148px;
        overflow: auto;
      }

      .mobile-controls {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 154px);
      }
    }

.game-nav-button {
  display: inline-flex;
  min-height: 42px;
  flex: 1 1 136px;
  align-items: center;
  justify-content: center;
  border: 2px solid #263650;
  border-radius: 8px;
  background: #14213d;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.game-nav-button:hover {
  background: #263650;
}
